From 49d153552e8a9c345304e4be07020557591f387b Mon Sep 17 00:00:00 2001 From: sorairo Date: Mon, 14 Oct 2024 15:17:00 +0900 Subject: [PATCH] =?UTF-8?q?subNotes=E3=82=82=E4=BF=9D=E6=8C=81=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/services/streaming_service_impl.dart | 26 ++++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/src/services/streaming_service_impl.dart b/lib/src/services/streaming_service_impl.dart index 681d945..9bd0342 100644 --- a/lib/src/services/streaming_service_impl.dart +++ b/lib/src/services/streaming_service_impl.dart @@ -24,6 +24,7 @@ class StreamingService implements StreamingController, WebSocketController { WebSocketChannel? _webSocketChannel; final List _connections = []; + final List _subNotes = []; final _controller = StreamController.broadcast(); StreamSubscription? _subscription; @@ -114,6 +115,9 @@ class StreamingService implements StreamingController, WebSocketController { for (final connection in _connections) { sendRequest(StreamingRequestType.connect, connection); } + for (final subscriptedNotes in _subNotes) { + subNote(subscriptedNotes); + } } catch (e) { if (retryCounts < maxRetryCounts) { await _reconnect(retryCounts: retryCounts + 1); @@ -206,16 +210,22 @@ class StreamingService implements StreamingController, WebSocketController { } @override - void subNote(String noteId) => sendRequest( - StreamingRequestType.subNote, - StreamingRequestBody(id: noteId, params: {}), - ); + void subNote(String noteId) { + sendRequest( + StreamingRequestType.subNote, + StreamingRequestBody(id: noteId, params: {}), + ); + _subNotes.add(noteId); + } @override - void unsubNote(String noteId) => sendRequest( - StreamingRequestType.unsubNote, - StreamingRequestBody(id: noteId, params: {}), - ); + void unsubNote(String noteId) { + sendRequest( + StreamingRequestType.unsubNote, + StreamingRequestBody(id: noteId, params: {}), + ); + _subNotes.remove(noteId); + } @override void requestLog(String id, int length) => sendRequest(