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
clientIdulongThe connection's client id.
seatIndexintThe seat it sits in, or -1 for none.
displayNamestringThe 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
Properties
ClientId
The sending connection's client id.
public ulong ClientId { get; }
Property Value
DisplayName
The name the player connected with; empty when unknown.
public string DisplayName { get; }
Property Value
HasSeat
True when the sender holds a seat.
public bool HasSeat { get; }
Property Value
IsServer
True when the call came from the server process itself (a host's own player).
public bool IsServer { get; }
Property Value
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
Server
The server (or a host's own player) with no seat information.
public static NetSender Server { get; }
Property Value
Methods
Equals(object)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand 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
otherNetSenderAn object to compare with this object.
Returns
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
Returns
implicit operator ulong(NetSender)
The sender's client id.
public static implicit operator ulong(NetSender sender)
Parameters
senderNetSender
Returns
operator !=(NetSender, NetSender)
Inequality by client id, seat and name.
public static bool operator !=(NetSender left, NetSender right)