Skip to main content

Interface INetworkPlayer

An object owned by a player that can: send/receive messages, have network visibility, be an object owner, authenticated permissions, and load scenes. May be from the server to client or from client to server

Syntax
public interface INetworkPlayer : IMessageSender, IVisibilityTracker, IObjectOwner, ISceneLoader

Properties

Connection

Connection object managed by

This is used to send messages and handle any reliability state for the underlying connection

Declaration
IConnection Connection { get; }

ConnectionHandle

The low-level handle returned by . Can be used to find out more information about the low-level transport used or to get the Address of the connection. Cast this to the handle type for the transport you are using. example: if (ConnectionHandle is UdpConnectionHandle udpHandle) and then get the address via udpHandle.Endpoint

Declaration
IConnectionHandle ConnectionHandle { get; }

IsConnecting

Connect called on client, but server has not replied yet

Declaration
bool IsConnecting { get; }

IsConnected

Server and Client are connected and can send messages

Declaration
bool IsConnected { get; }

Authentication

Declaration
PlayerAuthentication Authentication { get; }

IsAuthenticated

Declaration
bool IsAuthenticated { get; }

ErrorRateLimit

Error rate limiting, will invoke disconnect player (or call if set) when limit is reached

Declaration
RateLimitBucket ErrorRateLimit { get; }

ErrorFlags

Any flags set from catching errors

Declaration
PlayerErrorFlags ErrorFlags { get; }

IsHost

True if this Player is the local player on the server or client

Declaration
bool IsHost { get; }

Methods

SetAuthentication(PlayerAuthentication, Boolean)

Declaration
void SetAuthentication(PlayerAuthentication authentication, bool allowReplace = false)
Parameters
TypeNameDescription
Mirage.Authentication.PlayerAuthenticationauthentication
System.BooleanallowReplace

SetError(Int32, PlayerErrorFlags)

Call this when player causes an error

Declaration
void SetError(int cost, PlayerErrorFlags flags)
Parameters
TypeNameDescription
System.Int32costhow bad or costly is the error. higher cost means player will trigger limit faster
Mirage.PlayerErrorFlagsflagsoptional flag for error type

SetErrorAndDisconnect(PlayerErrorFlags)

Call this when player causes an error, will set cost to be above maxTokens to ensure that limit is cheated to trigger disconnect. If is null will call instead

Declaration
void SetErrorAndDisconnect(PlayerErrorFlags flags)
Parameters
TypeNameDescription
Mirage.PlayerErrorFlagsflagsoptional flag for error type

ResetErrorFlag()

Call to reset error flags

Declaration
void ResetErrorFlag()

Disconnect()

Declaration
void Disconnect()

MarkAsDisconnected()

Declaration
void MarkAsDisconnected()