Table of Contents

Interface ISubscriptionConnection

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

One connection as the transport drives it: inbound messages, and the end of the link.

public interface ISubscriptionConnection

Remarks

Implemented by the engine, one per connection. Everything the protocol says — the handshake, the message caps, the close codes, the session — happens behind these two methods, which is what keeps a transport free of protocol knowledge it would otherwise have to keep in step with the wire.

Methods

OnClosed(ushort, Exception)

Reports that the link has ended.

void OnClosed(ushort code, Exception error)

Parameters

code ushort

The close code observed on the wire, or Normal when there was none to observe.

error Exception

The transport failure that ended it, or null for an orderly close.

Remarks

Delivered exactly once, for every connection, whoever ended it — including a close the engine itself asked for through Close(ushort, string). It is what releases the session's row, so a transport that skips it on a path it considers uninteresting leaks a session slot for the lifetime of the process. It never throws.

OnMessage(ReadOnlySpan<byte>)

Delivers one complete client-to-server message.

void OnMessage(ReadOnlySpan<byte> message)

Parameters

message ReadOnlySpan<byte>

The whole message, type byte included and framing excluded. Borrowed: the engine copies whatever it keeps, so the transport may reuse the buffer the moment this returns.

Remarks

Sequential per connection, in the order the peer sent them. The engine does no locking on the strength of that and a transport that overlaps two calls breaks the session's ordering guarantees, not merely its own.

It does not throw, and it does not report. A message that is too large, out of state, unknown or malformed closes the connection with the close code the protocol gives it — 1009, 1002, 1007 — and the transport learns of it through Close(ushort, string), exactly as it would for a close the engine decided for any other reason. A transport therefore has one code path for "the engine ended this", not two.

A transport may cap message size itself and close 1009 before calling; the engine checks again, because the caps are the protocol's and only the engine knows the session's own clientMessageBytes.