|
@@ -50,6 +50,8 @@ class JsonRpcNotificationListener {
|
|
|
_channel = WebSocketChannel.connect(Uri.parse(_buildConnectUrl()));
|
|
|
_channel!.stream.listen(
|
|
|
(data) {
|
|
|
+ if (!running) return; // diable inner 5s's retention.
|
|
|
+
|
|
|
final message = _parseMessageData(data);
|
|
|
if (message != null) {
|
|
|
_handleNotification(message);
|
|
@@ -89,10 +91,10 @@ class JsonRpcNotificationListener {
|
|
|
}
|
|
|
|
|
|
/// Close and dispose connection/other resources.
|
|
|
- void close() {
|
|
|
+ Future<void> close() async {
|
|
|
if (_channel != null) {
|
|
|
- if (_channel!.closeCode != null) {
|
|
|
- _channel!.sink.close(wsStatus.normalClosure);
|
|
|
+ if (_channel!.closeCode == null) {
|
|
|
+ await _channel!.sink.close(wsStatus.normalClosure);
|
|
|
}
|
|
|
_channel = null;
|
|
|
}
|