Skip to content

Class Manus::Networking::NetworkManager

ClassList > Manus > Networking > NetworkManager

The basic NetworkManager Implementation. There should only be one NetworkManager in a project. This class should be inherited from in order to use your own Client and Server implementation. This class handles generic functions such as Hosting, Joining, Object spawning and removing.

Inherits the following classes: MonoBehaviour

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

Public Types

Type Name
enum Status
The different statuses the NetworkManager can have.

Public Attributes

Type Name
string appIdentifier = = "MyApp"
This variable defines which applications it can find and be found by. It should be unique for every project made with the NetworkManager.
NetObject playerPrefab
The player prefab that is spawned when a player joins.
Vector3 playerSpawnPostion = = Vector3.zero
The world position the Players are spawned in as.
Vector3 playerSpawnRotation = = Vector3.zero
The world rotation the Players are spawned in as.
int port = = 6969
The port on which the NetworkManager creates the Server at.

Public Properties

Type Name
property Status status
The current status of the NetworkManager.

Public Static Properties

Type Name
property NetworkManager instance
Get the NetworkManager.

Public Functions

Type Name
void Client ()
Creates a client for this game instance.
void Connect (string p_Host, int p_Port)
If there is a Client available, connect to a Server at a given address and port.
void Connect (System.Net.IPEndPoint p_RemoteEndPoint)
If there is a Client available, connect to a given Remote End Point. This function should be used in combination with the results of a LAN Discovery.
virtual Client CreateClient (NetworkManager p_Man, string p_AppID)
Function called when creating a client, this function needs to be overridden to use a custom Client implementation!
virtual Server CreateServer (NetworkManager p_Man, string p_AppID, int p_Port)
Function called when creating a server, this function needs to be overridden to use a custom Server implementation!
void DestroyObject (NetObject p_Obj)
Call this function when an object needs to be destroyed.
void DiscoverLan ()
If the Client is running, find servers on the LAN.
Client GetClient ()
Returns the Client, if any is available. Returns NULL if no Client is available.
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.
Peer GetPeer ()
Returns the Peer, if any is available. Returns NULL if no Peer available.
Server GetServer ()
Returns the Server, if any is available. Returns NULL if no Server is available.
void Host ()
Creates a server and spawns the Player Prefab for this game instance.
void ReleaseControlOfObject (NetObject p_Obj)
Call this function when you want to release control of an object.
void SendNetMessage (Message.Type p_Type, LidNet.NetBuffer p_Msg)
Call this function when you want to send a message.
void SendNetMessage (ushort p_Type, LidNet.NetBuffer p_Msg)
Call this function when you want to send a message.
void Server ()
Creates a server and does NOT spawn a Player Prefab for this game instance.
NetObject SpawnObject (NetObject p_Obj, Vector3 p_Position, Quaternion p_Rotation)
Call this function when an object needs to be created. Make sure this NetObject is in the resources folder! The return will be NULL if used as a client!
void TakeControlOfObject (NetObject p_Obj)
Call this function when you want to take control of an object.

Public Static Functions

Type Name
NetObject[] GetPrefabs ()
Gets all registered NetObject Prefabs.

Protected Attributes

Type Name
Peer m_Peer = = null
Status m_Status

Public Types Documentation

enum Status

enum Manus::Networking::NetworkManager::Status {
    Inactive,
    Peer,
    Server,
    Client
};

Public Attributes Documentation

variable appIdentifier

string Manus.Networking.NetworkManager.appIdentifier;

variable playerPrefab

NetObject Manus.Networking.NetworkManager.playerPrefab;

variable playerSpawnPostion

Vector3 Manus.Networking.NetworkManager.playerSpawnPostion;

variable playerSpawnRotation

Vector3 Manus.Networking.NetworkManager.playerSpawnRotation;

variable port

int Manus.Networking.NetworkManager.port;

Public Properties Documentation

property status

Status Manus.Networking.NetworkManager.status;

Public Static Properties Documentation

property instance

NetworkManager Manus.Networking.NetworkManager.instance;

Public Functions Documentation

function Client

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

function Connect [1/2]

If there is a Client available, connect to a Server at a given address and port.

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

Parameters:

  • p_Host IP Address of the Server
  • p_Port Port of the Server

function Connect [2/2]

If there is a Client available, connect to a given Remote End Point. This function should be used in combination with the results of a LAN Discovery.

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

Parameters:

  • p_RemoteEndPoint The Server's Remote End Point

function CreateClient

Function called when creating a client, this function needs to be overridden to use a custom Client implementation!

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

Parameters:

  • p_Man The Network Manager
  • p_AppID The AppID

Returns:

Returns the created Server

function CreateServer

Function called when creating a server, this function needs to be overridden to use a custom Server implementation!

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

Parameters:

  • p_Man The Network Manager
  • p_AppID The AppID
  • p_Port The Port

Returns:

Returns the created Server

function DestroyObject

Call this function when an object needs to be destroyed.

inline void Manus::Networking::NetworkManager::DestroyObject (
    NetObject p_Obj
) 

Parameters:

  • p_Obj The NetObject to destroy

function DiscoverLan

inline void Manus::Networking::NetworkManager::DiscoverLan () 

function GetClient

Returns the Client, if any is available. Returns NULL if no Client is available.

inline Client Manus::Networking::NetworkManager::GetClient () 

Returns:

A Client or NULL

function GetNetObject

Get the NetObject with a given NetID.

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

Parameters:

  • p_NetID NetID to get

Returns:

function GetNetObjects

Returns all the NetObjects.

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

Returns:

A List of NetObjects

function GetNetObjectsControlledByPlayer

Returns all the NetObjects that a given player controls.

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

Parameters:

  • p_PlayerNetID The controller's ID

Returns:

A List of NetObjects

function GetPeer

Returns the Peer, if any is available. Returns NULL if no Peer available.

inline Peer Manus::Networking::NetworkManager::GetPeer () 

Returns:

A Peer or NULL

function GetServer

Returns the Server, if any is available. Returns NULL if no Server is available.

inline Server Manus::Networking::NetworkManager::GetServer () 

Returns:

A Server or NULL

function Host

inline void Manus::Networking::NetworkManager::Host () 

function ReleaseControlOfObject

Call this function when you want to release control of an object.

inline void Manus::Networking::NetworkManager::ReleaseControlOfObject (
    NetObject p_Obj
) 

Parameters:

  • p_Obj The NetObject to release control of

function SendNetMessage [1/2]

Call this function when you want to send a message.

inline void Manus::Networking::NetworkManager::SendNetMessage (
    Message.Type p_Type,
    LidNet.NetBuffer p_Msg
) 

Parameters:

  • p_Type The Message Type
  • p_Msg The Message

function SendNetMessage [2/2]

Call this function when you want to send a message.

inline void Manus::Networking::NetworkManager::SendNetMessage (
    ushort p_Type,
    LidNet.NetBuffer p_Msg
) 

Parameters:

  • p_Type The Message Type
  • p_Msg The Message

function Server

inline void Manus::Networking::NetworkManager::Server () 

function SpawnObject

Call this function when an object needs to be created. Make sure this NetObject is in the resources folder! The return will be NULL if used as a client!

inline NetObject Manus::Networking::NetworkManager::SpawnObject (
    NetObject p_Obj,
    Vector3 p_Position,
    Quaternion p_Rotation
) 

Parameters:

  • p_Obj The NetObject to spawn.
  • 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 TakeControlOfObject

Call this function when you want to take control of an object.

inline void Manus::Networking::NetworkManager::TakeControlOfObject (
    NetObject p_Obj
) 

Parameters:

  • p_Obj The NetObject to take control of

Public Static Functions Documentation

function GetPrefabs

Gets all registered NetObject Prefabs.

static inline NetObject [] Manus::Networking::NetworkManager::GetPrefabs () 

Returns:

Returns all registered NetObject Prefabs.

Protected Attributes Documentation

variable m_Peer

Peer Manus.Networking.NetworkManager.m_Peer;

variable m_Status

Status Manus.Networking.NetworkManager.m_Status;

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