receive method

Future<ControlMessage> receive({
  1. Duration timeout = const Duration(seconds: 10),
})

Reads the next message, failing if none arrives within timeout.

Throws TransportException if the peer closes mid-handshake, and ProtocolException if what arrives is not a decodable control message.

Implementation

Future<ControlMessage> receive({
  Duration timeout = const Duration(seconds: 10),
}) async {
  try {
    return codec.fromWire(await connection.receive(timeout: timeout));
  } on OmnyServerException {
    rethrow;
  } on Object catch (e) {
    throw TransportException('connection closed during handshake: $e');
  }
}