This repository was archived by the owner on Feb 24, 2025. It is now read-only.
Commit b672220 1 parent b612fc2 commit b672220 Copy full SHA for b672220
File tree 2 files changed +7
-7
lines changed
2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -79,15 +79,13 @@ class AdapterWebSocketChannel extends StreamChannelMixin
79
79
}
80
80
81
81
webSocketFuture.then ((webSocket) {
82
- var remoteClosed = false ;
83
82
webSocket.events.listen ((event) {
84
83
switch (event) {
85
84
case TextDataReceived (text: final text):
86
85
_controller.local.sink.add (text);
87
86
case BinaryDataReceived (data: final data):
88
87
_controller.local.sink.add (data);
89
88
case CloseReceived (code: final code, reason: final reason):
90
- remoteClosed = true ;
91
89
_closeCode = code;
92
90
_closeReason = reason;
93
91
_controller.local.sink.close ();
@@ -105,13 +103,15 @@ class AdapterWebSocketChannel extends StreamChannelMixin
105
103
default :
106
104
throw UnsupportedError ('Cannot send ${obj .runtimeType }' );
107
105
}
108
- } on WebSocketConnectionClosed catch (_) {
106
+ } on WebSocketConnectionClosed {
109
107
// There is nowhere to surface this error; `_controller.local.sink`
110
108
// has already been closed.
111
109
}
112
- }, onDone: () {
113
- if (! remoteClosed) {
114
- webSocket.close (_localCloseCode, _localCloseReason);
110
+ }, onDone: () async {
111
+ try {
112
+ await webSocket.close (_localCloseCode, _localCloseReason);
113
+ } on WebSocketConnectionClosed {
114
+ // It is not an error to close an already-closed `WebSocketChannel`.
115
115
}
116
116
});
117
117
_protocol = webSocket.protocol;
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ dependencies:
14
14
crypto : ^3.0.0
15
15
stream_channel : ^2.1.0
16
16
web : ^0.5.0
17
- web_socket : ^0.1.1
17
+ web_socket : ^0.1.3
18
18
19
19
dev_dependencies :
20
20
dart_flutter_team_lints : ^2.0.0
You can’t perform that action at this time.
0 commit comments