Table of Contents

Interface IChannelConnection

Namespace
Shard.Network
Assembly
Shard.Network.dll

The game-facing handle to one QUIC stream's packet flow. Mirrors the Java ChannelConnection implemented by QuicheChannel: enqueue outbound packets, observe the peer certificate (for cert-bound auth), and control the connection. All members are safe to call from any thread; work is marshalled onto the owning connection's event loop.

public interface IChannelConnection

Properties

Channel

The logical channel this stream carries (Default / Chunks / WorldMap / Voice).

NetworkChannel Channel { get; }

Property Value

NetworkChannel

ClientCertificate

The peer's TLS certificate (mTLS), available once the connection is established.

X509Certificate2? ClientCertificate { get; }

Property Value

X509Certificate2

SniHostname

The SNI host name the peer requested, if any.

string? SniHostname { get; }

Property Value

string

Methods

Disconnect(string)

Gracefully close the connection with a human-readable reason.

void Disconnect(string reason)

Parameters

reason string

Flush()

Request a flush of any queued packets.

void Flush()

IsHandlerLeaseCurrent(ConnectionHandlerLease, IConnectionHandler)

Determines whether lease still identifies the exact stable generation owned by expected.

bool IsHandlerLeaseCurrent(ConnectionHandlerLease lease, IConnectionHandler expected)

Parameters

lease ConnectionHandlerLease
expected IConnectionHandler

Returns

bool

TryCaptureHandlerLease(IConnectionHandler, out ConnectionHandlerLease)

Attempts to capture authority for the exact stable generation currently owned by expected.

bool TryCaptureHandlerLease(IConnectionHandler expected, out ConnectionHandlerLease lease)

Parameters

expected IConnectionHandler
lease ConnectionHandlerLease

Returns

bool

Remarks

Capture fails while a replacement is in progress, after close, or when the expected handler is no longer current. The returned lease is opaque and valid only for this channel connection.

TryDisconnect(ConnectionHandlerLease, IConnectionHandler, string)

Atomically closes the connection only while lease still identifies the stable generation owned by expected.

bool TryDisconnect(ConnectionHandlerLease lease, IConnectionHandler expected, string reason)

Parameters

lease ConnectionHandlerLease
expected IConnectionHandler
reason string

Returns

bool

true when this exact handler generation won connection close. Otherwise, false when its authority was stale, foreign, transitioning, or already closed.

TryReplaceHandlerAsync(ConnectionHandlerLease, IConnectionHandler)

Conditionally replaces the exact handler generation identified by expected.

ValueTask<ConnectionHandlerLease?> TryReplaceHandlerAsync(ConnectionHandlerLease expected, IConnectionHandler replacement)

Parameters

expected ConnectionHandlerLease
replacement IConnectionHandler

Returns

ValueTask<ConnectionHandlerLease?>

A lease for the installed replacement, or null when the supplied authority is stale, foreign, already consumed, or otherwise not replaceable.

Remarks

Replacement callbacks execute on the owning connection loop. Closing the connection before a stable replacement commits faults the operation with ObjectDisposedException.

Write(IToClientPacket)

Queue a packet to send; flushed by the connection loop.

void Write(IToClientPacket packet)

Parameters

packet IToClientPacket

Write(IEnumerable<IToClientPacket>)

Queues multiple packets for transmission; flushed by the connection loop.

void Write(IEnumerable<IToClientPacket> packets)

Parameters

packets IEnumerable<IToClientPacket>

WriteAndFlush(IToClientPacket)

Queue a packet and request an immediate flush.

void WriteAndFlush(IToClientPacket packet)

Parameters

packet IToClientPacket

WriteAndFlush(IEnumerable<IToClientPacket>)

Queues multiple packets for transmission and requests an immediate flush.

void WriteAndFlush(IEnumerable<IToClientPacket> packets)

Parameters

packets IEnumerable<IToClientPacket>