Skip to content

Class Manus::Networking::Server

ClassList > Manus > Networking > Server

The basic Server 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::SimpleServer

Public Attributes

Type Name
ClientConnectedFunc onClientConnected
ClientDisconnectedFunc onClientDisconnected

Public Functions

Type Name
delegate void ClientConnectedFunc (long _PlayerNetID)
delegate void ClientDisconnectedFunc (long _PlayerNetID)
override NetObject CreateObject (NetObject p_NetObj, Vector3 p_Position, Quaternion p_Rotation)
Call this function when an object needs to be created.
override void DestroyObject (NetObject p_NetObj)
Call this function when an object needs to be destroyed.
override void HandleIncomingMessages ()
Handles the incoming messages, Data messages are passed on to the registered ReceiveMessageFunc functions.
override void ReleaseControlOfObject (NetObject p_NetObj)
This function is the same as taking control of the object for the server.
override void SendMessage (ushort p_Type, LidNet.NetBuffer p_Msg)
Call this function to send custom messages to the server.
Server (NetworkManager p_Man, string p_AppID, int p_Port)
Initializes the Server with the basic message types and port connection.
override void Shutdown ()
Shuts the server down.
override void Start ()
Starts the server and initializes and takes control of all objects.
override void TakeControlOfObject (NetObject p_NetObj)
Call this function when the server wants to take control of an object.
override void Update (float p_DT)
Update function, updates the object changes made on objects owned by the server.

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::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 OnRequestServerInfo (LidNet.NetOutgoingMessage p_Msg)
Function called when the server receives a discovery message from a client, they want information about the server. The client side should have the opposite in OnReceiveDiscoveryMessage to receive the data correctly. See the SimpleServer.cs for a sample implementation.

Public Attributes Documentation

variable onClientConnected

ClientConnectedFunc Manus.Networking.Server.onClientConnected;

variable onClientDisconnected

ClientDisconnectedFunc Manus.Networking.Server.onClientDisconnected;

Public Functions Documentation

function ClientConnectedFunc

delegate void Manus::Networking::Server::ClientConnectedFunc (
    long _PlayerNetID
) 

function ClientDisconnectedFunc

delegate void Manus::Networking::Server::ClientDisconnectedFunc (
    long _PlayerNetID
) 

function CreateObject

Call this function when an object needs to be created.

inline override NetObject Manus::Networking::Server::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:

The created NetObject.

function DestroyObject

Call this function when an object needs to be destroyed.

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

Parameters:

  • p_NetObj The NetObject to destroy.

function HandleIncomingMessages

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

function ReleaseControlOfObject

This function is the same as taking control of the object for the server.

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

Parameters:

  • p_NetObj The NetObject to take control of

function SendMessage

Call this function to send custom messages to the server.

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

Parameters:

  • p_Type The Message Type
  • p_Msg The Message

function Server

Initializes the Server with the basic message types and port connection.

inline Manus::Networking::Server::Server (
    NetworkManager p_Man,
    string p_AppID,
    int p_Port
) 

Parameters:

  • p_Man The Network Manager
  • p_AppID The AppID, this must be unique and is used for matchmaking
  • p_Port Port the server should listen on

function Shutdown

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

function Start

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

function TakeControlOfObject

Call this function when the server wants to take control of an object.

inline override void Manus::Networking::Server::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 the server.

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

Parameters:

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

Protected Functions Documentation

function OnRequestServerInfo

Function called when the server receives a discovery message from a client, they want information about the server. The client side should have the opposite in OnReceiveDiscoveryMessage to receive the data correctly. See the SimpleServer.cs for a sample implementation.

inline virtual void Manus::Networking::Server::OnRequestServerInfo (
    LidNet.NetOutgoingMessage p_Msg
) 

Parameters:

  • p_Msg

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