Class MultiplayerConnection
Defined in File MultiPlayerConnection.h
Class Documentation
-
class MultiplayerConnection
Handling of all multiplayer connection functionality, such as connect, disconnect, entity replication and network events.
Public Types
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.
-
void Connect(ErrorCodeCallbackHandler Callback, ISignalRConnection *SignalRConnection)
Start the connection and register to start receiving updates from the server.
Connect should be called after LogIn and before EnterSpace.
- Parameters
Callback – ErrorCodeCallbackHandler : a callback with failure state.
ISignalRConnection* – SignalRConnection : The SignalR connection to use when talking to the server. The MultiplayerConnection takes ownership of this pointer.
Public Static Functions
-
static std::pair<ErrorCode, std::string> ParseMultiplayerErrorFromExceptionPtr(std::exception_ptr Exception)
Parse a SignalR multiplayer error.
Unpacks the exception and forwards to ParseMultiplayerError
- Parameters
std::exception_ptr – Exception : Pointer to the exception to parse.
- Returns
std::pair<ErrorCode, std::string> First element being the deduced error code, second being the exception message.
-
static std::pair<ErrorCode, std::string> ParseMultiplayerError(const std::exception &Exception)
Parse a SignalR multiplayer error.
- Parameters
const – std::exception& Exception : The exception to parse
- Returns
std::pair<ErrorCode, std::string> First element being the deduced error code, second being the exception message.
-
static ISignalRConnection *MakeSignalRConnection()
Create a default SignalRConnection configured to the configured MultiplayerServiceURI.
- Returns
ISignalRConnection* Pointer to SignalR connection. The caller should take ownership of the pointer.
-
void SetDisconnectionCallback(DisconnectionCallbackHandler Callback)