BridgePacket class
BridgePacket (B=1): packets exchanged with the relay server, or forwarded by the server between two clients. These packets carry target/source bids and MAY be signed (HMAC-SHA256) once a secret has been established.
Instruction factories live on BridgePacketFactory; this class only
exposes the parse-facing constructor, the create constructor and the
sign method inherited from BasePacket.
- Inheritance
-
- Object
- BasePacket
- BridgePacket
Constructors
- BridgePacket(Packet _packet)
- Wrap a parsed or freshly built inner packet as a bridge packet, asserting that the bridge flag is set (B=1).
- BridgePacket.create({required int ack, required int target, required int source, required int sn, required int index, required int count, required int command, required Uint8List payload})
-
Build a fresh BridgePacket from scratch (wire bytes not yet packed).
factory
Properties
- ack → int
-
A (0x80): 1 = reply to the peer's request.
no setterinherited
- bid → int
-
B (0x40): 1 = bridge packet (carries target/source bids).
no setterinherited
- className → String
-
Class name shown by toString: the actual runtime type when asserts
are enabled (debug builds), or the fixed
'MagpiePacket'otherwise.no setterinherited - cmd → int
-
C (0x20): 1 = carries a command; 0 = plain DATA.
no setterinherited
- command → int
-
Command value (0 = empty command, plain DATA).
no setterinherited
- count → int
-
Fragment count (1 for mini packets).
no setterinherited
- dsn → int
-
D (0x10): 1 = carries an sn; 0 = system command.
no setterinherited
- ext → int
-
E (0x07): byte width of the index/count fields (0/2/4).
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- headerLength → int
-
Full header length in bytes,
buffer[5](8 ~ 32).no setterinherited - index → int
-
Fragment index (0 for mini packets).
no setterinherited
- length → int
-
Total size of the bare packet in bytes: header plus payload.
no setterinherited
- payload → Uint8List
-
Payload bytes (empty for none).
no setterinherited
- payloadLength → int
-
Payload length in bytes,
buffer[6] << 8 | buffer[7].no setterinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sn → int
-
Data serial number (0 for system commands).
no setterinherited
- source → int
-
Source bridge id (0 = first handshake / server-down).
no setterinherited
- target → int
-
Target bridge id (0 = addressed to the server).
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pack(
) → Uint8List -
Pack this packet into the wire bytes (header + payload, + attachment
for a ReliablePacket).
inherited
-
sign(
Uint8List secret) → ReliablePacket -
Compute HMAC-SHA256 over (header + payload) and return a signed packet.
inherited
-
toString(
) → String -
One-line dump, e.g.
ReliablePacket{BID,CMD,EXT=0; target=0, source=123, command=0x50494e47, header=20B, payload=1B, packet=53B}.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited