aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-10-11 21:28:48 +0300
committerGravatar Vitaly Takmazov2018-10-11 21:28:57 +0300
commitc88195104f12a4d28a89a532c45fbb25839270c1 (patch)
treedd85306fdb46ef4acab30be943cd0147db299626 /juick-server/src/main/java
parent6a41285e43e6b78433edffa3f9a2106cda6133c0 (diff)
SSE: send service message on connect to prevent Safari buffering
Diffstat (limited to 'juick-server/src/main/java')
-rw-r--r--juick-server/src/main/java/com/juick/server/api/Service.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/juick-server/src/main/java/com/juick/server/api/Service.java b/juick-server/src/main/java/com/juick/server/api/Service.java
index 2351c076..ecfc6957 100644
--- a/juick-server/src/main/java/com/juick/server/api/Service.java
+++ b/juick-server/src/main/java/com/juick/server/api/Service.java
@@ -1,5 +1,6 @@
package com.juick.server.api;
+import com.juick.Message;
import com.juick.User;
import com.juick.server.CommandsManager;
import com.juick.server.EmailManager;
@@ -137,9 +138,12 @@ public class Service {
}
}
@GetMapping("/api/events")
- public SseEmitter handle() {
+ public SseEmitter handle() throws IOException {
logger.info("{} connected", UserUtils.getCurrentUser().getName());
SseEmitter emitter = new SseEmitter(86400000L);
+ Message service = new Message();
+ service.setService(true);
+ emitter.send(service);
serverManager.getSessions().add(new ServerManager.EventSession(UserUtils.getCurrentUser(), emitter));
emitter.onCompletion(() -> serverManager.getSessions().remove(emitter));