Skip to content

Class Manus::Networking::Client

ClassList > Manus > Networking > Client

The basic Client Implementation. This class should be inherited from in order to make additions such as specific message listening. This can be done through the RegisterMessage function. Custom message types should start with ID's LARGER than Message.Type.CustomMessage.

Inherits the following classes: Manus::Networking::Peer

Inherited by the following classes: Manus::Networking::SimpleClient

Public Properties

Type Name
property Dictionary< System.Net.IPEndPoint, object > discoveredServers
The servers discovered by our discovery request.

Public Functions

Type Name
Client (NetworkManager p_Man, string p_AppID)
Initializes the Client with the basic message types.
void Connect (string p_Host, int p_Port)
Connects to a given IP Address and Port.
void Connect (System.Net.IPEndPoint p_RemoteEndPoint)
Connects to a given IP EndPoint.
override NetObject CreateObject (NetObject p_NetObj, Vector3 p_Position, Quaternion p_Rotation)
Call this function when an object needs to be created. Internally this sends a request to the server to create an object. The object created will have this client as owner.
override void DestroyObject (NetObject p_NetObj)
Call this function when an object needs to be destroyed. Internally this sends a request to the server to destroy an object.
void Disconnect ()
Disconnects from Server.
override void HandleIncomingMessages ()
Handles the incoming messages, Data messages are passed on to the registered ReceiveMessageFunc functions.
override void ReleaseControlOfObject (NetObject p_NetObj)
Call this function when the client wants to release control of an object. Internally this sends a request to the server to release control of an object.
void SendDiscoverySignal (int p_Port)
Sends a discovery signal on a given port.
override void SendMessage (ushort p_Type, LidNet.NetBuffer p_Msg)
Call this function to send custom messages to the server.
override void Shutdown ()
Shuts the client down.
override void Start ()
Starts the client.
override void TakeControlOfObject (NetObject p_NetObj)
Call this function when the client wants to take control of an object. Internally this sends a request to the server to take control of an object.
override void Update (float p_DT)
Update function, updates the object changes made on objects owned by this client.

Public Functions inherited from Manus::Networking::Peer

See Manus::Networking::Peer

Type Name
NetObject CreateObject (NetObject p_NetObj, UnityEngine.Vector3 p_Position, UnityEngine.Quaternion p_Rotation)
This function must be implemented to allow objects to be created.
void DestroyObject (NetObject p_NetObj)
This function must be implemented to allow objects to be destroyed.
long GetID ()
Gets the ID of this peer.
NetObject GetNetObject (long p_NetID)
Get the NetObject with a given NetID.
List< NetObject > GetNetObjects ()
Returns all the NetObjects.
List< NetObject > GetNetObjectsControlledByPlayer (long p_PlayerNetID)
Returns all the NetObjects that a given player controls.
void HandleIncomingMessages ()
This function must be implemented to handle the Incoming Messages.
void RegisterMessage (Message.Type p_ID, ReceiveMessageFunc p_Msg)
Register a message to listen for. Custom message types should start with ID's LARGER than Message.Type.CustomMessage.
void RegisterMessage (ushort p_ID, ReceiveMessageFunc p_Msg)
Register a message to listen for. Custom message types should start with ID's LARGER than Message.Type.CustomMessage.
void ReleaseControlOfObject (NetObject p_NetObj)
This function must be implemented to allow objects to be released by others.
void SendMessage (Message.Type p_Type, LidNet.NetBuffer p_Msg)
Call this function to send messages.
void SendMessage (ushort p_Type, LidNet.NetBuffer p_Msg)
Call this function to send custom messages to the server.
void SetNetObjectManager (NetObjectManager p_Manager)
Sets the NetObjectManager for managing the NetObjects.
void Shutdown ()
This function must be implemented to shut the Peer down.
void Start ()
This function must be implemented to start the Peer.
void TakeControlOfObject (NetObject p_NetObj)
This function must be implemented to allow objects to be controlled by others.
void UnregisterMessage (Message.Type p_ID)
Stop listening for a certain message. Custom message types should start with ID's LARGER than Message.Type.CustomMessage.
void UnregisterMessage (ushort p_ID)
Stop listening for a certain message. Custom message types should start with ID's LARGER than Message.Type.CustomMessage.
void Update (float p_DT)
Update function, updates whatever is desired on this Peer.

Protected Attributes

Type Name
Dictionary< System.Net.IPEndPoint, object > m_DiscoveredServers = = new Dictionary<System.Net.IPEndPoint, object>()

Protected Attributes inherited from Manus::Networking::Peer

See Manus::Networking::Peer

Type Name
long m_ID = = 0
The ID assigned to this Peer by itself or the peer who controls ID assignment.
NetworkManager m_Manager = = null
The NetworkManager that this peer has been created by.
Dictionary< ushort, ReceiveMessageFunc > m_Messages = = new Dictionary<ushort, ReceiveMessageFunc>()
NetObjectManager m_NetObjectManager
The NetObjectManager that this peer uses to manage its objects.

Protected Functions

Type Name
virtual void OnConnected (string p_Reason)
Function called when a connection is made to a server.
virtual void OnDisconnected (string p_Reason)
Function called when the client disconnects.
virtual object OnReceiveDiscoveryMessage (LidNet.NetIncomingMessage p_Msg)
Function called when the client receives a discovery message from a server, usually contains server information. The returned object is saved to the Discovered Servers list which contains the endpoints of the servers and whatever information is passed back.

Public Properties Documentation

property discoveredServers

Dictionary<System.Net.IPEndPoint, object> Manus.Networking.Client.discoveredServers;

Public Functions Documentation

function Client

Initializes the Client with the basic message types.

inline Manus::Networking::Client::Client (
    NetworkManager p_Man,
    string p_AppID
) 

Parameters:

  • p_Man The Network Manager
  • p_AppID The AppID, this must be unique and is used for matchmaking

function Connect [1/2]

Connects to a given IP Address and Port.

inline void Manus::Networking::Client::Connect (
    string p_Host,
    int p_Port
) 

Parameters:

  • p_Host IP Address
  • p_Port Port

function Connect [2/2]

Connects to a given IP EndPoint.

inline void Manus::Networking::Client::Connect (
    System.Net.IPEndPoint p_RemoteEndPoint
) 

Parameters:

  • p_RemoteEndPoint EndPoint to connect to

function CreateObject

Call this function when an object needs to be created. Internally this sends a request to the server to create an object. The object created will have this client as owner.

inline override NetObject Manus::Networking::Client::CreateObject (
    NetObject p_NetObj,
    Vector3 p_Position,
    Quaternion p_Rotation
) 

Parameters:

  • p_NetObj The prefab of the NetObject to create. (Must be registered as a Networked Prefab!)
  • p_Position The initial position of the spawned object.
  • p_Rotation The initial rotation of the spawned object.

Returns:

NULL, since the NetObject is not instantly created

function DestroyObject

Call this function when an object needs to be destroyed. Internally this sends a request to the server to destroy an object.

inline override void Manus::Networking::Client::DestroyObject (
    NetObject p_NetObj
) 

Parameters:

  • p_NetObj The NetObject to destroy.

function Disconnect

inline void Manus::Networking::Client::Disconnect () 

function HandleIncomingMessages

inline override void Manus::Networking::Client::HandleIncomingMessages () 

function ReleaseControlOfObject

Call this function when the client wants to release control of an object. Internally this sends a request to the server to release control of an object.

inline override void Manus::Networking::Client::ReleaseControlOfObject (
    NetObject p_NetObj
) 

Parameters:

  • p_NetObj The NetObject to take control of

function SendDiscoverySignal

Sends a discovery signal on a given port.

inline void Manus::Networking::Client::SendDiscoverySignal (
    int p_Port
) 

Parameters:

  • p_Port Port to send the signal on

function SendMessage

Call this function to send custom messages to the server.

inline override void Manus::Networking::Client::SendMessage (
    ushort p_Type,
    LidNet.NetBuffer p_Msg
) 

Parameters:

  • p_Type The Message Type
  • p_Msg The Message

function Shutdown

inline override void Manus::Networking::Client::Shutdown () 

function Start

inline override void Manus::Networking::Client::Start () 

function TakeControlOfObject

Call this function when the client wants to take control of an object. Internally this sends a request to the server to take control of an object.

inline override void Manus::Networking::Client::TakeControlOfObject (
    NetObject p_NetObj
) 

Parameters:

  • p_NetObj The NetObject to take control of

function Update

Update function, updates the object changes made on objects owned by this client.

inline override void Manus::Networking::Client::Update (
    float p_DT
) 

Parameters:

  • p_DT (Delta Time) Time passed since last Update Call

Protected Attributes Documentation

variable m_DiscoveredServers

Dictionary<System.Net.IPEndPoint, object> Manus.Networking.Client.m_DiscoveredServers;

Protected Functions Documentation

function OnConnected

Function called when a connection is made to a server.

inline virtual void Manus::Networking::Client::OnConnected (
    string p_Reason
) 

Parameters:

  • p_Reason A string explaining what happened

function OnDisconnected

Function called when the client disconnects.

inline virtual void Manus::Networking::Client::OnDisconnected (
    string p_Reason
) 

Parameters:

  • p_Reason The reason for disconnection

function OnReceiveDiscoveryMessage

Function called when the client receives a discovery message from a server, usually contains server information. The returned object is saved to the Discovered Servers list which contains the endpoints of the servers and whatever information is passed back.

inline virtual object Manus::Networking::Client::OnReceiveDiscoveryMessage (
    LidNet.NetIncomingMessage p_Msg
) 

Parameters:

  • p_Msg

Returns:

Server information


The documentation for this class was generated from the following file api/unity-plugin/Scripts/Networking/Client.cs