onMessage method

  1. @override
void onMessage(
  1. List<int> msg,
  2. PeerInfo info
)
override

Internal callback triggered when a message arrives for this peer

Implementation

@override
void onMessage(List<int> msg, PeerInfo info) {
  // Check protocol messages first
  if (_isHandshake(msg)) return;
  if (_isClosing(msg)) return;
  if (_isClosed(msg)) return;
  if (_isKeepAlive(msg)) return;

  // Pass to parent for user callback
  if (_isData(msg)) {
    super.onMessage(msg, info);
    return;
  }

  throw ShspProtocolException(
    'Message type not recognized by ShspInstance',
    messageType: msg.isNotEmpty ? '0x${msg[0].toRadixString(16)}' : 'empty',
  );
}