Skip to content

Mirror::Cloud::Example::NetworkManagerListServer

Network Manager with events that are used by the list server

Inherits from NetworkManager, MonoBehaviour

Inherited by NetworkManagerListServerPong

Public Events

Name
Action onServerStarted()
Called when Server Starts
Action onServerStopped()
Called when Server Stops
OnPlayerListChanged onPlayerListChanged()
Called when players leaves or joins the room

Public Functions

Name
delegate void OnPlayerListChanged(int playerCount)
virtual override void OnServerConnect(NetworkConnection conn)
Called on the server when a new client connects.
virtual override void OnServerDisconnect(NetworkConnection conn)
Called on the server when a client disconnects.
virtual override void OnStartServer()
This is invoked when a server is started - including when a host is started.
virtual override void OnStopServer()
This is called when a server is stopped - including when a host is stopped.

Additional inherited members

Public Functions inherited from NetworkManager

Name
virtual void OnValidate()
virtual so that inheriting classes' OnValidate() can call base.OnValidate() too
virtual void Awake()
virtual so that inheriting classes' Awake() can call base.Awake() too
virtual void Start()
virtual so that inheriting classes' Start() can call base.Start() too
virtual void LateUpdate()
virtual so that inheriting classes' LateUpdate() can call base.LateUpdate() too
void StartServer()
This starts a new server.
void StartClient()
This starts a network client. It uses the networkAddress property as the address to connect to.
void StartClient(Uri uri)
This starts a network client. It uses the Uri parameter as the address to connect to.
void StartHost()
This starts a network "host" - a server and client in the same application.
void StopHost()
This stops both the client and the server that the manager is using.
void StopServer()
Stops the server that the manager is using.
void StopClient()
Stops the client that the manager is using.
virtual void OnApplicationQuit()
called when quitting the application by closing the window / pressing stop in the editor
virtual void ConfigureServerFrameRate()
Set the frame rate for a headless server.
virtual void OnDestroy()
virtual so that inheriting classes' OnDestroy() can call base.OnDestroy() too
virtual void ServerChangeScene(string newSceneName)
This causes the server to switch scenes and sets the networkSceneName.
Transform GetStartPosition()
This finds a spawn position based on NetworkStartPosition objects in the scene.
virtual void OnServerReady(NetworkConnection conn)
Called on the server when a client is ready.
virtual void OnServerAddPlayer(NetworkConnection conn)
Called on the server when a client adds a new player with ClientScene.AddPlayer.
virtual void OnServerError(NetworkConnection conn, int errorCode)
Called on the server when a network error occurs for a client connection.
virtual void OnServerChangeScene(string newSceneName)
Called from ServerChangeScene immediately before SceneManager.LoadSceneAsync is executed
virtual void OnServerSceneChanged(string sceneName)
Called on the server when a scene is completed loaded, when the scene load was initiated by the server with ServerChangeScene().
virtual void OnClientConnect(NetworkConnection conn)
Called on the client when connected to a server.
virtual void OnClientDisconnect(NetworkConnection conn)
Called on clients when disconnected from a server.
virtual void OnClientError(NetworkConnection conn, int errorCode)
Called on clients when a network error occurs.
virtual void OnClientNotReady(NetworkConnection conn)
Called on clients when a servers tells the client it is no longer ready.
virtual void OnClientChangeScene(string newSceneName, SceneOperation sceneOperation, bool customHandling)
Called from ClientChangeScene immediately before SceneManager.LoadSceneAsync is executed
virtual void OnClientSceneChanged(NetworkConnection conn)
Called on clients when a scene has completed loaded, when the scene load was initiated by the server.
virtual void OnStartHost()
This is invoked when a host is started.
virtual void OnStartClient()
This is invoked when the client is started.
virtual void OnStopClient()
This is called when a client is stopped.
virtual void OnStopHost()
This is called when a host is stopped.
bool IsSceneActive(string scene)
void Shutdown()
This is the only way to clear the singleton, so another instance can be created.
void RegisterStartPosition(Transform start)
Registers the transform of a game object as a player spawn location.
void UnRegisterStartPosition(Transform start)
Unregisters the transform of a game object as a player spawn location.

Public Properties inherited from NetworkManager

Name
NetworkManager singleton
NetworkManager singleton
NetworkManagerMode mode
string networkSceneName
The name of the current network scene.

Public Attributes inherited from NetworkManager

Name
bool dontDestroyOnLoad
A flag to control whether the NetworkManager object is destroyed when the scene changes.
bool runInBackground
Controls whether the program runs when it is in the background.
bool autoStartServerBuild
Automatically invoke StartServer()
bool showDebugMessages
Enables verbose debug messages in the console
int serverTickRate
Server Update frequency, per second. Use around 60Hz for fast paced games like Counter-Strike to minimize latency. Use around 30Hz for games like WoW to minimize computations. Use around 1-10Hz for slow paced games like EVE.
string offlineScene
The scene to switch to when offline.
string onlineScene
The scene to switch to when online.
string networkAddress
The network address currently in use.
int maxConnections
The maximum number of concurrent network connections to support.
bool disconnectInactiveConnections
Should the server disconnect remote connections that have gone silent for more than Server Idle Timeout?
float disconnectInactiveTimeout
Timeout in seconds since last message from a client after which server will auto-disconnect.
NetworkAuthenticator authenticator
GameObject playerPrefab
The default prefab to be used to create player objects on the server.
bool autoCreatePlayer
A flag to control whether or not player objects are automatically created on connect, and on scene change.
PlayerSpawnMethod playerSpawnMethod
The current method of spawning players used by the NetworkManager.
List< GameObject > spawnPrefabs
List of prefabs that will be registered with the spawning system.
int numPlayers
Number of active player objects across all connections on the server.
bool isNetworkActive
True if the server or client is started and running
bool clientLoadedScene
This is true if the client loaded a new scene when connecting to the server.
UnityEngine.AsyncOperation loadingSceneAsync
int startPositionIndex
List< Transform > startPositions
List of transforms populted by NetworkStartPosition components found in the scene.

Protected Attributes inherited from NetworkManager

Name
Transport transport

Public Events Documentation

event onServerStarted

Action onServerStarted()

Called when Server Starts

event onServerStopped

Action onServerStopped()

Called when Server Stops

event onPlayerListChanged

OnPlayerListChanged onPlayerListChanged()

Called when players leaves or joins the room

Public Functions Documentation

function OnPlayerListChanged

delegate void OnPlayerListChanged(
    int playerCount
)

function OnServerConnect

inline virtual override void OnServerConnect(
    NetworkConnection conn
)

Called on the server when a new client connects.

Parameters:

  • conn Connection from client.

Reimplements: Mirror::NetworkManager::OnServerConnect

Unity calls this on the Server when a Client connects to the Server. Use an override to tell the NetworkManager what to do when a client connects to the server.

function OnServerDisconnect

inline virtual override void OnServerDisconnect(
    NetworkConnection conn
)

Called on the server when a client disconnects.

Parameters:

  • conn Connection from client.

Reimplements: Mirror::NetworkManager::OnServerDisconnect

This is called on the Server when a Client disconnects from the Server. Use an override to decide what should happen when a disconnection is detected.

function OnStartServer

inline virtual override void OnStartServer()

This is invoked when a server is started - including when a host is started.

Reimplements: Mirror::NetworkManager::OnStartServer

StartServer has multiple signatures, but they all cause this hook to be called.

function OnStopServer

inline virtual override void OnStopServer()

This is called when a server is stopped - including when a host is stopped.

Reimplements: Mirror::NetworkManager::OnStopServer


Updated on 26 January 2021 at 15:30:27 UTC