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();
    List GetAvailableRooms();
    string GetCurrentConnectedRoom();
    bool EstablishConnectionToMainServer(string args);
    void Disconnect();
    GameObject SpawnObject(GameObject prefab, 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 AddQuestionSyncScript(GameObject questionPrefab);
    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.

List GetAvailableRooms()

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, bool isUnique = true)

Spawns a network object for all users.

Parameters:

prefab

Network gameobject that will be spawned.

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 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 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.