Skip to content

Commit

Permalink
subNotesも保持するように
Browse files Browse the repository at this point in the history
  • Loading branch information
shiosyakeyakini-info committed Oct 14, 2024
1 parent cde01a9 commit 49d1535
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions lib/src/services/streaming_service_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class StreamingService implements StreamingController, WebSocketController {
WebSocketChannel? _webSocketChannel;

final List<StreamingRequestBody> _connections = [];
final List<String> _subNotes = [];

final _controller = StreamController<StreamingResponse>.broadcast();
StreamSubscription? _subscription;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 49d1535

Please sign in to comment.