Struct SessionEvent
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
CloseCode
The close code the client was given.
public ushort CloseCode { get; }
Property Value
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
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
Kind
What happened.
public SessionEventKind Kind { get; }
Property Value
Limits
The limits admission asked for — the object the hook handed back, not the resolved numbers.
public SessionLimits Limits { get; }
Property Value
Principal
public ClaimsPrincipal Principal { get; }
Property Value
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
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
Resumable
Whether the client may come back to this session within the grace period.
public bool Resumable { get; }
Property Value
ResumedFrom
The session this one resumed, or None. Filled when resume is built.
public SessionId ResumedFrom { get; }
Property Value
Role
The role admission gave it. Meaningful on Opened.
public SessionRole Role { get; }
Property Value
Session
Which session it happened to.
public SessionId Session { get; }
Property Value
SessionKind
The application-declared kind the client presented.
public string SessionKind { get; }
Property Value
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
kindSessionEventKindWhat happened.
sessionSessionIdWhich session.
appDataobjectWhat the admission hook attached.
resumedFromSessionIdFor an Opened that resumed one, the session it resumed.
resumableboolFor a Closed, whether the client may come back within the grace period.
reasonSessionCloseReasonFor a Closed, why.
roleSessionRoleThe role admission gave it.
sessionKindstringThe application-declared kind the client presented.
closeCodeushortFor a Closed, the close code.
realmRealmIdFor a RealmClosed, the realm removed.
degradeLevelintFor a Degraded, the level.
Returns
- SessionEvent
The event, as the engine would deliver it.
ToString()
public override string ToString()