RemoteClient.withoutJson constructor
RemoteClient.withoutJson(
- StreamChannel<
Map> channel
Implementation
RemoteClient.withoutJson(this.channel) {
// A message sent after the connection has closed is dropped.
_ctrl.local.stream.listen((m) => _addTo(channel.sink, m.toJson()));
// The end of [channel], and its errors, are passed on, so that a server
// knows when the connection has ended. A message that is not one, such
// as one without a string `type`, is left out.
channel.stream.listen(
(m) {
OperationMessage message;
try {
message = OperationMessage.fromJson(m);
} on ArgumentError {
return;
}
_ctrl.local.sink.add(message);
},
onError: _ctrl.local.sink.addError,
onDone: _ctrl.local.sink.close,
);
}