Search Results for

    Show / Hide Table of Contents

    Class NetworkManager

    The network manager drives the NetworkClient and NetworkServer systems.

    TODO: Make extensible with Justin's NetworkLogic idea.

    Inheritance
    Object
    NetworkManager
    Namespace: FNNLib
    Assembly: FNNLib.dll
    Syntax
    public class NetworkManager : MonoBehaviour

    Fields

    | Improve this Doc View Source

    allClientIDs

    List of all client IDs

    Declaration
    public List<ulong> allClientIDs
    Field Value
    Type Description
    List<UInt64>
    | Improve this Doc View Source

    clientOnConnect

    On client connects to server.

    Declaration
    public UnityEvent clientOnConnect
    Field Value
    Type Description
    UnityEvent
    | Improve this Doc View Source

    clientOnDisconnect

    On client disconnects from server.

    Declaration
    public UnityEvent<string> clientOnDisconnect
    Field Value
    Type Description
    UnityEvent<String>
    | Improve this Doc View Source

    connectedClients

    Dictionary containing all connected clients. Key is client ID.

    Declaration
    public readonly Dictionary<ulong, NetworkedClient> connectedClients
    Field Value
    Type Description
    Dictionary<UInt64, NetworkedClient>
    | Improve this Doc View Source

    connectedClientsList

    List of all connected clients.

    Declaration
    public readonly List<NetworkedClient> connectedClientsList
    Field Value
    Type Description
    List<NetworkedClient>
    | Improve this Doc View Source

    connectionApprovalCallback

    Connection approval callback. Used for adding extra logic to connection acceptance.

    Declaration
    public ApproveConnectionDelegate connectionApprovalCallback
    Field Value
    Type Description
    ApproveConnectionDelegate
    | Improve this Doc View Source

    dontDestroyOnLoad

    Whether or not to move the manager to the DontDestroyOnLoad Scene.

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

    instance

    The game's NetworkManager.

    Declaration
    public static NetworkManager instance
    Field Value
    Type Description
    NetworkManager
    | Improve this Doc View Source

    networkConfig

    The network config.

    Declaration
    public NetworkConfig networkConfig
    Field Value
    Type Description
    NetworkConfig
    | Improve this Doc View Source

    runInBackground

    Whether or not the application should run in the background while networking is running. Will be reset once the client/server is finished.

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

    ServerLocalID

    The local ID of the server

    Declaration
    public const ulong ServerLocalID = 0UL
    Field Value
    Type Description
    UInt64
    | Improve this Doc View Source

    serverOnClientConnect

    On client connect to server.

    Declaration
    public UnityEvent<ulong> serverOnClientConnect
    Field Value
    Type Description
    UnityEvent<UInt64>
    | Improve this Doc View Source

    serverOnClientDisconnect

    On client disconnect from server.

    Declaration
    public UnityEvent<ulong> serverOnClientDisconnect
    Field Value
    Type Description
    UnityEvent<UInt64>

    Properties

    | Improve this Doc View Source

    isClient

    Whether or not the game should run clientside code.

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

    isHost

    Whether or not the client is a virtual client.

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

    isServer

    Whether or not the game should run serverside code.

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

    isSinglePlayer

    Whether or not the game is running in single player mode.

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

    localClientID

    The local client ID.

    Declaration
    public ulong localClientID { get; }
    Property Value
    Type Description
    UInt64

    Methods

    | Improve this Doc View Source

    ConfigureServerFramerate()

    Configure the server's framerate to prevent high CPU usage.

    Declaration
    protected virtual void ConfigureServerFramerate()
    | Improve this Doc View Source

    ServerDisconnect(UInt64, String)

    Disconnect a client with a reason

    Declaration
    public void ServerDisconnect(ulong clientID, string disconnectReason)
    Parameters
    Type Name Description
    UInt64 clientID
    String disconnectReason
    | Improve this Doc View Source

    ServerForceDisconnect(UInt64)

    Disconnect a client without a reason.

    Declaration
    public void ServerForceDisconnect(ulong clientID)
    Parameters
    Type Name Description
    UInt64 clientID

    Client to disconnect.

    | Improve this Doc View Source

    SinglePlayerStartHost()

    Converts single player game to host game.

    Declaration
    public void SinglePlayerStartHost()
    | Improve this Doc View Source

    StartClient(String, Byte[])

    Start the manager in client mode.

    Declaration
    public void StartClient(string hostname, byte[] connectionRequestData = null)
    Parameters
    Type Name Description
    String hostname

    The hostname of the server to connect to.

    Byte[] connectionRequestData

    Connection request data used for the approval stage.

    Exceptions
    Type Condition
    NotSupportedException
    | Improve this Doc View Source

    StartHost()

    Start the manager in host mode. This runs a virtual client on top of the server.

    Declaration
    public void StartHost()
    Exceptions
    Type Condition
    InvalidOperationException
    NotSupportedException
    | Improve this Doc View Source

    StartServer()

    Starts the manager in server mode.

    Declaration
    public void StartServer()
    | Improve this Doc View Source

    StartSinglePlayer()

    Runs the game as if there was a server, without running one.

    Declaration
    public void StartSinglePlayer()
    | Improve this Doc View Source

    StopClient()

    Stop the client

    Declaration
    public void StopClient()
    Exceptions
    Type Condition
    NotSupportedException

    Thrown if running in a different mode, or a client isn't running.

    | Improve this Doc View Source

    StopHost()

    Stop host mode, closing the server and disconnecting remote users.

    Declaration
    public void StopHost()
    Exceptions
    Type Condition
    NotSupportedException
    | Improve this Doc View Source

    StopServer()

    Stop a running server.

    Declaration
    public void StopServer()
    Exceptions
    Type Condition
    NotSupportedException
    | Improve this Doc View Source

    StopSinglePlayer()

    Stops running the game in single player mode.

    Declaration
    public void StopSinglePlayer()
    • Improve this Doc
    • View Source
    In This Article
    Back to top (C) 2020 Reece Mackie. Released under the MIT License.