Class ClientManager
A container for local client data and actions.
Inheritance
Inherited Members
Namespace: FishNet.Managing.Client
Assembly: FishNet.Runtime.dll
Syntax
[DisallowMultipleComponent]
[AddComponentMenu("FishNet/Manager/ClientManager")]
public sealed class ClientManager : MonoBehaviour
Fields
Clients
All currently connected clients. This field only contains data while ServerManager.ShareIds is enabled.
Declaration
public Dictionary<int, NetworkConnection> Clients
Field Value
| Type | Description |
|---|---|
| System.Collections.Generic.Dictionary<System.Int32, NetworkConnection> |
Connection
NetworkConnection the local client is using to send data to the server.
Declaration
public NetworkConnection Connection
Field Value
| Type | Description |
|---|---|
| NetworkConnection |
Properties
IsServerDevelopment
This is set true if the server has notified the client it is using a development build. Value is set before authentication.
Declaration
public bool IsServerDevelopment { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
NetworkManager
NetworkManager for client.
Declaration
[HideInInspector]
public NetworkManager NetworkManager { get; }
Property Value
| Type | Description |
|---|---|
| NetworkManager |
Objects
Handling and information for objects known to the local client.
Declaration
public ClientObjects Objects { get; }
Property Value
| Type | Description |
|---|---|
| ClientObjects |
Started
True if the client connection is connected to the server.
Declaration
public bool Started { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Methods
Broadcast<T>(T, Channel)
Sends a Broadcast to the server.
Declaration
public void Broadcast<T>(T message, Channel channel = Channel.Reliable)
where T : struct, IBroadcast
Parameters
| Type | Name | Description |
|---|---|---|
| T | message | Broadcast data being sent; for example: an instance of your broadcast type. |
| Channel | channel | Channel to send on. |
Type Parameters
| Name | Description |
|---|---|
| T | Type of broadcast to send. |
GetTransportIndex()
Gets the transport index being used for the local client. If only one transport is used this will return 0. If Multipass is being used this will return the client's transport in multipass.
Declaration
public int GetTransportIndex()
Returns
| Type | Description |
|---|---|
| System.Int32 |
RegisterBroadcast<T>(Action<T, Channel>)
Registers a method to call when a Broadcast arrives.
Declaration
public void RegisterBroadcast<T>(Action<T, Channel> handler)
where T : struct, IBroadcast
Parameters
| Type | Name | Description |
|---|---|---|
| System.Action<T, Channel> | handler | Method to call. |
Type Parameters
| Name | Description |
|---|---|
| T | Type of broadcast being registered. |
SetFrameRate(UInt16)
Declaration
public void SetFrameRate(ushort value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt16 | value |
SetRemoteServerTimeout(RemoteTimeoutType, UInt16)
Sets timeout settings. Can be used at runtime.
Declaration
public void SetRemoteServerTimeout(RemoteTimeoutType timeoutType, ushort duration)
Parameters
| Type | Name | Description |
|---|---|---|
| RemoteTimeoutType | timeoutType | |
| System.UInt16 | duration |
StartConnection()
Starts the local client connection.
Declaration
public bool StartConnection()
Returns
| Type | Description |
|---|---|
| System.Boolean |
StartConnection(String)
Sets the transport address and starts the local client connection.
Declaration
public bool StartConnection(string address)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | address |
Returns
| Type | Description |
|---|---|
| System.Boolean |
StartConnection(String, UInt16)
Sets the transport address and port, and starts the local client connection.
Declaration
public bool StartConnection(string address, ushort port)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | address | |
| System.UInt16 | port |
Returns
| Type | Description |
|---|---|
| System.Boolean |
StopConnection()
Stops the local client connection.
Declaration
public bool StopConnection()
Returns
| Type | Description |
|---|---|
| System.Boolean |
UnregisterBroadcast<T>(Action<T, Channel>)
Unregisters a method call from a Broadcast type.
Declaration
public void UnregisterBroadcast<T>(Action<T, Channel> handler)
where T : struct, IBroadcast
Parameters
| Type | Name | Description |
|---|---|---|
| System.Action<T, Channel> | handler | Method to unregister. |
Type Parameters
| Name | Description |
|---|---|
| T | Type of broadcast being unregistered. |
Events
OnAuthenticated
Called after local client has authenticated.
Declaration
public event Action OnAuthenticated
Event Type
| Type | Description |
|---|---|
| System.Action |
OnClientConnectionState
Called after the local client connection state changes.
Declaration
public event Action<ClientConnectionStateArgs> OnClientConnectionState
Event Type
| Type | Description |
|---|---|
| System.Action<ClientConnectionStateArgs> |
OnClientTimeOut
Called when the local client connection to the server has timed out. This is called immediately before disconnecting.
Declaration
public event Action OnClientTimeOut
Event Type
| Type | Description |
|---|---|
| System.Action |
OnConnectedClients
Called when the server sends all currently connected clients. This is only available when using ServerManager.ShareIds.
Declaration
public event Action<ConnectedClientsArgs> OnConnectedClients
Event Type
| Type | Description |
|---|---|
| System.Action<ConnectedClientsArgs> |
OnRemoteConnectionState
Called when a client other than self connects. This is only available when using ServerManager.ShareIds.
Declaration
public event Action<RemoteConnectionStateArgs> OnRemoteConnectionState
Event Type
| Type | Description |
|---|---|
| System.Action<RemoteConnectionStateArgs> |