Skip to main content

Class NetworkPlayer

A High level network connection. This is used for connections from client-to-server and for connection from server-to-client.

Inheritance
System.Object
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
TypeNameDescription
Mirage.SocketLayer.IConnectionconnection
System.BooleanisHost

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; }

Address

The IP address / URL / FQDN associated with the connection. Can be useful for a game master to do IP Bans etc.

Declaration
public IEndPoint Address { get; }

Connection

Declaration
public IConnection Connection { 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
TypeNameDescription
Mirage.Authentication.PlayerAuthenticationauthentication
System.BooleanallowReplace

Disconnect()

Disconnects the player. A disconnected player can not send messages

Declaration
public void Disconnect()

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
TypeNameDescription
Tmessage
Mirage.ChannelchannelIdThe 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
TypeNameDescription
System.ArraySegment<System.Byte>segment
Mirage.ChannelchannelId

Send<T>(T, INotifyCallBack)

This sends a network message to the connection.

Declaration
public void Send<T>(T message, INotifyCallBack callBacks)
Parameters
TypeNameDescription
Tmessage
Mirage.SocketLayer.INotifyCallBackcallBacks

ToString()

Declaration
public override string ToString()
Returns
TypeDescription
System.String

AddToVisList(NetworkIdentity)

Declaration
public void AddToVisList(NetworkIdentity identity)
Parameters
TypeNameDescription
Mirage.NetworkIdentityidentity

RemoveFromVisList(NetworkIdentity)

Declaration
public void RemoveFromVisList(NetworkIdentity identity)
Parameters
TypeNameDescription
Mirage.NetworkIdentityidentity

ContainsInVisList(NetworkIdentity)

Checks if player can see NetworkIdentity

Declaration
public bool ContainsInVisList(NetworkIdentity identity)
Parameters
TypeNameDescription
Mirage.NetworkIdentityidentity
Returns
TypeDescription
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
TypeNameDescription
Mirage.NetworkIdentityidentity

RemoveOwnedObject(NetworkIdentity)

Declaration
public void RemoveOwnedObject(NetworkIdentity identity)
Parameters
TypeNameDescription
Mirage.NetworkIdentityidentity

RemoveAllOwnedObject(Boolean)

Declaration
public void RemoveAllOwnedObject(bool sendAuthorityChangeEvent)
Parameters
TypeNameDescription
System.BooleansendAuthorityChangeEvent

DestroyOwnedObjects()

Destroy all objects owned by this player NOTE: only destroyed objects that are currently spawned

Declaration
public void DestroyOwnedObjects()