WsSampleFrame class abstract final

Binary framing for data-stream samples.

Data streams are the latency-critical path, and their shape is already fixed and known to both ends from the negotiated DataStreamConfig — so nothing per-sample needs describing and JSON would be pure overhead. An 8-channel float64 sample is 78 bytes here versus 200+ as JSON, and the receiver can read the payload as a typed list without parsing.

Layout (little-endian):

 0      uint8    frame kind (always kindSample)
 1      uint8    StreamDataType.index
 2..3   uint16   streamSlot   negotiated per stream; no name per sample
 4..5   uint16   srcSlot      REWRITTEN BY THE HUB on relay
 6..13  float64  senderMicros sender's clock, mirrors lsl_timestamp
14..    payload  channels x sizeof(dtype)
                 (string: uint32 length + utf8, per channel)

The hub never parses the payload: it overwrites two bytes at offset 4 and forwards the same buffer to every subscriber. That is what keeps relay cost near zero and is the whole justification for a dumb hub.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

dataTypeOf(Uint8List frame) → StreamDataType
decodeChannels(Uint8List frame, int channelCount) → List<Object?>
Reads the channel values back out.
encode({required StreamDataType dataType, required int streamSlot, required int srcSlot, required double senderMicros, required List<Object?> channels, bool relayed = false}) → Uint8List
isRelayed(Uint8List frame) → bool
Whether a sample frame is of kindRelayed.
isSample(Uint8List bytes) → bool
Whether bytes looks like a sample frame rather than control text.
rewriteSourceSlot(Uint8List frame, int srcSlot) → void
Rewrites the source slot in place, without copying or parsing.
senderMicrosOf(Uint8List frame) → double
sourceSlotOf(Uint8List frame) → int
streamSlotOf(Uint8List frame) → int

Constants

headerBytes → const int
kindRelayed → const int
A sample passed on from somewhere else: the clock field holds the time its origin stamped it with, not when this sender sent it, and reading it needs the stream's ClockChain as well as the sender's offset.
kindSample → const int