Skip to content

Commit 6dd5d6e

Browse files
Merge pull request zino-hofmann#1404 from szantogab/main
Main
2 parents 41cd27e + 694aa26 commit 6dd5d6e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/graphql/lib/src/links/websocket_link/websocket_client.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,14 @@ class GraphQLWebSocketChannel extends StreamChannelMixin<dynamic>
637637
Stream<GraphQLSocketMessage>? _messages;
638638

639639
/// Stream of messages from the endpoint parsed as GraphQLSocketMessages
640-
Stream<GraphQLSocketMessage> get messages => _messages ??=
641-
stream.map<GraphQLSocketMessage>(GraphQLSocketMessage.parse);
640+
Stream<GraphQLSocketMessage> get messages {
641+
if (_messages == null)
642+
_messages = stream.map((event) {
643+
return GraphQLSocketMessage.parse(event);
644+
}).asBroadcastStream();
645+
646+
return _messages!;
647+
}
642648

643649
String? get protocol => _webSocket.protocol;
644650

packages/graphql/lib/src/links/websocket_link/websocket_link.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class WebSocketLink extends Link {
4545
);
4646
}
4747

48+
SocketClient? get getSocketClient => _socketClient;
49+
4850
/// Disposes the underlying socket client explicitly. Only use this, if you want to disconnect from
4951
/// the current server in favour of another one. If that's the case, create a new [WebSocketLink] instance.
5052
Future<void> dispose() async {

0 commit comments

Comments
 (0)