Struct NetSender

Namespace
Unity.Multiplayer.Core

Who sent a ToServerAttribute call, as the server knows them: the connection's client id, the seat it sits in and the player's display name. Passed to every On<Name> server handler.

public readonly struct NetSender : IEquatable<NetSender>
Implements
Inherited Members

Remarks

Converts to its ulong client id, so a handler can answer the caller through a ToClientAttribute call: Denied(sender, "Not your turn").

Constructors

NetSender(ulong, int, string)

Creates a sender record.

public NetSender(ulong clientId, int seatIndex, string displayName)

Parameters

clientId ulong

The connection's client id.

seatIndex int

The seat it sits in, or -1 for none.

displayName string

The player's display name; null is stored as empty.

Fields

ServerClientId

The client id of the server itself (and of a host's own player).

public const ulong ServerClientId = 0

Field Value

ulong

Properties

ClientId

The sending connection's client id.

public ulong ClientId { get; }

Property Value

ulong

DisplayName

The name the player connected with; empty when unknown.

public string DisplayName { get; }

Property Value

string

HasSeat

True when the sender holds a seat.

public bool HasSeat { get; }

Property Value

bool

IsServer

True when the call came from the server process itself (a host's own player).

public bool IsServer { get; }

Property Value

bool

SeatIndex

The sender's seat index, or -1 when it has none (no session seats players, or the server itself on a dedicated server).

public int SeatIndex { get; }

Property Value

int

Server

The server (or a host's own player) with no seat information.

public static NetSender Server { get; }

Property Value

NetSender

Methods

Equals(object)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

Equals(NetSender)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(NetSender other)

Parameters

other NetSender

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

Operators

operator ==(NetSender, NetSender)

Equality by client id, seat and name.

public static bool operator ==(NetSender left, NetSender right)

Parameters

left NetSender
right NetSender

Returns

bool

implicit operator ulong(NetSender)

The sender's client id.

public static implicit operator ulong(NetSender sender)

Parameters

sender NetSender

Returns

ulong

operator !=(NetSender, NetSender)

Inequality by client id, seat and name.

public static bool operator !=(NetSender left, NetSender right)

Parameters

left NetSender
right NetSender

Returns

bool