Skip to main content

MLAPI.NetworkManager

The main component of the library

Inheritance#

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

Implements#

INetworkUpdateSystem

Inherited Members#

MonoBehaviour.IsInvoking()

MonoBehaviour.CancelInvoke()

MonoBehaviour.Invoke(String, Single)

MonoBehaviour.InvokeRepeating(String, Single, Single)

MonoBehaviour.CancelInvoke(String)

MonoBehaviour.IsInvoking(String)

MonoBehaviour.StartCoroutine(String)

MonoBehaviour.StartCoroutine(String, Object)

MonoBehaviour.StartCoroutine(IEnumerator)

MonoBehaviour.StartCoroutine_Auto(IEnumerator)

MonoBehaviour.StopCoroutine(IEnumerator)

MonoBehaviour.StopCoroutine(Coroutine)

MonoBehaviour.StopCoroutine(String)

MonoBehaviour.StopAllCoroutines()

MonoBehaviour.print(Object)

MonoBehaviour.useGUILayout

MonoBehaviour.runInEditMode

Behaviour.enabled

Behaviour.isActiveAndEnabled

Component.GetComponent(Type)

Component.GetComponent<T>()

Component.GetComponent(String)

Component.GetComponentInChildren(Type, Boolean)

Component.GetComponentInChildren(Type)

Component.GetComponentInChildren<T>(Boolean)

Component.GetComponentInChildren<T>()

Component.GetComponentsInChildren(Type, Boolean)

Component.GetComponentsInChildren(Type)

Component.GetComponentsInChildren<T>(Boolean)

Component.GetComponentsInChildren<T>(Boolean, List<T>)"

Component.GetComponentsInChildren<T>()

Component.GetComponentsInChildren<T>(List<T>)"

Component.GetComponentInParent(Type)

Component.GetComponentInParent<T>()

Component.GetComponentsInParent(Type, Boolean)

Component.GetComponentsInParent(Type)

Component.GetComponentsInParent<T>(Boolean)

Component.GetComponentsInParent<T>(Boolean, List<T>)"

Component.GetComponentsInParent<T>()

Component.GetComponents(Type)

Component.GetComponents(Type, List<Component>)

Component.GetComponents<T>(List<T>)"

Component.GetComponents<T>()

Component.CompareTag(String)

Component.SendMessageUpwards(String, Object, SendMessageOptions)

Component.SendMessageUpwards(String, Object)

Component.SendMessageUpwards(String)

Component.SendMessageUpwards(String, SendMessageOptions)

Component.SendMessage(String, Object)

Component.SendMessage(String)

Component.SendMessage(String, Object, SendMessageOptions)

Component.SendMessage(String, SendMessageOptions)

Component.BroadcastMessage(String, Object, SendMessageOptions)

Component.BroadcastMessage(String, Object)

Component.BroadcastMessage(String)

Component.BroadcastMessage(String, SendMessageOptions)

Component.transform

Component.gameObject

Component.tag

Component.rigidbody

Component.rigidbody2D

Component.camera

Component.light

Component.animation

Component.constantForce

Component.renderer

Component.audio

Component.guiText

Component.networkView

Component.guiElement

Component.guiTexture

Component.collider

Component.collider2D

Component.hingeJoint

Component.particleEmitter

Component.particleSystem

Object.GetInstanceID()

Object.GetHashCode()

Object.Equals(Object)

Object.Instantiate(Object, Vector3, Quaternion)

Object.Instantiate(Object, Vector3, Quaternion, Transform)

Object.Instantiate(Object)

Object.Instantiate(Object, Transform)

Object.Instantiate(Object, Transform, Boolean)

Object.Instantiate<T>(T)"

Object.Instantiate<T>(T, Vector3, Quaternion)"

Object.Instantiate<T>(T, Vector3, Quaternion, Transform)"

Object.Instantiate<T>(T, Transform)"

Object.Instantiate<T>(T, Transform, Boolean)"

Object.Destroy(Object, Single)

Object.Destroy(Object)

Object.DestroyImmediate(Object, Boolean)

Object.DestroyImmediate(Object)

Object.FindObjectsOfType(Type)

Object.DontDestroyOnLoad(Object)

Object.DestroyObject(Object, Single)

Object.DestroyObject(Object)

Object.FindSceneObjectsOfType(Type)

Object.FindObjectsOfTypeIncludingAssets(Type)

Object.FindObjectsOfType<T>()

Object.FindObjectOfType<T>()

Object.FindObjectsOfTypeAll(Type)

Object.FindObjectOfType(Type)

Object.ToString()

Object.name

Object.hideFlags

Object.Equals(Object, Object)

Object.GetType()

Object.MemberwiseClone()

Object.ReferenceEquals(Object, Object)

Namespace: System.Dynamic.ExpandoObject#
Assembly: MLAPI.dll#
Syntax#
[AddComponentMenu("MLAPI/NetworkManager", -100)]
public class NetworkManager : MonoBehaviour, INetworkUpdateSystem

Fields#

ConnectedClients#

Gets a dictionary of connected clients and their clientId keys. This is only populated on the server.

Declaration#

public readonly Dictionary<ulong, NetworkClient> ConnectedClients

Field Value#

TypeDescription
System.Collections.Generic.Dictionary<System.UInt64, NetworkClient>

ConnectedClientsList#

Gets a list of connected clients. This is only populated on the server.

Declaration#

public readonly List<NetworkClient> ConnectedClientsList

Field Value#

TypeDescription
System.Collections.Generic.List<NetworkClient>

DontDestroy#

Gets or sets if the NetworkManager should be marked as DontDestroyOnLoad

Declaration#

[HideInInspector]
public bool DontDestroy

Field Value#

TypeDescription
System.Boolean

LogLevel#

The log level to use

Declaration#

[HideInInspector]
public LogLevel LogLevel

Field Value#

TypeDescription
LogLevel

NetworkConfig#

The current NetworkConfig

Declaration#

[HideInInspector]
public NetworkConfig NetworkConfig

Field Value#

TypeDescription
NetworkConfig

PendingClients#

Gets a dictionary of the clients that have been accepted by the transport but are still pending by the MLAPI. This is only populated on the server.

Declaration#

public readonly Dictionary<ulong, PendingClient> PendingClients

Field Value#

TypeDescription
System.Collections.Generic.Dictionary<System.UInt64, PendingClient>

RunInBackground#

Gets or sets if the application should be set to run in background

Declaration#

[HideInInspector]
public bool RunInBackground

Field Value#

TypeDescription
System.Boolean

Properties#

ConnectedHostname#

The current hostname we are connected to, used to validate certificate

Declaration#

public string ConnectedHostname { get; }

Property Value#

TypeDescription
System.String

IsClient#

Gets Whether or not a client is running

Declaration#

public bool IsClient { get; }

Property Value#

TypeDescription
System.Boolean

IsConnectedClient#

Gets if we are connected as a client

Declaration#

public bool IsConnectedClient { get; }

Property Value#

TypeDescription
System.Boolean

IsHost#

Gets if we are running as host

Declaration#

public bool IsHost { get; }

Property Value#

TypeDescription
System.Boolean

IsListening#

Gets Whether or not we are listening for connections

Declaration#

public bool IsListening { get; }

Property Value#

TypeDescription
System.Boolean

IsServer#

Gets Whether or not a server is running

Declaration#

public bool IsServer { get; }

Property Value#

TypeDescription
System.Boolean

LocalClientId#

The clientId the server calls the local client by, only valid for clients

Declaration#

public ulong LocalClientId { get; }

Property Value#

TypeDescription
System.UInt64

NetworkTime#

A synchronized time, represents the time in seconds since the server application started. Is replicated across all clients

Declaration#

public float NetworkTime { get; }

Property Value#

TypeDescription
System.Single

ServerClientId#

Gets the networkId of the server

Declaration#

public ulong ServerClientId { get; }

Property Value#

TypeDescription
System.UInt64

Singleton#

The singleton instance of the NetworkManager

Declaration#

public static NetworkManager Singleton { get; }

Property Value#

TypeDescription
NetworkManager

Methods#

DisconnectClient(UInt64)#

Disconnects the remote client.

Declaration#

public void DisconnectClient(ulong clientId)

Parameters#

TypeNameDescription
System.UInt64clientIdThe ClientId to disconnect

NetworkUpdate(NetworkUpdateStage)#

Declaration#

public void NetworkUpdate(NetworkUpdateStage updateStage)

Parameters#

TypeNameDescription
NetworkUpdateStageupdateStage

SetSingleton()#

Declaration#

public void SetSingleton()

Shutdown()#

Declaration#

public void Shutdown()

StartClient()#

Starts a client

Declaration#

public SocketTasks StartClient()

Returns#

TypeDescription
SocketTasks

StartHost(Nullable<Vector3>, Nullable<Quaternion>, Nullable<Boolean>, Nullable<UInt64>, Stream)#

Starts a Host

Declaration#

public SocketTasks StartHost(Vector3? position = default(Vector3? ), Quaternion? rotation = default(Quaternion? ), bool? createPlayerObject = default(bool? ), ulong? prefabHash = default(ulong? ), Stream payloadStream = null)

Parameters#

TypeNameDescription
System.Nullable<UnityEngine.Vector3>position
System.Nullable<UnityEngine.Quaternion>rotation
System.Nullable<System.Boolean>createPlayerObject
System.Nullable<System.UInt64>prefabHash
System.IO.StreampayloadStream

Returns#

TypeDescription
SocketTasks

StartServer()#

Starts a server

Declaration#

public SocketTasks StartServer()

Returns#

TypeDescription
SocketTasks

StopClient()#

Stops the running client

Declaration#

public void StopClient()

StopHost()#

Stops the running host

Declaration#

public void StopHost()

StopServer()#

Stops the running server

Declaration#

public void StopServer()

Events#

ConnectionApprovalCallback#

The callback to invoke during connection approval

Declaration#

public event Action<byte[], ulong, NetworkManager.ConnectionApprovedDelegate> ConnectionApprovalCallback

Event Type#

TypeDescription
System.Action<System.Byte[], System.UInt64, NetworkManager.ConnectionApprovedDelegate>

OnClientConnectedCallback#

The callback to invoke once a client connects. This callback is only ran on the server and on the local client that connects.

Declaration#

public event Action<ulong> OnClientConnectedCallback

Event Type#

TypeDescription
System.Action<System.UInt64>

OnClientDisconnectCallback#

The callback to invoke when a client disconnects. This callback is invoked on a client when the server shuts down or disconnects the client. It is only run on the server and the local client that disconnects.

The callback is not invoked on the client when the client-side invokes the NetworkManager.StopClient method or when the client side application shuts down abruptly (for example, no graceful disconnection where server or client notified it was exiting).

Declaration#

public event Action<ulong> OnClientDisconnectCallback

Event Type#

TypeDescription
System.Action<System.UInt64>

OnPerformanceDataEvent#

Declaration#

public static event NetworkManager.PerformanceDataEventHandler OnPerformanceDataEvent

Event Type#

TypeDescription
NetworkManager.PerformanceDataEventHandler

OnServerStarted#

The callback to invoke once the server is ready

Declaration#

public event Action OnServerStarted

Event Type#

TypeDescription
System.Action

Implements#

INetworkUpdateSystem

Extension Methods#

NetworkUpdateLoop.RegisterAllNetworkUpdates(INetworkUpdateSystem)

NetworkUpdateLoop.RegisterNetworkUpdate(INetworkUpdateSystem, NetworkUpdateStage)

NetworkUpdateLoop.UnregisterAllNetworkUpdates(INetworkUpdateSystem)

NetworkUpdateLoop.UnregisterNetworkUpdate(INetworkUpdateSystem, NetworkUpdateStage)