Struct ApprovalDecision

Namespace
Unity.Multiplayer.Core

The server's answer to a connection request: approved with the decoded payload, or rejected with an ApprovalRejection and a sentence the client can show the player.

public readonly struct ApprovalDecision
Inherited Members

Properties

Approved

True when the connection may proceed.

public bool Approved { get; }

Property Value

bool

Message

A sentence for the player; empty when approved.

public string Message { get; }

Property Value

string

Payload

The decoded payload when it could be read (always when approved; null for most BadPayload cases).

public ConnectionPayload Payload { get; }

Property Value

ConnectionPayload

Rejection

Why the connection was rejected, or None.

public ApprovalRejection Rejection { get; }

Property Value

ApprovalRejection

Methods

Approve(ConnectionPayload)

An approval carrying the client's payload.

public static ApprovalDecision Approve(ConnectionPayload payload)

Parameters

payload ConnectionPayload

Returns

ApprovalDecision

Exceptions

ArgumentNullException

payload is null.

Reject(ApprovalRejection, string, ConnectionPayload)

A rejection with its reason and message.

public static ApprovalDecision Reject(ApprovalRejection rejection, string message, ConnectionPayload payload = null)

Parameters

rejection ApprovalRejection
message string
payload ConnectionPayload

Returns

ApprovalDecision

Exceptions

ArgumentException

rejection is None or undefined.

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

ToWireReason()

The reason string the transport sends back with a refused connection: "<Rejection>|<message>", or empty when approved. TryParseWireReason(string, out ApprovalRejection, out string) reads it on the client.

public string ToWireReason()

Returns

string

TryParseWireReason(string, out ApprovalRejection, out string)

Reads a reason string written by ToWireReason(). False for empty or foreign text, in which case message holds the raw text so it can still be shown.

public static bool TryParseWireReason(string reason, out ApprovalRejection rejection, out string message)

Parameters

reason string
rejection ApprovalRejection
message string

Returns

bool