Table of Contents

Struct SessionEvent

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

One thing that happened to one session, as an application system reads it in the tick.

public readonly struct SessionEvent
Inherited Members

Remarks

A single struct rather than one type per kind: the batch is a flat span an application walks with a switch, which keeps the read allocation-free and keeps the ordering between an Opened and a Closed visible — a session that opens and closes inside one tick produces both, in that order, and an application that only handles one of them would otherwise leak whatever it built.

Properties

AppData

Whatever the admission hook attached to this session.

public object AppData { get; }

Property Value

object

CloseCode

The close code the client was given.

public ushort CloseCode { get; }

Property Value

ushort

DegradeLevel

The degrade level the session moved to. Meaningful on Degraded: 1 is served every 2nd tick, 2 every 4th, and 0 is back to every tick. 0 on every other kind.

public int DegradeLevel { get; }

Property Value

int

HelloPayload

The client's HELLO payload, copied out of the transport's buffer. Empty when it sent none.

public ReadOnlyMemory<byte> HelloPayload { get; }

Property Value

ReadOnlyMemory<byte>

Kind

What happened.

public SessionEventKind Kind { get; }

Property Value

SessionEventKind

Limits

The limits admission asked for — the object the hook handed back, not the resolved numbers.

public SessionLimits Limits { get; }

Property Value

SessionLimits

Principal

The authenticated principal, or null — always null until the security work lands.

public ClaimsPrincipal Principal { get; }

Property Value

ClaimsPrincipal

Realm

The realm this is about. Meaningful on RealmClosed, where it is the realm that was removed; None on every other kind.

public RealmId Realm { get; }

Property Value

RealmId

Remarks

The realm that went away, not the one the session is in — which is None by the time this is read and would tell the application nothing. An application with per-realm state keyed by id (a party, an instance record, a timer) needs the key to drop it by, and this is the last moment that key exists anywhere: the realm is out of the table before the tick delivering this begins.

Reason

Why it ended. Meaningful on Closed.

public SessionCloseReason Reason { get; }

Property Value

SessionCloseReason

Resumable

Whether the client may come back to this session within the grace period.

public bool Resumable { get; }

Property Value

bool

ResumedFrom

The session this one resumed, or None. Filled when resume is built.

public SessionId ResumedFrom { get; }

Property Value

SessionId

Role

The role admission gave it. Meaningful on Opened.

public SessionRole Role { get; }

Property Value

SessionRole

Session

Which session it happened to.

public SessionId Session { get; }

Property Value

SessionId

SessionKind

The application-declared kind the client presented.

public string SessionKind { get; }

Property Value

string

Methods

Create(SessionEventKind, SessionId, object, SessionId, bool, SessionCloseReason, SessionRole, string, ushort, RealmId, int)

A session event built by hand: what a unit test hands an application's session-lifecycle code, through Raise(in SessionEvent), to drive it without sockets.

public static SessionEvent Create(SessionEventKind kind, SessionId session, object appData = null, SessionId resumedFrom = default, bool resumable = false, SessionCloseReason reason = SessionCloseReason.ClientLeft, SessionRole role = SessionRole.Spectator, string sessionKind = null, ushort closeCode = 0, RealmId realm = default, int degradeLevel = 0)

Parameters

kind SessionEventKind

What happened.

session SessionId

Which session.

appData object

What the admission hook attached.

resumedFrom SessionId

For an Opened that resumed one, the session it resumed.

resumable bool

For a Closed, whether the client may come back within the grace period.

reason SessionCloseReason

For a Closed, why.

role SessionRole

The role admission gave it.

sessionKind string

The application-declared kind the client presented.

closeCode ushort

For a Closed, the close code.

realm RealmId

For a RealmClosed, the realm removed.

degradeLevel int

For a Degraded, the level.

Returns

SessionEvent

The event, as the engine would deliver it.

ToString()

public override string ToString()

Returns

string