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
Public Attributes Documentation
variable appIdentifier
variable playerPrefab
variable playerSpawnPostion
variable playerSpawnRotation
variable port
Public Properties Documentation
property status
Public Static Properties Documentation
property instance
Public Functions Documentation
function Client
function Connect [1/2]
If there is a Client available, connect to a Server at a given address and port.
Parameters:
p_Host
IP Address of the Serverp_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.
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 Managerp_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 Managerp_AppID
The AppIDp_Port
The Port
Returns:
Returns the created Server
function DestroyObject
Call this function when an object needs to be destroyed.
Parameters:
p_Obj
The NetObject to destroy
function DiscoverLan
function GetClient
Returns the Client, if any is available. Returns NULL if no Client is available.
Returns:
A Client or NULL
function GetNetObject
Get the NetObject with a given NetID.
Parameters:
p_NetID
NetID to get
Returns:
function GetNetObjects
Returns all the NetObjects.
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.
Returns:
A Peer or NULL
function GetServer
Returns the Server, if any is available. Returns NULL if no Server is available.
Returns:
A Server or NULL
function Host
function ReleaseControlOfObject
Call this function when you want to release control of an object.
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 Typep_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 Typep_Msg
The Message
function 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.
Parameters:
p_Obj
The NetObject to take control of
Public Static Functions Documentation
function GetPrefabs
Gets all registered NetObject Prefabs.
Returns:
Returns all registered NetObject Prefabs.
Protected Attributes Documentation
variable m_Peer
variable m_Status
The documentation for this class was generated from the following file api/unity-plugin/Scripts/Networking/NetworkManager.cs