Skip to content

Class Manus::Networking::SimpleServer

ClassList > Manus > Networking > SimpleServer

This is an example of a Server implementation. It has lobby information, which it sends upon request.

Inherits the following classes: Manus::Networking::Server

Public Attributes

Type Name
Text chatText
Dictionary< string, string > clientsUsername = = new Dictionary<string,string>()
NetLobbyInfo lobbyInfo
bool newChat = = false

Public Attributes inherited from Manus::Networking::Server

See Manus::Networking::Server

Type Name
ClientConnectedFunc onClientConnected
ClientDisconnectedFunc onClientDisconnected

Public Functions

Type Name
void OnClientChatMessage (LidNet.NetIncomingMessage p_ChatText)
void OnSetClientUsername (LidNet.NetIncomingMessage p_Username)
SimpleServer (NetworkManager p_Man, string p_AppID, int p_Port)
Initializes the Server with the basic message types and port connection.

Public Functions inherited from Manus::Networking::Server

See Manus::Networking::Server

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 override void OnRequestServerInfo (LidNet.NetOutgoingMessage p_Msg)
Function called when the server receives a discovery message from a client, they want information about the server. Writes the NetLobbyInfo to a message which the SimpleClient can receive and read.

Protected Functions inherited from Manus::Networking::Server

See Manus::Networking::Server

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 chatText

Text Manus.Networking.SimpleServer.chatText;

variable clientsUsername

Dictionary<string,string> Manus.Networking.SimpleServer.clientsUsername;

variable lobbyInfo

NetLobbyInfo Manus.Networking.SimpleServer.lobbyInfo;

variable newChat

bool Manus.Networking.SimpleServer.newChat;

Public Functions Documentation

function OnClientChatMessage

inline void Manus::Networking::SimpleServer::OnClientChatMessage (
    LidNet.NetIncomingMessage p_ChatText
) 

function OnSetClientUsername

inline void Manus::Networking::SimpleServer::OnSetClientUsername (
    LidNet.NetIncomingMessage p_Username
) 

function SimpleServer

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

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

Protected Functions Documentation

function OnRequestServerInfo

Function called when the server receives a discovery message from a client, they want information about the server. Writes the NetLobbyInfo to a message which the SimpleClient can receive and read.

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

Parameters:

  • p_Msg

Implements Manus::Networking::Server::OnRequestServerInfo


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