Class RosterWire

Namespace
Unity.Multiplayer.Core

The bytes the roster travels in (UM-T55): roster updates from the server, and a player's change request and the server's reply. Engine-free so dotnet test covers it; the adapter carries the bytes in named messages. Decoding is strict and never throws: anything malformed is refused.

public static class RosterWire
Inheritance
RosterWire
Inherited Members

Remarks

Every message starts with Version. A roster update is the flags byte (bit 0: full), then the players (count, then per player: seat, client id, name, colour as RGBA, flags host/connected, ping), then the freed seats. IsLocal never travels: each peer works it out.

Fields

MaxEntries

The most players or seats one message may carry.

public const int MaxEntries = 1024

Field Value

int

MaxReasonLength

The longest refusal reason a reply carries, in characters.

public const int MaxReasonLength = 256

Field Value

int

Version

The format version every message starts with.

public const byte Version = 1

Field Value

byte

Methods

EncodeChangeReply(uint, bool, string)

Encodes the server's reply to change request requestId.

public static byte[] EncodeChangeReply(uint requestId, bool accepted, string reason)

Parameters

requestId uint
accepted bool
reason string

Returns

byte[]

EncodeChangeRequest(uint, PlayerChangeRequest)

Encodes a change request (requestId matches the reply to it).

public static byte[] EncodeChangeRequest(uint requestId, PlayerChangeRequest request)

Parameters

requestId uint
request PlayerChangeRequest

Returns

byte[]

EncodeUpdate(RosterUpdate)

Encodes a roster update.

public static byte[] EncodeUpdate(RosterUpdate update)

Parameters

update RosterUpdate

Returns

byte[]

Exceptions

ArgumentNullException

update is null.

ArgumentException

It carries more than MaxEntries players or seats.

TryDecodeChangeReply(byte[], out uint, out bool, out string)

Decodes a reply; false for anything malformed.

public static bool TryDecodeChangeReply(byte[] data, out uint requestId, out bool accepted, out string reason)

Parameters

data byte[]
requestId uint
accepted bool
reason string

Returns

bool

TryDecodeChangeRequest(byte[], out uint, out PlayerChangeRequest)

Decodes a change request; false for anything malformed (the request itself is checked with Validate()).

public static bool TryDecodeChangeRequest(byte[] data, out uint requestId, out PlayerChangeRequest request)

Parameters

data byte[]
requestId uint
request PlayerChangeRequest

Returns

bool

TryDecodeUpdate(byte[], out RosterUpdate)

Decodes a roster update; false (and null) for anything malformed.

public static bool TryDecodeUpdate(byte[] data, out RosterUpdate update)

Parameters

data byte[]
update RosterUpdate

Returns

bool