Classes

Network

Brief descriptions

Structures

nau::NetworkTransformData

Data for NetworkTransform component sample

nau::NetworkingAddress

Encapsulates address of some type.

nau::NetworkingFactory

Network context instance factory class.

nau::NetworkingMessage

Encapsulates a networking message which is a byte sequence of known size.

nau::INetConnector

Provides an interface for network connector service which manages connections between peers.

nau::INetSnapshots

Provides an interface for network snapshot service.

Classes

nau::NetSyncTransformComponent

nau::INetworking

Provides interface for a network context instance.

nau::INetworkingConnection

Provides basic interface for a connection object.

nau::INetworkingConnector

Provides an interface for establishing a network connection.

nau::INetworkingListener

Provides an interface for listening to a network connection.

nau::INetworkingSignaling

Provides an interface for a side channel for P2P connections.

nau::INetworkingTransport

Provides an interface for data transfer.

nau::INetworkingIdentity

Provides an interface for networking ID of some type.

nau::NetworkingTest

Empty test implementation, developers only usage

Detailed information

NetworkTransformData

engine/core/modules/network/include/nau/network/components/net_sync_transform_component.h

struct NetworkTransformData

Public Functions

rotation auto operator<=>(const NetworkTransformData&) const = default
inline bool write(eastl::string &buffer)
inline bool read(const eastl::string &buffer)

Public Members

math::vec3 position = math::vec3::zero()
math::vec3 scale = math::vec3::zero()
math::quat rotation = math::quat::identity()
position
scale

NetworkingAddress

engine/core/modules/network/include/nau/network/napi/networking_address.h

struct NetworkingAddress

Encapsulates address of some type.

Public Members

NetworkingAddressType type

Address type.

eastl::string address

Address text representation.


NetworkingFactory

engine/core/modules/network/include/nau/network/napi/networking_factory.h

struct NetworkingFactory

Network context instance factory class.

Public Functions

virtual eastl::unique_ptr<INetworking> create(const eastl::string &name) = 0

Creates a network context instance using specific implementation.

Parameters:

name[in] Name of Network implementation

Returns:

A pointer to an INetworking instance or NULL if creation failed.


NetworkingMessage

engine/core/modules/network/include/nau/network/napi/networking_message.h

struct NetworkingMessage

Encapsulates a networking message which is a byte sequence of known size.

Public Functions

NetworkingMessage() = default

Default constructor.

~NetworkingMessage() = default

Destructor.

inline NetworkingMessage(const NetworkingMessage &other)

Copy constructor.

Parameters:

other[in] Intance to copy from.

inline NetworkingMessage &operator=(const NetworkingMessage &other)

Copy-assigment operator.

Parameters:

other[in] Instance to assign.

Returns:

Modified object.

NetworkingMessage(NetworkingMessage &&other) noexcept = default

Move constructor.

Parameters:

other[in] Instance to move from.

NetworkingMessage &operator=(NetworkingMessage &&other) noexcept = default

Move-assigment operator.

Parameters:

other[in] Instance to assign.

Returns:

Modified object.

inline NetworkingMessage(const eastl::string_view &str)

Constructs message from string.

Note

This is a naive constructor for debug purposes.

Parameters:

str[in] String to convert in to a message

inline NetworkingMessage(const eastl::u8string_view &str)

Constructs message from u8string.

Note

This is a naive constructor for debug purposes.

Parameters:

str[in] String to convert in to a message.

Public Members

BytesBuffer buffer

Containes message byte buffer.


INetConnector

engine/core/modules/network/include/nau/network/netsync/net_connector.h

struct INetConnector

Provides an interface for network connector service which manages connections between peers.

Public Functions

virtual void init() = 0

Initializes the service. The function must be called once.

virtual void listen(const eastl::string &localPeerId, const eastl::string &remotePeerId, const eastl::string &uri) = 0

Starts listening to incoming connection.

Parameters:
  • localPeerId[in] Local ID of the peer which is awaiting connection.

  • remotePeerId[in] Remote ID of the peer which is establishing connection.

  • uri[in] URI that describes protocol, address and port for incoming connection.

virtual void getListeners(eastl::vector<ConnectionData> &listeners) = 0

Retrieves information about active listeners.

Parameters:

listeners[out] Data that has been cleared and filled by listeners.

virtual void connect(const eastl::string &localPeerId, const eastl::string &remotePeerId, const eastl::string &uri) = 0

Initiates outgoing connection.

Parameters:
  • localPeerId[in] Local ID of the peer which is establishing connection.

  • remotePeerId[in] Remote ID of the peer which is awaiting connection.

  • uri[in] URI that describes protocol, address and port for outgoing connection.

virtual void getConnectors(eastl::vector<ConnectionData> &connectors) = 0

Retrieves information about active connectors.

Parameters:

listeners[out] Data that has been cleared and filled by connectors.

virtual void getConnections(const eastl::string &peerId, eastl::vector<eastl::string> &peers) = 0

Get peers connected to specified peer.

Parameters:
  • peerId – - specific peer

  • peers – - connected to specific peer peers

virtual void getConnections(eastl::vector<eastl::weak_ptr<IConnection>> &connections) = 0

Get all connections.

Parameters:

connections – - cleared and filled by ptrs to established connections

virtual void writeFrame(const eastl::string &peerId, const eastl::string &frame) = 0

Write frame state, expected to be called once per frame.

Parameters:
  • peerId – - remote peer, destination

  • frame – - serialized frame state

virtual bool readFrame(const eastl::string &peerId, const eastl::string &fromPeerId, eastl::string &frame) = 0

Read frame state.

Parameters:
  • peerId – - local peer, destination

  • fromPeerId – - remote peer, source of frame state

  • frame – - serialized frame state

Returns:

True, if frame state exists, false otherwise

virtual void update() = 0

Update service. Must be called once per frame.

struct ConnectionData

Encapsulates connection information.

Public Members

eastl::string localPeerId
eastl::string remotePeerId
eastl::string localUri
struct IConnection

Provides access to connection data and state.

Public Types

enum State

Enumerates possible connection states.

Values:

enumerator none
enumerator accepted
enumerator connecting
enumerator connected
enumerator disconnecting
enumerator disconnected
enumerator idRequested
enumerator ready
enumerator failed

Public Functions

virtual State state() = 0

Retrieves the connection state.

Returns:

Current connection state.

virtual const eastl::string &localPeerId() = 0

Retrieves the local peer ID. Its representation is implementation-dependent, but it has to be unique for the current sesion,.

Returns:

String ID of the local peer.

virtual const eastl::string &remotePeerId() = 0

Retrieves the remote peer ID. Its representation is implementation-dependent, but it has to be unique for the current sesion,.

Returns:

String ID of the remote peer.

virtual const eastl::string &localEndPoint() = 0

Retrieves the local end point URI.

Returns:

Local end point URI.

virtual const eastl::string &remoteEndPoint() = 0

Retrieves the remote end point URI.

Returns:

Remote end point URI.


INetSnapshots

engine/core/modules/network/include/nau/network/netsync/net_snapshots.h

struct INetSnapshots

Provides an interface for network snapshot service.

Public Functions

virtual void onSceneActivated(IComponentNetScene *scene) = 0

Callback that is dispatched when a scene with an IComponentNetScene object attached is activated.

Parameters:

scene[in] A pointer to IComponentNetScene object.

virtual void onSceneDectivated(IComponentNetScene *scene) = 0

Callback that is dispatched when a scene with an IComponentNetScene object attached is deactivated.

Parameters:

scene[in] A pointer to IComponentNetScene object.

virtual void onSceneUpdated(IComponentNetScene *scene) = 0

Callback that is dispatched when a scene with an IComponentNetScene object attached is updated (which is expected to happen once per frame).

Parameters:

scene[in] A pointer to IComponentNetScene object.

virtual void setOnSceneMissing(nau::Functor<void(eastl::string_view peerId, eastl::string_view sceneName)> callback) = 0

Sets a callback for the scene manager that is dispatched when a snapshot for not yet activated scene is received.

Note

The callback should take the peer ID and the scene name as parameters.

Parameters:

callback[in] Callback to assign.

virtual void onComponentActivated(IComponentNetSync *component) = 0

Callback that is dispatched when an IComponentNetSync scene component is activated.

Parameters:

component[in] A pointer to IComponentNetSync component.

virtual void onComponentDeactivated(IComponentNetSync *component) = 0

Callback that is dispatched when an IComponentNetSync scene component is deactivated.

Parameters:

component[in] A pointer to IComponentNetSync component.

virtual void onComponentWrite(IComponentNetSync *component) = 0

Callback that is dispatched when scene an IComponentNetSync component is updated and serialized.

Parameters:

component[in] A pointer to IComponentNetSync component.

virtual void nextFrame() = 0

Advances networking to the next frame. The function must be called once per frame.

virtual void applyPeerUpdates() = 0

Applies all incoming scene/component updates.

virtual bool doSelfTest() = 0

NetSyncTransformComponent

engine/core/modules/network/include/nau/network/components/net_sync_transform_component.h

class NetSyncTransformComponent : public nau::NetSyncBaseComponent

NetSyncTransformComponent sample Sync transform state between network peers.

Protected Functions

inline virtual void netWrite(BytesBuffer &buffer) override

Serializes the component into a binary buffer.

Parameters:

buffer[out] Buffer storing the serialized data.

inline virtual void netRead(const BytesBuffer &buffer) override

Deserializes the binary buffer into the scene component.

Parameters:

buffer[in] Buffer with serialized data.

inline virtual void netWrite(eastl::string &buffer) override

Serializes the component into a JSON text buffer.

Parameters:

buffer[out] Buffer storing the serialized data.

inline virtual void netRead(const eastl::string &buffer) override

Deserializes the JSON text buffer into the scene component.

Parameters:

buffer[in] Buffer with serialized data.

Protected Attributes

NetworkTransformData m_transform
bool m_wasReplicated = false

Private Functions

Net Sync Net Sync Transform (description)")) ( 1(m_transform
inline Net Sync Net Sync transform bool wasReplicated () const

Private Members

true
Net Sync Transform

INetworking

engine/core/modules/network/include/nau/network/napi/networking.h

class INetworking

Provides interface for a network context instance.

Subclassed by nau::NetworkingASIO, nau::NetworkingTest

Public Functions

virtual bool applyConfig(const eastl::string &data) = 0

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() = 0

Initializes networking context. Call this function once before the first update.

Returns:

true on success, false otherwise.

virtual bool shutdown() = 0

Shuts down the context and frees all resources.

Returns:

true on success, false otherwise.

virtual bool update() = 0

Updates state (polling). This function must be called in a loop.

Returns:

true on success, false otherwise.

virtual const INetworkingIdentity &identity() const = 0

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() = 0

Creates a listener object.

Returns:

A pointer to the INetworkingListener instance or NULL in case of failure.

virtual eastl::shared_ptr<INetworkingConnector> createConnector() = 0

Creates a connector object.

Returns:

A pointer to the INetworkingConnector instance or NULL in case of failure.


INetworkingConnection

engine/core/modules/network/include/nau/network/napi/networking_connection.h

class INetworkingConnection

Provides basic interface for a connection object.

Subclassed by nau::INetworkingConnector, nau::INetworkingListener

Public Functions

virtual void setOnAuthorization(nau::Functor<bool(const INetworkingIdentity &identity, const NetworkingAddress &address)> cb) = 0

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.


INetworkingConnector

engine/core/modules/network/include/nau/network/napi/networking_connection.h

class INetworkingConnector : public nau::INetworkingConnection

Provides an interface for establishing a network connection.

Subclassed by nau::NetworkingConnectorASIO

Public Functions

virtual bool connect(const eastl::string &uri, nau::Functor<void(eastl::shared_ptr<INetworkingTransport>)> successCallback, nau::Functor<void(void)> failCallback) = 0

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.

virtual bool connect(const eastl::string &uri, nau::Functor<void(eastl::shared_ptr<INetworkingTransport>)> successCallback, nau::Functor<void(void)> failCallback, nau::Functor<void(eastl::shared_ptr<INetworkingSignaling>)> signalingCallback) = 0

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() = 0

Stops connection attempts.

Returns:

true, if connection attempts has been stopped, false otherwise.


INetworkingListener

engine/core/modules/network/include/nau/network/napi/networking_connection.h

class INetworkingListener : public nau::INetworkingConnection

Provides an interface for listening to a network connection.

Subclassed by nau::NetworkingListenerASIO

Public Functions

virtual bool listen(const eastl::string &uri, nau::Functor<void(eastl::shared_ptr<INetworkingTransport>)> successCallback, nau::Functor<void(void)> failCallback) = 0

Listens to the connection.

Parameters:
  • uri[in] URI for local endpoint.

  • successCallback[in] Callback that is dispatched, if the connection has succeeded.

  • failCallback[in] Callback that is dispatched, if the connection has failed.

Returns:

true, if listening has started, false otherwise.

virtual bool stop() = 0

Stops listening.

Returns:

true, if listening has stopped, false otherwise.


INetworkingSignaling

engine/core/modules/network/include/nau/network/napi/networking_signaling.h

class INetworkingSignaling

Provides an interface for a side channel for P2P connections.

Public Functions

virtual void send(const eastl::string &identity, const eastl::string &data) = 0

Sends the signal to the side channel.

Parameters:
  • identity[in] Destination identity.

  • data[in] Data to send.

virtual void setOnDispatch(nau::Functor<bool(const eastl::string &fromIdentity, const eastl::string &data)> cb) = 0

Sets the callback that is used to filter data from the side channel.

Note

The callback takes the source directory and a reference to the received data as parameters.

Parameters:

cb[in] Callback to assign.


INetworkingTransport

engine/core/modules/network/include/nau/network/napi/networking_transport.h

class INetworkingTransport

Provides an interface for data transfer.

Subclassed by nau::NetworkingTransportASIO

Public Functions

virtual size_t read(eastl::vector<nau::NetworkingMessage> &messages) = 0

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) = 0

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() = 0

Checks if the connection is alive.

Returns:

true if the connection is still alive, false otherwise.

virtual bool disconnect() = 0

Drops the connection.

Returns:

true if the connections has been dropped successfully, false otherwise.

virtual const eastl::string &localEndPoint() const = 0

Retrieves the local endpoint as URI.

Returns:

Local endpoint in URI form.

virtual const eastl::string &remoteEndPoint() const = 0

Retrieves the remote endpoint as URI.

Returns:

Remote endpoint in URI form.


INetworkingIdentity

engine/core/modules/network/include/nau/network/napi/networkinig_identity.h

class INetworkingIdentity

Provides an interface for networking ID of some type.

Subclassed by nau::NetworkingIdentityASIO

Public Functions

virtual NetworkingIdentityType getType() const = 0

Retrieves the networking ID Type.

Returns:

Networking ID type.

virtual eastl::string toString() const = 0

Retrieves the networking ID text representation.

Returns:

Networking ID text representation


NetworkingTest

engine/core/modules/network/include/nau/network/transportTest/networking_test.h

class NetworkingTest : public nau::INetworking

Empty test implementation, developers only usage.

Public Functions

NetworkingTest()
~NetworkingTest()
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()