Classes¶
Network/ASIO
Brief descriptions¶
Classes |
|
Provides interface for ASIO network context instance. |
|
Class for listen for connection |
|
Establishing a ASIO-based network connection. |
|
Encapsulates ASIO-specific ID. |
|
Provides ASIO-based data transfer mechanism. |
|
Structures |
|
Detailed information¶
NetworkingASIO¶
engine/core/modules/network/include/nau/network/asio/networking_asio.h
-
class NetworkingASIO : public nau::INetworking¶
Provides interface for ASIO network context instance.
Public Functions
-
NetworkingASIO()¶
Default constructor.
-
~NetworkingASIO()¶
Destructor.
-
virtual bool applyConfig(const eastl::string &data) override¶
Apply config string.
- Parameters:
data – [in] String data in implementation dependent format.
- Returns:
true
, if the string data has been successfully parsed and applied,false
otherwise.
-
virtual bool init() override¶
Initializes networking context. Call this function once before the first update.
- Returns:
true
on success,false
otherwise.
-
virtual bool shutdown() override¶
Shuts down the context and frees all resources.
- Returns:
true
on success,false
otherwise.
-
virtual bool update() override¶
Updates state (polling). This function must be called in a loop.
- Returns:
true
on success,false
otherwise.
-
virtual const INetworkingIdentity &identity() const override¶
Retrieves the context instance id. It has to be unique for each instance in each process.
- Returns:
A reference to a INetworkingIdentity object.
-
virtual eastl::shared_ptr<INetworkingListener> createListener() override¶
Creates a listener object.
- Returns:
A pointer to the INetworkingListener instance or
NULL
in case of failure.
-
virtual eastl::shared_ptr<INetworkingConnector> createConnector() override¶
Creates a connector object.
- Returns:
A pointer to the INetworkingConnector instance or
NULL
in case of failure.
Public Static Functions
-
static inline eastl::unique_ptr<nau::INetworking> create()¶
Creates a NetworkingASIO instance.
- Returns:
A pointer to the created NetworkingASIO instance.
Private Members
-
eastl::string m_identity¶
-
asio::io_context m_io_context¶
-
eastl::vector<eastl::shared_ptr<NetworkingListenerASIO>> m_listeners¶
-
eastl::vector<eastl::shared_ptr<NetworkingConnectorASIO>> m_connectors¶
-
NetworkingASIO()¶
NetworkingListenerASIO¶
engine/core/modules/network/include/nau/network/asio/networking_connection_asio.h
-
class NetworkingListenerASIO : public nau::INetworkingListener¶
Class for listen for connection.
Public Functions
-
NetworkingListenerASIO(asio::io_context &io_context)¶
-
~NetworkingListenerASIO()¶
-
void setOnAuthorization(nau::Functor<bool(const INetworkingIdentity &identity, const NetworkingAddress&)> address) override¶
Sets the callback that is dispatched when a connection attempts to authorize.
Note
The callback takes the identity to check and the address of incoming connection as parameters.
- Parameters:
cb – [in] Callback to assign.
Listen for connection.
- Parameters:
uri – [in] URI for local endpoint
successCallback – [in] Callback, if connection succeeded
failCallback – [in] Callback, if connection failed
- Returns:
True, if listening begin, false otherwise
-
virtual bool stop() override¶
Stop listen.
- Returns:
True if stopped, false otherwise
Private Members
-
NetworkingConectionASIOContext m_context¶
-
eastl::shared_ptr<ASIO_Acceptor> m_acceptor¶
-
eastl::vector<eastl::shared_ptr<ASIO_Connection>> m_incomingConnections¶
-
NetworkingListenerASIO(asio::io_context &io_context)¶
NetworkingConnectorASIO¶
engine/core/modules/network/include/nau/network/asio/networking_connection_asio.h
-
class NetworkingConnectorASIO : public nau::INetworkingConnector¶
Establishing a ASIO-based network connection.
Public Functions
-
NetworkingConnectorASIO(asio::io_context &io_context)¶
-
~NetworkingConnectorASIO()¶
-
void setOnAuthorization(nau::Functor<bool(const INetworkingIdentity &identity, const NetworkingAddress&)> address) override¶
Sets the callback that is dispatched when a connection attempts to authorize.
Note
The callback takes the identity to check and the address of incoming connection as parameters.
- Parameters:
cb – [in] Callback to assign.
Connects using URI with callbacks.
- Parameters:
uri – [in] URI for the remote endpoint.
successCallback – [in] Callback that is dispatched, if the connection has been successful.
failCallback – [in] Callback that is dispatched, if the connection has failed.
- Returns:
true
, if connection attempt has started,false
otherwise.
Connects using URI with callbacks.
- Parameters:
uri – [in] URI for remote endpoint.
successCallback – [in] Callback that is dispatched, if the connection has been successful.
failCallback – [in] Callback that is dispatched, if the connection has failed.
signalingCallback – [in] Callback to signaling service.
- Returns:
true
, if connection attempt has started,false
otherwise.
-
virtual bool stop() override¶
Stops connection attempts.
- Returns:
true
, if connection attempts has been stopped,false
otherwise.
Private Members
-
NetworkingConectionASIOContext m_context¶
-
eastl::shared_ptr<ASIO_Connection> m_connection¶
-
NetworkingConnectorASIO(asio::io_context &io_context)¶
NetworkingIdentityASIO¶
engine/core/modules/network/include/nau/network/asio/networking_identity_asio.h
-
class NetworkingIdentityASIO : public nau::INetworkingIdentity¶
Encapsulates ASIO-specific ID.
Public Functions
-
inline NetworkingIdentityASIO(const eastl::string &id)¶
Initialization constructor.
- Parameters:
id – [in] String networking id.
-
~NetworkingIdentityASIO() = default¶
-
inline virtual NetworkingIdentityType getType() const override¶
Retrieves the networking ID Type.
- Returns:
Networking ID type.
-
inline virtual eastl::string toString() const¶
Retrieves the networking ID text representation.
- Returns:
Networking ID text representation
Private Members
-
eastl::string m_dentity¶
-
inline NetworkingIdentityASIO(const eastl::string &id)¶
NetworkingTransportASIO¶
engine/core/modules/network/include/nau/network/asio/networking_transport_asio.h
-
class NetworkingTransportASIO : public nau::INetworkingTransport¶
Provides ASIO-based data transfer mechanism.
Public Functions
-
NetworkingTransportASIO(ASIO_Connection *connection)¶
Initialization constructor.
- Parameters:
connection – [in] A pointer to the connection object.
-
virtual size_t read(eastl::vector<nau::NetworkingMessage> &messages) override¶
Attempts to read received messages.
- Parameters:
messages – [out] A collection of received message. Empty if no messages.
- Returns:
Number of received messages, i.e. size of messages.
-
virtual bool write(const nau::NetworkingMessage &message) override¶
Attempts to send the specified message.
- Parameters:
message – [in] Message to send.
- Returns:
true
if the message can be sent,false
otherwise.
-
virtual bool isConnected() override¶
Checks if the connection is alive.
- Returns:
true
if the connection is still alive,false
otherwise.
-
virtual bool disconnect() override¶
Drops the connection.
- Returns:
true
if the connections has been dropped successfully,false
otherwise.
-
virtual const eastl::string &localEndPoint() const override¶
Retrieves the local endpoint as URI.
- Returns:
Local endpoint in URI form.
-
virtual const eastl::string &remoteEndPoint() const override¶
Retrieves the remote endpoint as URI.
- Returns:
Remote endpoint in URI form.
Private Members
-
ASIO_Connection *m_connection¶
-
NetworkingTransportASIO(ASIO_Connection *connection)¶
NetworkingConectionASIOContext¶
engine/core/modules/network/include/nau/network/asio/networking_connection_asio.h