From c88195104f12a4d28a89a532c45fbb25839270c1 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 11 Oct 2018 21:28:48 +0300 Subject: SSE: send service message on connect to prevent Safari buffering --- juick-server/src/main/java/com/juick/server/api/Service.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'juick-server/src/main/java/com/juick') 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)); -- cgit v1.2.3