Search Results for

    Show / Hide Table of Contents

    Class NetworkServer

    NetworkServer handles remote connections and has a local connection for a local client.

    Inheritance
    Object
    NetworkServer
    Namespace: Mirror
    Assembly: doc.dll
    Syntax
    public static class NetworkServer : object

    Fields

    | Improve this Doc View Source

    aoi

    Declaration
    public static InterestManagement aoi
    Field Value
    Type Description
    InterestManagement
    | Improve this Doc View Source

    connections

    Dictionary of all server connections, with connectionId as key

    Declaration
    public static Dictionary<int, NetworkConnectionToClient> connections
    Field Value
    Type Description
    Dictionary<Int32, NetworkConnectionToClient>
    | Improve this Doc View Source

    dontListen

    Single player mode can use dontListen to not accept incoming connections

    Declaration
    public static bool dontListen
    Field Value
    Type Description
    Boolean
    | Improve this Doc View Source

    isLoadingScene

    Declaration
    public static bool isLoadingScene
    Field Value
    Type Description
    Boolean
    | Improve this Doc View Source

    maxConnections

    Declaration
    public static int maxConnections
    Field Value
    Type Description
    Int32
    | Improve this Doc View Source

    OnConnectedEvent

    Declaration
    public static Action<NetworkConnectionToClient> OnConnectedEvent
    Field Value
    Type Description
    Action<NetworkConnectionToClient>
    | Improve this Doc View Source

    OnDisconnectedEvent

    Declaration
    public static Action<NetworkConnectionToClient> OnDisconnectedEvent
    Field Value
    Type Description
    Action<NetworkConnectionToClient>
    | Improve this Doc View Source

    OnErrorEvent

    Declaration
    public static Action<NetworkConnectionToClient, TransportError, string> OnErrorEvent
    Field Value
    Type Description
    Action<NetworkConnectionToClient, TransportError, String>
    | Improve this Doc View Source

    spawned

    All spawned NetworkIdentities by netId.

    Declaration
    public static readonly Dictionary<uint, NetworkIdentity> spawned
    Field Value
    Type Description
    Dictionary<UInt32, NetworkIdentity>

    Properties

    | Improve this Doc View Source

    active

    active checks if the server has been started

    Declaration
    public static bool active { get; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    localClientActive

    True is a local client is currently active on the server

    Declaration
    public static bool localClientActive { get; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    localConnection

    Connection to host mode client (if any)

    Declaration
    public static NetworkConnectionToClient localConnection { get; }
    Property Value
    Type Description
    NetworkConnectionToClient

    Methods

    | Improve this Doc View Source

    ActivateHostScene()

    Declaration
    public static void ActivateHostScene()
    | Improve this Doc View Source

    AddConnection(NetworkConnectionToClient)

    Add a connection and setup callbacks. Returns true if not added yet.

    Declaration
    public static bool AddConnection(NetworkConnectionToClient conn)
    Parameters
    Type Name Description
    NetworkConnectionToClient conn
    Returns
    Type Description
    Boolean
    | Improve this Doc View Source

    AddPlayerForConnection(NetworkConnectionToClient, GameObject)

    Called by server after AddPlayer message to add the player for the connection.

    Declaration
    public static bool AddPlayerForConnection(NetworkConnectionToClient conn, GameObject player)
    Parameters
    Type Name Description
    NetworkConnectionToClient conn
    GameObject player
    Returns
    Type Description
    Boolean
    | Improve this Doc View Source

    AddPlayerForConnection(NetworkConnectionToClient, GameObject, Guid)

    Called by server after AddPlayer message to add the player for the connection.

    Declaration
    public static bool AddPlayerForConnection(NetworkConnectionToClient conn, GameObject player, Guid assetId)
    Parameters
    Type Name Description
    NetworkConnectionToClient conn
    GameObject player
    Guid assetId
    Returns
    Type Description
    Boolean
    | Improve this Doc View Source

    ClearHandlers()

    Clears all registered message handlers.

    Declaration
    public static void ClearHandlers()
    | Improve this Doc View Source

    Destroy(GameObject)

    Destroys this object and corresponding objects on all clients.

    Declaration
    public static void Destroy(GameObject obj)
    Parameters
    Type Name Description
    GameObject obj
    | Improve this Doc View Source

    DestroyPlayerForConnection(NetworkConnectionToClient)

    Destroys all of the connection's owned objects on the server.

    Declaration
    public static void DestroyPlayerForConnection(NetworkConnectionToClient conn)
    Parameters
    Type Name Description
    NetworkConnectionToClient conn
    | Improve this Doc View Source

    DisconnectAll()

    Disconnect all connections, including the local connection.

    Declaration
    public static void DisconnectAll()
    | Improve this Doc View Source

    HasExternalConnections()

    True if we have external connections (that are not host)

    Declaration
    public static bool HasExternalConnections()
    Returns
    Type Description
    Boolean
    | Improve this Doc View Source

    Listen(Int32)

    Starts server and listens to incoming connections with max connections limit.

    Declaration
    public static void Listen(int maxConns)
    Parameters
    Type Name Description
    Int32 maxConns
    | Improve this Doc View Source

    RebuildObservers(NetworkIdentity, Boolean)

    Declaration
    public static void RebuildObservers(NetworkIdentity identity, bool initialize)
    Parameters
    Type Name Description
    NetworkIdentity identity
    Boolean initialize
    | Improve this Doc View Source

    RegisterHandler<T>(Action<NetworkConnectionToClient, T, Int32>, Boolean)

    Register a handler for message type T. Most should require authentication.

    Declaration
    public static void RegisterHandler<T>(Action<NetworkConnectionToClient, T, int> handler, bool requireAuthentication = true)
        where T : struct, NetworkMessage
    Parameters
    Type Name Description
    Action<NetworkConnectionToClient, T, Int32> handler
    Boolean requireAuthentication
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    RegisterHandler<T>(Action<NetworkConnectionToClient, T>, Boolean)

    Register a handler for message type T. Most should require authentication.

    Declaration
    public static void RegisterHandler<T>(Action<NetworkConnectionToClient, T> handler, bool requireAuthentication = true)
        where T : struct, NetworkMessage
    Parameters
    Type Name Description
    Action<NetworkConnectionToClient, T> handler
    Boolean requireAuthentication
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    RemoveConnection(Int32)

    Removes a connection by connectionId. Returns true if removed.

    Declaration
    public static bool RemoveConnection(int connectionId)
    Parameters
    Type Name Description
    Int32 connectionId
    Returns
    Type Description
    Boolean
    | Improve this Doc View Source

    RemovePlayerForConnection(NetworkConnection, Boolean)

    Removes the player object from the connection

    Declaration
    public static void RemovePlayerForConnection(NetworkConnection conn, bool destroyServerObject)
    Parameters
    Type Name Description
    NetworkConnection conn
    Boolean destroyServerObject
    | Improve this Doc View Source

    ReplaceHandler<T>(Action<T>, Boolean)

    Replace a handler for message type T. Most should require authentication.

    Declaration
    public static void ReplaceHandler<T>(Action<T> handler, bool requireAuthentication = true)
        where T : struct, NetworkMessage
    Parameters
    Type Name Description
    Action<T> handler
    Boolean requireAuthentication
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    ReplaceHandler<T>(Action<NetworkConnectionToClient, T>, Boolean)

    Replace a handler for message type T. Most should require authentication.

    Declaration
    public static void ReplaceHandler<T>(Action<NetworkConnectionToClient, T> handler, bool requireAuthentication = true)
        where T : struct, NetworkMessage
    Parameters
    Type Name Description
    Action<NetworkConnectionToClient, T> handler
    Boolean requireAuthentication
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    ReplacePlayerForConnection(NetworkConnectionToClient, GameObject, Guid, Boolean)

    Replaces connection's player object. The old object is not destroyed.

    Declaration
    public static bool ReplacePlayerForConnection(NetworkConnectionToClient conn, GameObject player, Guid assetId, bool keepAuthority = false)
    Parameters
    Type Name Description
    NetworkConnectionToClient conn
    GameObject player
    Guid assetId
    Boolean keepAuthority
    Returns
    Type Description
    Boolean
    | Improve this Doc View Source

    ReplacePlayerForConnection(NetworkConnectionToClient, GameObject, Boolean)

    Replaces connection's player object. The old object is not destroyed.

    Declaration
    public static bool ReplacePlayerForConnection(NetworkConnectionToClient conn, GameObject player, bool keepAuthority = false)
    Parameters
    Type Name Description
    NetworkConnectionToClient conn
    GameObject player
    Boolean keepAuthority
    Returns
    Type Description
    Boolean
    | Improve this Doc View Source

    SendToAll<T>(T, Int32, Boolean)

    Send a message to all clients, even those that haven't joined the world yet (non ready)

    Declaration
    public static void SendToAll<T>(T message, int channelId = null, bool sendToReadyOnly = false)
        where T : struct, NetworkMessage
    Parameters
    Type Name Description
    T message
    Int32 channelId
    Boolean sendToReadyOnly
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    SendToReady<T>(T, Int32)

    Send a message to all clients which have joined the world (are ready).

    Declaration
    public static void SendToReady<T>(T message, int channelId = null)
        where T : struct, NetworkMessage
    Parameters
    Type Name Description
    T message
    Int32 channelId
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    SendToReadyObservers<T>(NetworkIdentity, T, Boolean, Int32)

    Send a message to only clients which are ready with option to include the owner of the object identity

    Declaration
    public static void SendToReadyObservers<T>(NetworkIdentity identity, T message, bool includeOwner = true, int channelId = null)
        where T : struct, NetworkMessage
    Parameters
    Type Name Description
    NetworkIdentity identity
    T message
    Boolean includeOwner
    Int32 channelId
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    SendToReadyObservers<T>(NetworkIdentity, T, Int32)

    Send a message to only clients which are ready including the owner of the NetworkIdentity

    Declaration
    public static void SendToReadyObservers<T>(NetworkIdentity identity, T message, int channelId)
        where T : struct, NetworkMessage
    Parameters
    Type Name Description
    NetworkIdentity identity
    T message
    Int32 channelId
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    SetAllClientsNotReady()

    Marks all connected clients as no longer ready.

    Declaration
    public static void SetAllClientsNotReady()
    | Improve this Doc View Source

    SetClientNotReady(NetworkConnectionToClient)

    Marks the client of the connection to be not-ready.

    Declaration
    public static void SetClientNotReady(NetworkConnectionToClient conn)
    Parameters
    Type Name Description
    NetworkConnectionToClient conn
    | Improve this Doc View Source

    SetClientReady(NetworkConnectionToClient)

    Flags client connection as ready (=joined world).

    Declaration
    public static void SetClientReady(NetworkConnectionToClient conn)
    Parameters
    Type Name Description
    NetworkConnectionToClient conn
    | Improve this Doc View Source

    Shutdown()

    Shuts down the server and disconnects all clients

    Declaration
    public static void Shutdown()
    | Improve this Doc View Source

    Spawn(GameObject, GameObject)

    Spawns an object and also assigns Client Authority to the specified client.

    Declaration
    public static void Spawn(GameObject obj, GameObject ownerPlayer)
    Parameters
    Type Name Description
    GameObject obj
    GameObject ownerPlayer
    | Improve this Doc View Source

    Spawn(GameObject, Guid, NetworkConnection)

    Spawns an object and also assigns Client Authority to the specified client.

    Declaration
    public static void Spawn(GameObject obj, Guid assetId, NetworkConnection ownerConnection = null)
    Parameters
    Type Name Description
    GameObject obj
    Guid assetId
    NetworkConnection ownerConnection
    | Improve this Doc View Source

    Spawn(GameObject, NetworkConnection)

    Spawn the given game object on all clients which are ready.

    Declaration
    public static void Spawn(GameObject obj, NetworkConnection ownerConnection = null)
    Parameters
    Type Name Description
    GameObject obj
    NetworkConnection ownerConnection
    | Improve this Doc View Source

    SpawnObjects()

    Spawns NetworkIdentities in the scene on the server.

    Declaration
    public static bool SpawnObjects()
    Returns
    Type Description
    Boolean
    | Improve this Doc View Source

    UnregisterHandler<T>()

    Unregister a handler for a message type T.

    Declaration
    public static void UnregisterHandler<T>()
        where T : struct, NetworkMessage
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    UnSpawn(GameObject)

    This takes an object that has been spawned and un-spawns it.

    Declaration
    public static void UnSpawn(GameObject obj)
    Parameters
    Type Name Description
    GameObject obj
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX