Class NetworkPlayer
A High level network connection. This is used for connections from client-to-server and for connection from server-to-client.
Inheritance
Inherited Members
Show
Syntax
public sealed class NetworkPlayer : INetworkPlayer, IMessageSender, IVisibilityTracker, IObjectOwner, ISceneLoader
Constructors
NetworkPlayer(IConnection, Boolean)
Creates a new NetworkConnection with the specified address and connectionId
Declaration
public NetworkPlayer(IConnection connection, bool isHost)
Parameters
Type | Name | Description |
---|---|---|
Mirage.SocketLayer.IConnection | connection | |
System.Boolean | isHost |
Properties
IsHost
Declaration
public bool IsHost { get; }
Authentication
Authentication information for this NetworkPlayer
Declaration
public PlayerAuthentication Authentication { get; }
IsAuthenticated
Helper methods to check if Authentication is set
Declaration
public bool IsAuthenticated { get; }
SceneIsReady
Flag that tells us if the scene has fully loaded in for player. This property is read-only. It is set by the system on the client when the scene has fully loaded, and set by the system on the server when a ready message is received from a client. A client that is ready is sent spawned objects by the server and updates to the state of spawned objects. A client that is not ready is not sent spawned objects. Starts as true, when a client connects it is assumed that it is already in a ready scene. It will be set to not ready if NetworkSceneManager loads a scene
Declaration
public bool SceneIsReady { get; set; }
HasCharacter
Checks if this player has a
Declaration
public bool HasCharacter { get; }
Connection
Declaration
public IConnection Connection { get; }
Address
The IP address / URL / FQDN associated with the connection. Can be useful for a game master to do IP Bans etc.
Best used to get concrete Endpoint type based on the being used
Declaration
public IEndPoint Address { get; }
IsConnecting
Connect called on client, but server has not replied yet
Declaration
public bool IsConnecting { get; }
IsConnected
Server and Client are connected and can send messages
Declaration
public bool IsConnected { get; }
VisList
List of all networkIdentity that this player can see Only valid on server
Declaration
public IReadOnlyCollection<NetworkIdentity> VisList { get; }
OwnedObjects
Declaration
public IReadOnlyCollection<NetworkIdentity> OwnedObjects { get; }
Identity
The NetworkIdentity for this connection.
Declaration
public NetworkIdentity Identity { get; set; }
Methods
SetAuthentication(PlayerAuthentication, Boolean)
Declaration
public void SetAuthentication(PlayerAuthentication authentication, bool allowReplace)
Parameters
Type | Name | Description |
---|---|---|
Mirage.Authentication.PlayerAuthentication | authentication | |
System.Boolean | allowReplace |
Disconnect()
Disconnects the player. A disconnected player can not send messages
Declaration
public void Disconnect()
Disconnect(DisconnectReason)
Disconnects the player. A disconnected player can not send messages
Declaration
public void Disconnect(DisconnectReason reason)
Parameters
Type | Name | Description |
---|---|---|
Mirage.SocketLayer.DisconnectReason | reason |
MarkAsDisconnected()
Marks player as disconnected, used when the disconnect call is from peer A disconnected player can not send messages
Declaration
public void MarkAsDisconnected()
Send<T>(T, Channel)
This sends a network message to the connection.
Declaration
public void Send<T>(T message, Channel channelId = Channel.Reliable)
Parameters
Type | Name | Description |
---|---|---|
T | message | |
Mirage.Channel | channelId | The transport layer channel to send on. |
Send(ArraySegment<Byte>, Channel)
Sends a block of data Only use this method if data has message Id already included, otherwise receives wont know how to handle it. Otherwise use (T, int)">
Declaration
public void Send(ArraySegment<byte> segment, Channel channelId = Channel.Reliable)
Parameters
Type | Name | Description |
---|---|---|
System.ArraySegment<System.Byte> | segment | |
Mirage.Channel | channelId |
Send<T>(T, INotifyCallBack)
This sends a network message to the connection.
Declaration
public void Send<T>(T message, INotifyCallBack callBacks)
Parameters
Type | Name | Description |
---|---|---|
T | message | |
Mirage.SocketLayer.INotifyCallBack | callBacks |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
AddToVisList(NetworkIdentity)
Declaration
public void AddToVisList(NetworkIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
Mirage.NetworkIdentity | identity |
RemoveFromVisList(NetworkIdentity)
Declaration
public void RemoveFromVisList(NetworkIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
Mirage.NetworkIdentity | identity |
ContainsInVisList(NetworkIdentity)
Checks if player can see NetworkIdentity
Declaration
public bool ContainsInVisList(NetworkIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
Mirage.NetworkIdentity | identity |
Returns
Type | Description |
---|---|
System.Boolean |
RemoveAllVisibleObjects()
Removes all objects that this player can see This is called when loading a new scene
Declaration
public void RemoveAllVisibleObjects()
AddOwnedObject(NetworkIdentity)
Declaration
public void AddOwnedObject(NetworkIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
Mirage.NetworkIdentity | identity |
RemoveOwnedObject(NetworkIdentity)
Declaration
public void RemoveOwnedObject(NetworkIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
Mirage.NetworkIdentity | identity |
RemoveAllOwnedObject(Boolean)
Declaration
public void RemoveAllOwnedObject(bool sendAuthorityChangeEvent)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | sendAuthorityChangeEvent |
DestroyOwnedObjects()
Destroy all objects owned by this player NOTE: only destroyed objects that are currently spawned
Declaration
public void DestroyOwnedObjects()