RpcChannelFrame class abstract final

Multiplexed frame format for IRpcChannel-based transports.

Wire layout (9-byte header + payload):

[4 bytes] streamId   (big-endian uint32)
[1 byte]  flags
[4 bytes] payloadLen (big-endian uint32)
[N bytes] payload

Flags:

  • bit 0: endOfStream
  • bit 1: metadata frame (payload = encoded headers)
  • bits 2-7: reserved. A sender writes 0; a receiver ignores them, so a later revision can give one an optional meaning without raising protocolVersion. A flag the peer must understand needs a new version.

A metadata payload, every length an unsigned LEB128 varint of at most 5 bytes, every string UTF-8:

[varint] methodPath length + 1   (0: no methodPath)
[bytes]  methodPath
[varint] header count
per header:
  [varint] name length,  [bytes] name
  [varint] value length, [bytes] value

Nothing may follow the last header.

Before its first frame each end writes preface once: rpcdart and protocolVersion.

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 Properties

preface → Uint8List
The bytes each end writes before its first frame: prefaceMagic and protocolVersion. A fresh list on every read.
no setter

Static Methods

decode(Uint8List data, {int? maxPayloadLen, int? maxMetadataLen}) → RpcDecodedFrame?
Decode a frame from raw bytes.
decodeAll(Uint8List data, {int? maxPayloadLen, int? maxMetadataLen, void onMalformedMetadata(int streamId)?}) → (List<RpcDecodedFrame>, int)
Read multiple frames from a buffer.
encodeData({required int streamId, required Uint8List payload, bool endOfStream = false}) → Uint8List
Encode a data frame (gRPC-framed payload bytes).
encodeEndOfStream(int streamId) → Uint8List
Encode an end-of-stream marker (no payload).
encodeMetadata({required int streamId, required RpcMetadata metadata, bool endOfStream = false}) → Uint8List
Encode a metadata frame (headers + optional methodPath).

Constants

flagMetadata → const int
Flag bit marking a metadata frame.
headerSize → const int
Total header size in bytes (4 streamId + 1 flags + 4 length).
prefaceMagic → const String
The magic that opens preface.
prefaceSize → const int
Length of preface in bytes.
protocolVersion → const int
Revision of this wire format, raised with every incompatible change.