Skip to content

Class Manus::Networking::SimpleClient

ClassList > Manus > Networking > SimpleClient

A sample Client implementation which can receive details about hosted games and utilizes the SimpleInterface.

Inherits the following classes: Manus::Networking::Client

Public Attributes

Type Name
SimpleLobbyBrowser lobbyBrowser
SimpleInterface simpleInterface

Public Properties

Type Name
property string name
property string stringID

Public Properties inherited from Manus::Networking::Client

See Manus::Networking::Client

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

Public Functions

Type Name
void SetClientUsername (string p_Username)
SimpleClient (NetworkManager p_Man, string p_AppID)
Initializes the Client with the basic message types.

Public Functions inherited from Manus::Networking::Client

See Manus::Networking::Client

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 inherited from Manus::Networking::Client

See Manus::Networking::Client

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 override void OnConnected (string p_Reason)
Function called when a connection is made to a server. Call the On Connected in the interface.
virtual override void OnDisconnected (string p_Reason)
Function called when the client disconnects. Call the On Disconnected in the interface.
virtual override object OnReceiveDiscoveryMessage (LidNet.NetIncomingMessage p_Msg)
Function called when the client receives a discovery message from a server. The simple implementation reads a NetLobbyInfo data structure. The returned object is saved to the Discovered Servers list.

Protected Functions inherited from Manus::Networking::Client

See Manus::Networking::Client

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 Attributes Documentation

variable lobbyBrowser

SimpleLobbyBrowser Manus.Networking.SimpleClient.lobbyBrowser;

variable simpleInterface

SimpleInterface Manus.Networking.SimpleClient.simpleInterface;

Public Properties Documentation

property name

string Manus.Networking.SimpleClient.name;

property stringID

string Manus.Networking.SimpleClient.stringID;

Public Functions Documentation

function SetClientUsername

inline void Manus::Networking::SimpleClient::SetClientUsername (
    string p_Username
) 

function SimpleClient

Initializes the Client with the basic message types.

inline Manus::Networking::SimpleClient::SimpleClient (
    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

Protected Functions Documentation

function OnConnected

Function called when a connection is made to a server. Call the On Connected in the interface.

inline virtual override void Manus::Networking::SimpleClient::OnConnected (
    string p_Reason
) 

Parameters:

  • p_Reason A string explaining what happened

Implements Manus::Networking::Client::OnConnected

function OnDisconnected

Function called when the client disconnects. Call the On Disconnected in the interface.

inline virtual override void Manus::Networking::SimpleClient::OnDisconnected (
    string p_Reason
) 

Parameters:

  • p_Reason The reason for disconnection

Implements Manus::Networking::Client::OnDisconnected

function OnReceiveDiscoveryMessage

Function called when the client receives a discovery message from a server. The simple implementation reads a NetLobbyInfo data structure. The returned object is saved to the Discovered Servers list.

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

Parameters:

  • p_Msg

Returns:

Server information

Implements Manus::Networking::Client::OnReceiveDiscoveryMessage


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