Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/HEAD' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Dec 13, 2023
2 parents bcc3151 + a316c53 commit da5c809
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions lib/html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ class HtmlWebSocketChannel extends StreamChannelMixin
}
// The socket API guarantees that only a single open event will be
// emitted.
innerWebSocket.onOpen.first.then((_) {
innerWebSocket.onOpenX.first.then((_) {
_readyCompleter.complete();
_listen();
});
}

// The socket API guarantees that only a single error event will be emitted,
// and that once it is no open or message events will be emitted.
innerWebSocket.onError.first.then((_) {
innerWebSocket.onErrorX.first.then((_) {
// Unfortunately, the underlying WebSocket API doesn't expose any
// specific information about the error itself.
final error = WebSocketChannelException('WebSocket connection failed.');
Expand All @@ -115,11 +115,11 @@ class HtmlWebSocketChannel extends StreamChannelMixin
_controller.local.sink.close();
});

innerWebSocket.onMessage.listen(_innerListen);
innerWebSocket.onMessageX.listen(_innerListen);

// The socket API guarantees that only a single error event will be emitted,
// and that once it is no other events will be emitted.
innerWebSocket.onClose.first.then((event) {
innerWebSocket.onCloseX.first.then((event) {
_closeCode = event.code;
_closeReason = event.reason;
_controller.local.sink.close();
Expand Down
8 changes: 4 additions & 4 deletions lib/src/web_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import 'package:web/helpers.dart';
// TODO(kevmoo): remove when https://github.com/dart-lang/web/commit/4cb5811ed06
// is in a published release and the min constraint on pkg:web is updated
extension WebSocketEvents on WebSocket {
Stream<Event> get onOpen => EventStreamProviders.openEvent.forTarget(this);
Stream<MessageEvent> get onMessage =>
Stream<Event> get onOpenX => EventStreamProviders.openEvent.forTarget(this);
Stream<MessageEvent> get onMessageX =>
EventStreamProviders.messageEvent.forTarget(this);
Stream<CloseEvent> get onClose =>
Stream<CloseEvent> get onCloseX =>
EventStreamProviders.closeEvent.forTarget(this);
Stream<Event> get onError =>
Stream<Event> get onErrorX =>
EventStreamProviders.errorEventSourceEvent.forTarget(this);
}
2 changes: 1 addition & 1 deletion test/html_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void main() {

test('communicates using an existing open WebSocket', () async {
final webSocket = WebSocket('ws://localhost:$port');
await webSocket.onOpen.first;
await webSocket.onOpenX.first;

final channel = HtmlWebSocketChannel(webSocket);

Expand Down

0 comments on commit da5c809

Please sign in to comment.