Clean live sessions list

This commit is contained in:
Andrea Cavalli 2022-01-09 20:32:27 +01:00
parent 172c770524
commit fd0bfda2eb

View File

@ -374,7 +374,7 @@ public class AtomixReactiveApi implements ReactiveApi {
} }
}) })
.doOnNext(path -> reactiveApiPublisher.start(path, .doOnNext(path -> reactiveApiPublisher.start(path,
() -> AtomixReactiveApi.this.onPublisherClosed(userId) () -> AtomixReactiveApi.this.onPublisherClosed(userId, liveId)
)) ))
.thenReturn(new CreateSessionResponse(liveId)); .thenReturn(new CreateSessionResponse(liveId));
}); });
@ -393,8 +393,9 @@ public class AtomixReactiveApi implements ReactiveApi {
.doOnError(ex -> LOG.debug("Handled session request {}, the response is: error", req, ex)); .doOnError(ex -> LOG.debug("Handled session request {}, the response is: error", req, ex));
} }
private void onPublisherClosed(long userId) { private void onPublisherClosed(long userId, Long liveId) {
this.destroySession(userId, nodeId).whenComplete((result, ex) -> { this.destroySession(userId, nodeId).whenComplete((result, ex) -> {
localLiveSessions.remove(liveId);
if (ex != null) { if (ex != null) {
LOG.error("Failed to close the session for user {} after it was closed itself", userId); LOG.error("Failed to close the session for user {} after it was closed itself", userId);
} else { } else {