class MAGES::NetworkingModule¶
Overview¶
The networking module base class. More…
class NetworkingModule: public MAGES::HubModule { public: // properties bool AutomaticSceneSetup; Type NetworkIdType; IMAGESNetworkIntegration Integration; bool IsInitialized; bool IsHost; // methods virtual abstract bool EstablishConnectionToMainServer(string args) = 0; virtual abstract void DisconnectFromMainServer() = 0; virtual abstract bool CreateRoom(string roomName) = 0; virtual abstract bool JoinRoom(string roomName = null) = 0; virtual abstract bool ExitCurrentRoom() = 0; virtual abstract ListGetAvailableRooms() = 0; virtual abstract string GetCurrentConnectedRoom() = 0; virtual abstract void OnDisconnected(string cause) = 0; virtual abstract void OnConnected(string info) = 0; virtual abstract bool OwnershipRequest(MAGESObject obj) = 0; virtual abstract int GetPrefabIDFromNetwork( GameObject prefab, out bool isUnique ) = 0; virtual abstract bool LinkNetworkObject( GameObject networkPrefab, GameObject localPrefab ) = 0; virtual abstract GameObject NetworkSpawn( GameObject prefab, bool spawnedByHost = true ) = 0; virtual abstract void RemoteDestroyComponent( GameObject gameObject, string componentType ) = 0; virtual abstract void RequestChangeState(byte changeState, string actionID) = 0; virtual abstract int GetConnectedUsersToRoom(string roomName) = 0; virtual abstract int GetConnectedUsersToCurrentRoom() = 0; virtual abstract void AddSyncTransform(GameObject objectToBeSynchronized) = 0; virtual abstract void RegisterActivatedObject( GameObject grabbableObject, bool isActivated ) = 0; virtual abstract bool IsRemoteActivated(GameObject grabbableObject) = 0; virtual abstract bool HasAuthority(GameObject networkObject) = 0; }; // direct descendants class MAGESNetworking; class StubNetworking;
Inherited Members¶
public: // methods virtual abstract void Startup() = 0; virtual abstract void Shutdown() = 0;
Detailed Documentation¶
The networking module base class.
Properties¶
bool AutomaticSceneSetup
Gets or sets a value indicating whether all grabbable objects in the scene will automatically be configured for multiplayer. This will enforce the default configuration.
Type NetworkIdType
Gets or sets the class type of the networking id.
IMAGESNetworkIntegration Integration
Gets or sets the plugin that will handle the networking logic.
bool IsInitialized
Gets or sets a value indicating whether the networking module has been initialized.
Returns:
True after connection has been established with the server.
bool IsHost
Gets or sets a value indicating whether this user is host.
Returns:
True if user is host. False if user is not host or has not joined a room yet.
Methods¶
virtual abstract bool EstablishConnectionToMainServer(string args) = 0
Establish connection to the main server.
Parameters:
args |
Connect arguments. Regions eu, us etc. |
Returns:
Return true if connection succeed.
virtual abstract void DisconnectFromMainServer() = 0
Disconnect from main server. Does nothing if client is not already connected.
virtual abstract bool CreateRoom(string roomName) = 0
Creates a room with the provided name.
Parameters:
roomName |
Room name. |
Returns:
True if room was created successfully.
virtual abstract bool JoinRoom(string roomName = null) = 0
Attempts to join a room with the provided name.
Parameters:
roomName |
The room name to join. |
Returns:
True if room was created successfully.
virtual abstract bool ExitCurrentRoom() = 0
Exits the current room.
Returns:
True if exited successfully.
virtual abstract ListGetAvailableRooms() = 0
Find and return all available rooms.
Returns:
Return a list with all available rooms.
virtual abstract string GetCurrentConnectedRoom() = 0
Return current connected room.
Returns:
Returns name of current room. Null if user is not connected to a room.
virtual abstract void OnDisconnected(string cause) = 0
Called on disconnected.
Parameters:
cause |
Disconnect cause. |
virtual abstract void OnConnected(string info) = 0
Called on connected to a room.
Parameters:
info |
Connection info. |
virtual abstract bool OwnershipRequest(MAGESObject obj) = 0
Request ownership for a MAGESObject.
Parameters:
obj |
The obj to take ownership. |
Returns:
Returns true if request succeed.
virtual abstract int GetPrefabIDFromNetwork( GameObject prefab, out bool isUnique ) = 0
Gets the prefab id from an object that was spawned from the network.
Parameters:
prefab |
The object to be checked. |
isUnique |
Whether this object should be unique. |
Returns:
A positive integer in case the object is from network. Else, returns -1.
virtual abstract bool LinkNetworkObject( GameObject networkPrefab, GameObject localPrefab ) = 0
Links network object with the remote object.
Parameters:
networkPrefab |
The remote object will be linked with the local prefab. At the end it is destroyed. |
localPrefab |
The local object that will be marked as remote. |
Returns:
True if linking was successful. False otherwise.
virtual abstract GameObject NetworkSpawn( GameObject prefab, bool spawnedByHost = true ) = 0
Spawns a gameobject over the network. Only required to be called from one user, preferably the host.
Parameters:
prefab |
Network object to be spawned. |
spawnedByHost |
If the object will be spawned by the host to all users. True by default. |
Returns:
The spawned object.
virtual abstract void RemoteDestroyComponent( GameObject gameObject, string componentType ) = 0
Destroys component in all other users.
Parameters:
gameObject |
The gameobject that has that component. |
componentType |
The type of component. |
virtual abstract void RequestChangeState(byte changeState, string actionID) = 0
Request a change in scenegraph’s state.
Parameters:
changeState |
The change keycode that will be requested. |
actionID |
The ID of the action that will change. |
virtual abstract int GetConnectedUsersToRoom(string roomName) = 0
Gets connected users to a specific room.
Parameters:
roomName |
The name ID of the room. |
Returns:
The number of the connected users. Returns -1 if the room does not exist.
virtual abstract int GetConnectedUsersToCurrentRoom() = 0
Gets connected users to the current room.
Returns:
The number of the connected users in the current room. Returns -1 if not connected to a room.
virtual abstract void AddSyncTransform(GameObject objectToBeSynchronized) = 0
Adds default sync transform to a gameobject.
Parameters:
objectToBeSynchronized |
The change keycode that will be requested. |
virtual abstract void RegisterActivatedObject( GameObject grabbableObject, bool isActivated ) = 0
Register an object that was remotely activated.
Parameters:
grabbableObject |
Object that is remotely activated. |
isActivated |
If true the object is added, if false the object is removed. |
virtual abstract bool IsRemoteActivated(GameObject grabbableObject) = 0
Returns true if object is remotely activated.
Parameters:
grabbableObject |
Object to check. |
Returns:
Returns true if object is activated from another user.
virtual abstract bool HasAuthority(GameObject networkObject) = 0
Checks if local user has authority over a network object.
Parameters:
networkObject |
The network object that will be checked. |
Returns:
True if user has authority else false. If the user is not connected in a session.