interface MAGES::Networking::IMAGESNetworkIntegration¶
Overview¶
Interface for a mages network integration module. More…
interface IMAGESNetworkIntegration { // methods bool IsConnectedToServer(); bool CreateRoom(string roomName); bool JoinRoom(string roomName); short? ValidateClientNetworkingSetup(); ListGetAvailableRooms(); string GetCurrentConnectedRoom(); bool EstablishConnectionToMainServer(string args); void Disconnect(); GameObject SpawnObject( GameObject prefab, Transform prefabParent = null, bool isUnique = true ); bool DestroyObject(GameObject gameObject); int GetPrefabIDFromNetwork(GameObject prefab, out bool isUnique); GameObject LinkNetworkObject(GameObject remotePrefab, GameObject localPrefab); void RequestAuthority(GameObject networkObject); int GetNetworkID(GameObject networkObject); void RequestChangeState(byte changeState, string actionID); bool HasAuthority(GameObject networkObject); bool DestroyComponent(GameObject gameObject, string componentType); int GetConnectedUsersToRoom(string roomID); int GetConnectedUsersToCurrentRoom(); IMAGESObjectSynchronization AddSyncTransform(GameObject gameObject); void InitSpawnedObjectForNetwork(GameObject gameObject, bool syncTransform); void InitNetworkHand(GameObject prefab, GameObject instance, bool syncTransform); void InitNetworkAvatar( GameObject prefab, GameObject instance, bool syncTransform ); void AddQuestionSyncScript(GameObject questionPrefab); void AddAnimationActionScript(GameObject animatedObject); void AddChoiceSyncScript(BaseActionData action, GameObject choicePrefab); void NetworkButtonAction( GameObject networkObject, UnityAction action, int index ); void InvokeButtonRemoteCalls(GameObject networkObject, int index); void SyncMessage(GameObject netObject, string message); void AddMessageRemoteAction(GameObject netObject, UnityAction action); void AddInteractableNetworkingEvents(GameObject interactable); void OnStartup(); int GetPing(); };
Detailed Documentation¶
Interface for a mages network integration module.
Methods¶
bool IsConnectedToServer()
Checks if a user is connected to the main server and is ready to join a room.
Returns:
True when the user is connected, false when he is not.
bool CreateRoom(string roomName)
Creates a new network room that users can join.
Parameters:
roomName |
The name ID of the room. |
Returns:
True on successfully creating a room.
bool JoinRoom(string roomName)
Joins an existing network room.
Parameters:
roomName |
The name ID of the room. |
Returns:
True on successfully joining room.
short? ValidateClientNetworkingSetup()
Returns the operation code for when the user tries to establish a connection to the networking client.
Returns:
The return code. Usually 0 means it succeeded.
ListGetAvailableRooms()
Gets all available network rooms.
Returns:
Returns a list with all room names IDs.
string GetCurrentConnectedRoom()
Return current connected room.
Returns:
Returns name of current room. Null if user is not connected to a room.
bool EstablishConnectionToMainServer(string args)
Establishes a connection to the main server. Needs to be called for the networking module to be initialized.
Parameters:
args |
Configuration arguments for this connection. |
Returns:
True when a connection is established successfully.
void Disconnect()
Disconnects user from the main server by disconnecting.
GameObject SpawnObject( GameObject prefab, Transform prefabParent = null, bool isUnique = true )
Spawns a network object for all users.
Parameters:
prefab |
Network gameobject that will be spawned. |
prefabParent |
The parent that will be spawned with. |
isUnique |
Whether this object should be unique. |
Returns:
Returns the spawned object.
bool DestroyObject(GameObject gameObject)
Destroys a network object for all users.
Parameters:
gameObject |
The object to be destroyed. |
Returns:
Returns true if destroy was successful.
int GetPrefabIDFromNetwork(GameObject prefab, out bool isUnique)
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.
GameObject LinkNetworkObject(GameObject remotePrefab, GameObject localPrefab)
Links network object with the remote object.
Parameters:
remotePrefab |
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:
The new linked object.
void RequestAuthority(GameObject networkObject)
Transfers ownership of a network object to the current user.
Parameters:
networkObject |
The network object which this user wants to control. |
int GetNetworkID(GameObject networkObject)
Retrieves the network id of a network object.
Parameters:
networkObject |
The network object to retrieve the ID from. |
Returns:
The network id of the object. Returns -1 if not a networkObject.
void RequestChangeState(byte changeState, string actionID)
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. |
bool HasAuthority(GameObject networkObject)
Returns if the user has authority on this gameObject.
Parameters:
networkObject |
The network object that will be checked. |
Returns:
True if this user has authority over the object.
bool DestroyComponent(GameObject gameObject, string componentType)
Destroys a component to all other users.
Parameters:
gameObject |
The network object that will be checked has the component. |
componentType |
The component type that will be destroyed. |
Returns:
True if the component was destroyed successfully.
int GetConnectedUsersToRoom(string roomID)
Gets connected users to a specific room.
Parameters:
roomID |
The name ID of the room. |
Returns:
The number of the connected users. Returns -1 if the room does not exist.
int GetConnectedUsersToCurrentRoom()
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.
IMAGESObjectSynchronization AddSyncTransform(GameObject gameObject)
Adds the sync transform component to the gameobject and returns it.
Parameters:
gameObject |
The gameobject that will be passed as argument. |
Returns:
Reference to the sync transform component.
void InitSpawnedObjectForNetwork(GameObject gameObject, bool syncTransform)
Initializes an object for multiplayer that is already spawned.
Parameters:
gameObject |
The object that is spawned. |
syncTransform |
If the object’s transform should be synchronized. |
void InitNetworkHand(GameObject prefab, GameObject instance, bool syncTransform)
Initializes and synchronizes the hand prefab inside the network.
Parameters:
prefab |
The prefab of the hand. |
instance |
The instance of the hand inside the scene. |
syncTransform |
If the object’s transform should be synchronized. |
void InitNetworkAvatar( GameObject prefab, GameObject instance, bool syncTransform )
Initializes and synchronizes the avatar prefab inside the network.
Parameters:
prefab |
The prefab of the avatar. |
instance |
The instance of the avatar inside the scene. |
syncTransform |
If the object’s transform should be synchronized. |
void AddQuestionSyncScript(GameObject questionPrefab)
Adds and initializes network script for question action prefab.
Parameters:
questionPrefab |
The question UI prefab that has the question and the answers. |
void AddAnimationActionScript(GameObject animatedObject)
Adds and initializes network script to sync the Animation Action.
Parameters:
animatedObject |
The animation prefab that spawns in the Action. |
void AddChoiceSyncScript(BaseActionData action, GameObject choicePrefab)
Adds and initializes network script for choice action prefab.
Parameters:
action |
The choice action data. |
choicePrefab |
The choice action game object instance. |
void NetworkButtonAction( GameObject networkObject, UnityAction action, int index )
Adds to a specific button the apropriate network action.
Parameters:
networkObject |
The network object that holds the buttons list. |
action |
The action that will be attached to the button. |
index |
The index of the button in the list of buttons. |
void InvokeButtonRemoteCalls(GameObject networkObject, int index)
Invoke calls of a specific network button from the list attched to the object.
Parameters:
networkObject |
The network object that holds the buttons list. |
index |
The index of the button in the list of buttons. |
void SyncMessage(GameObject netObject, string message)
Call to sync a message among clients.
Parameters:
netObject |
The object that synces the message. |
message |
The message to be synced. |
void AddMessageRemoteAction(GameObject netObject, UnityActionaction)
Subscribe a unity action to message recieved event.
Parameters:
netObject |
The network object that holds the event. |
action |
An action to subscribe on message recieved event, invoke. |
void AddInteractableNetworkingEvents(GameObject interactable)
Adds networking events to an interactable object.
Parameters:
interactable |
The interactable to add to. |
void OnStartup()
Called on startup to initialize this integration.
int GetPing()
Gets the ping of the current to the server.
Returns:
An integer indicating the ping.