Class MultiplayerConnection

Class Documentation

class MultiplayerConnection

Handling of all multiplayer connection functionality, such as connect, disconnect, entity replication and network events.

Public Types

typedef std::function<void(ErrorCode)> ErrorCodeCallbackHandler
typedef std::function<void(const csp::common::String&)> DisconnectionCallbackHandler
typedef std::function<void(const csp::common::String&)> ConnectionCallbackHandler
typedef std::function<void(const csp::common::String&)> NetworkInterruptionCallbackHandler

Public Functions

void SetDisconnectionCallback(DisconnectionCallbackHandler Callback)

Sets a callback for a disconnection event.

Parameters

Callback – DisconnectionCallbackHandler : The callback for disconnection, contains a string with a reason for disconnection.

void SetConnectionCallback(ConnectionCallbackHandler Callback)

Sets a callback for a connection event.

Parameters

Callback – ConnectionCallbackHandler : The callback for connection, contains a string with a status of connection (Success, Failure etc).

void SetNetworkInterruptionCallback(NetworkInterruptionCallbackHandler Callback)

Sets a callback for a network interruption event.

Connection isn’t recoverable after this point and Disconnect should be called.

Parameters

Callback – NetworkInterruptionCallbackHandler : The callback for network interruption, contains a string showing failure.

uint64_t GetClientId() const

Requests the ClientID.

Returns

uint64_t the ClientID for this connection.

ConversationSystem *GetConversationSystem() const

Gets a pointer to the conversation system.

Returns

A pointer to the conversation system.

ConnectionState GetConnectionState() const

Gets the current connection state.

Returns

A ConnectionState enum value.

void SetAllowSelfMessagingFlag(const bool AllowSelfMessaging, ErrorCodeCallbackHandler Callback)

Sets the Self Messaging flag for this client.

This allows a client to declare that it wishes to recieve every patch and object message it sends.

Warning

Don’t use this function if you aren’t sure of the consequences, it’s very unlikely that a client would want to use this!

Parameters
  • AllowSelfMessaging – bool : True to allow and false to disallow.

  • Callback – ErrorCodeCallbackHandler : a callback with failure state.

bool GetAllowSelfMessagingFlag() const

Gets the bool representing if we’re using self-messaging or not.

Returns

True if self messaging is allowed, false otherwise.