From d77b21dcf62c3e8d63615d5ef5acaaaf2614736d Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 12 May 2016 23:32:50 +0300 Subject: add ping --- src/main/java/com/juick/api/TelegramBotHook.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/main/java/com/juick/api') diff --git a/src/main/java/com/juick/api/TelegramBotHook.java b/src/main/java/com/juick/api/TelegramBotHook.java index 83eea314..2d64b83e 100644 --- a/src/main/java/com/juick/api/TelegramBotHook.java +++ b/src/main/java/com/juick/api/TelegramBotHook.java @@ -37,7 +37,15 @@ public class TelegramBotHook { bot.setWebhook("https://api.juick.com/tlgmbtwbhk"); try { ws = new WebSocketFactory().createSocket("wss://ws.juick.com/_all"); + ws.addHeader("Origin", "ws.juick.com"); + ws.addHeader("Host", "ws.juick.com"); //TODO: remove from server + ws.setPingInterval(60 * 1000); ws.addListener(new WebSocketAdapter() { + @Override + public void onDisconnected(WebSocket websocket, WebSocketFrame serverCloseFrame, WebSocketFrame clientCloseFrame, boolean closedByServer) throws Exception { + logger.info("ws disconnected"); + } + @Override public void onConnected(WebSocket websocket, Map> headers) { logger.info("ws connected"); -- cgit v1.2.3