Skip to content

Class Manus::Networking::Peer

ClassList > Manus > Networking > Peer

This class is what the Client and Server are based upon. It contains information and functions required for basic functionality.

Inherited by the following classes: Manus::Networking::Client, Manus::Networking::Server

Public Functions

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

Public Functions Documentation

function CreateObject

This function must be implemented to allow objects to be created.

NetObject Manus::Networking::Peer::CreateObject (
    NetObject p_NetObj,
    UnityEngine.Vector3 p_Position,
    UnityEngine.Quaternion p_Rotation
) 

Parameters:

  • p_NetObj The prefab of the NetObject to create.
  • p_Position The initial position of the spawned object.
  • p_Rotation The initial rotation of the spawned object.

Returns:

NULL if NetObject not found or not instantly created

function DestroyObject

This function must be implemented to allow objects to be destroyed.

void Manus::Networking::Peer::DestroyObject (
    NetObject p_NetObj
) 

Parameters:

  • p_NetObj The prefab of the NetObject to destroy.

function GetID

Gets the ID of this peer.

inline long Manus::Networking::Peer::GetID () 

Returns:

The ID of this peer.

function GetNetObject

Get the NetObject with a given NetID.

inline NetObject Manus::Networking::Peer::GetNetObject (
    long p_NetID
) 

Parameters:

  • p_NetID NetID to get

Returns:

function GetNetObjects

Returns all the NetObjects.

inline List< NetObject > Manus::Networking::Peer::GetNetObjects () 

Returns:

A List of NetObjects

function GetNetObjectsControlledByPlayer

Returns all the NetObjects that a given player controls.

inline List< NetObject > Manus::Networking::Peer::GetNetObjectsControlledByPlayer (
    long p_PlayerNetID
) 

Parameters:

  • p_PlayerNetID The controller's ID

Returns:

A List of NetObjects

function HandleIncomingMessages

void Manus::Networking::Peer::HandleIncomingMessages () 

function RegisterMessage [1/2]

Register a message to listen for. Custom message types should start with ID's LARGER than Message.Type.CustomMessage.

inline void Manus::Networking::Peer::RegisterMessage (
    Message.Type p_ID,
    ReceiveMessageFunc p_Msg
) 

Parameters:

  • p_ID A Message Type
  • p_Msg The Function to call when receiving this message

function RegisterMessage [2/2]

Register a message to listen for. Custom message types should start with ID's LARGER than Message.Type.CustomMessage.

inline void Manus::Networking::Peer::RegisterMessage (
    ushort p_ID,
    ReceiveMessageFunc p_Msg
) 

Parameters:

  • p_ID A Message Type
  • p_Msg The Function to call when receiving this message

function ReleaseControlOfObject

This function must be implemented to allow objects to be released by others.

void Manus::Networking::Peer::ReleaseControlOfObject (
    NetObject p_NetObj
) 

Parameters:

  • p_NetObj The prefab of the NetObject to release control of.

function SendMessage [1/2]

Call this function to send messages.

inline void Manus::Networking::Peer::SendMessage (
    Message.Type p_Type,
    LidNet.NetBuffer p_Msg
) 

Parameters:

  • p_Type The Message Type
  • p_Msg The Message

function SendMessage [2/2]

Call this function to send custom messages to the server.

void Manus::Networking::Peer::SendMessage (
    ushort p_Type,
    LidNet.NetBuffer p_Msg
) 

Parameters:

  • p_Type The Message Type
  • p_Msg The Message

function SetNetObjectManager

Sets the NetObjectManager for managing the NetObjects.

inline void Manus::Networking::Peer::SetNetObjectManager (
    NetObjectManager p_Manager
) 

Parameters:

  • p_Manager The NetObjectManager

function Shutdown

void Manus::Networking::Peer::Shutdown () 

function Start

void Manus::Networking::Peer::Start () 

function TakeControlOfObject

This function must be implemented to allow objects to be controlled by others.

void Manus::Networking::Peer::TakeControlOfObject (
    NetObject p_NetObj
) 

Parameters:

  • p_NetObj The prefab of the NetObject to take control of.

function UnregisterMessage [1/2]

Stop listening for a certain message. Custom message types should start with ID's LARGER than Message.Type.CustomMessage.

inline void Manus::Networking::Peer::UnregisterMessage (
    Message.Type p_ID
) 

Parameters:

  • p_ID A Message Type

function UnregisterMessage [2/2]

Stop listening for a certain message. Custom message types should start with ID's LARGER than Message.Type.CustomMessage.

inline void Manus::Networking::Peer::UnregisterMessage (
    ushort p_ID
) 

Parameters:

  • p_ID A Message Type

function Update

Update function, updates whatever is desired on this Peer.

void Manus::Networking::Peer::Update (
    float p_DT
) 

Parameters:

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

Protected Attributes Documentation

variable m_ID

long Manus.Networking.Peer.m_ID;

variable m_Manager

NetworkManager Manus.Networking.Peer.m_Manager;

variable m_Messages

Dictionary<ushort, ReceiveMessageFunc> Manus.Networking.Peer.m_Messages;

variable m_NetObjectManager

NetObjectManager Manus.Networking.Peer.m_NetObjectManager;

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