decodeControlPayload method

  1. @override
IMessage<IMessageType>? decodeControlPayload(
  1. Object payload,
  2. String fromNodeUId
)
override

The only control payload a data stream carries is a producer's upstream, which is noted here and is not a message.

Implementation

@override
IMessage? decodeControlPayload(Object payload, String fromNodeUId) {
  if (payload is! String) return null;
  try {
    final json = jsonDecode(payload);
    if (json is Map && json.containsKey(_clockKey)) {
      _upstreams[fromNodeUId] = ClockChain.fromJson(json[_clockKey]);
    }
  } on FormatException {
    // Not ours; a peer cannot be trusted to send well-formed JSON.
  }
  return null;
}