File tree Expand file tree Collapse file tree 4 files changed +7438
-6581
lines changed
Expand file tree Collapse file tree 4 files changed +7438
-6581
lines changed Original file line number Diff line number Diff line change 1+ ## 3.0.0
2+
3+ - Add retry logic.
4+
5+ ** Possible Breaking Change ** Error messages may now be delayed up to 5 seconds
6+ in the client.
7+
18## 2.1.2
29
310- Remove ` package:http ` dependency.
Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ class SseClient extends StreamChannelMixin<String> {
2525
2626 String _serverUrl;
2727
28+ Timer _errorTimer;
29+
2830 /// [serverUrl] is the URL under which the server is listening for
2931 /// incoming bi-directional SSE connections.
3032 SseClient (String serverUrl) {
@@ -36,7 +38,20 @@ class SseClient extends StreamChannelMixin<String> {
3638 .listen (_onOutgoingMessage, onDone: _onOutgoingDone);
3739 _eventSource.addEventListener ('message' , _onIncomingMessage);
3840 _eventSource.addEventListener ('control' , _onIncomingControlMessage);
39- _eventSource.onError.listen (_incomingController.addError);
41+ _eventSource.onOpen.listen ((_) {
42+ _errorTimer? .cancel ();
43+ });
44+ _eventSource.onError.listen ((error) {
45+ if (! (_errorTimer? .isActive ?? false )) {
46+ // By default the SSE client uses keep-alive.
47+ // Allow for a retry to connect before giving up.
48+ _errorTimer = Timer (const Duration (seconds: 5 ), () {
49+ _incomingController.addError (error);
50+ _eventSource.close ();
51+ });
52+ }
53+ });
54+
4055 _startPostingMessages ();
4156 }
4257
Original file line number Diff line number Diff line change 11name : sse
2- version : 2.1.2
2+ version : 3.0.0
33author :
Dart Team <[email protected] > 44homepage : https://github.com/dart-lang/sse
55description : >-
You can’t perform that action at this time.
0 commit comments