listen method

StreamSubscription<String> listen(
  1. void onMessage(
    1. ProtocolMessage message
    ), {
  2. Function? onError,
  3. void onDone()?,
})

Implementation

StreamSubscription<String> listen(
    void Function(ProtocolMessage message) onMessage,
    {Function? onError,
    void Function()? onDone}) {
  return _input.transform(PacketTransformer()).listen(
    (String data) => _readMessage(data, onMessage),
    onError: onError,
    onDone: () {
      close();
      if (onDone != null) {
        onDone();
      }
    },
  );
}