diff options
Diffstat (limited to 'juick-api/src/main/java/com/juick/api/TelegramBotManager.java')
-rw-r--r-- | juick-api/src/main/java/com/juick/api/TelegramBotManager.java | 5 |
1 files changed, 5 insertions, 0 deletions
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 b9154424..44f0fdc6 100644 --- a/juick-api/src/main/java/com/juick/api/TelegramBotManager.java +++ b/juick-api/src/main/java/com/juick/api/TelegramBotManager.java @@ -18,6 +18,7 @@ package com.juick.api; import com.fasterxml.jackson.databind.ObjectMapper; +import com.juick.server.component.DisconnectedEvent; import com.juick.service.MessagesService; import com.juick.service.SubscriptionService; import com.juick.service.TelegramService; @@ -33,6 +34,7 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.springframework.web.socket.CloseStatus; @@ -68,6 +70,8 @@ public class TelegramBotManager extends TextWebSocketHandler { private SubscriptionService subscriptionService; @Inject private ObjectMapper jsonMapper; + @Inject + private ApplicationEventPublisher applicationEventPublisher; private WebSocketSession session; @@ -99,6 +103,7 @@ public class TelegramBotManager extends TextWebSocketHandler { @Override public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception { logger.info("WebSocket disconnected with code {}: {}", status.getCode(), status.getReason()); + applicationEventPublisher.publishEvent(new DisconnectedEvent(this)); } @Scheduled(fixedRate = 30000) |