ConnectionData

Readonly struct that carries user identity information during the Netcode connection handshake. Provides implicit conversion operators to and from byte[] for seamless integration with Unity Netcode's ConnectionData payload.

Definition

Namespace: Paragon.Core.Network Assembly: Paragon.dll

public readonly struct ConnectionData

Remarks

When a client connects to a session, Netcode sends a byte[] connection payload that the server can inspect during connection approval. ConnectionData wraps this mechanism by:

  1. Storing a NetworkUser (containing user ID and display name).

  2. Providing implicit operator byte[] to automatically serialize the struct when assigned to Netcode's NetworkConfig.ConnectionData.

  3. Providing implicit operator ConnectionData to automatically deserialize incoming byte[] payloads.

Serialization uses Unity Netcode's FastBufferWriter / FastBufferReader with Allocator.Temp for zero-allocation in steady state.

Quick Lookup

Goal
How

Create from a user

new ConnectionData(networkUser)

Serialize to bytes

byte[] bytes = connectionData; (implicit)

Deserialize from bytes

ConnectionData data = bytes; (implicit)

Get user ID

data.UserID

Get user name

data.UserName

Properties

User

The NetworkUser this connection data represents.

UserID

Shortcut to User.ID.

UserName

Shortcut to User.Name.

Methods

Constructor

Parameter
Type
Description

user

NetworkUser

The user identity to embed in the connection payload

Implicit Operators

These enable seamless assignment to/from Netcode's byte[] connection data fields:

Examples

Setting Connection Data Before Joining

Reading Connection Data During Approval

See Also

Last updated