responses property
Responses as a Dart Stream (native async surface). Cancelling the subscription abandons the call: RST CANCELLED is sent so the server stops.
Implementation
Stream<Event> get responses {
var cancelled = false;
late StreamController<Event> controller;
controller = StreamController<Event>(
onListen: () {
() async {
try {
while (!cancelled) {
controller.add(await recv());
}
} on EndOfStreamError {
if (!cancelled) await controller.close();
} catch (e, st) {
if (!cancelled) {
controller.addError(e, st);
await controller.close();
}
}
}();
},
onCancel: () {
cancelled = true;
_stream.cancel();
},
);
return controller.stream;
}