From 9a72efea7c78c7c16a80a411e001949949328b12 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 2 Nov 2017 14:43:00 +0300 Subject: api: send disconnected event when ping --- juick-api/src/main/java/com/juick/api/TelegramBotManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'juick-api') diff --git a/juick-api/src/main/java/com/juick/api/TelegramBotManager.java b/juick-api/src/main/java/com/juick/api/TelegramBotManager.java index 44f0fdc6..f992d726 100644 --- a/juick-api/src/main/java/com/juick/api/TelegramBotManager.java +++ b/juick-api/src/main/java/com/juick/api/TelegramBotManager.java @@ -108,9 +108,11 @@ public class TelegramBotManager extends TextWebSocketHandler { @Scheduled(fixedRate = 30000) public void ping() throws IOException { - if (session != null) { + if (session != null && session.isOpen()) { logger.debug("Sending WebSocket ping"); session.sendMessage(new PingMessage()); + } else { + applicationEventPublisher.publishEvent(new DisconnectedEvent(this)); } } -- cgit v1.2.3