diff options
Diffstat (limited to 'src/main/java/com/juick/api/TelegramBotHook.java')
-rw-r--r-- | src/main/java/com/juick/api/TelegramBotHook.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main/java/com/juick/api/TelegramBotHook.java b/src/main/java/com/juick/api/TelegramBotHook.java index b6cd16ab..83eea314 100644 --- a/src/main/java/com/juick/api/TelegramBotHook.java +++ b/src/main/java/com/juick/api/TelegramBotHook.java @@ -1,10 +1,7 @@ package com.juick.api; import com.juick.json.MessageSerializer; -import com.neovisionaries.ws.client.WebSocket; -import com.neovisionaries.ws.client.WebSocketAdapter; -import com.neovisionaries.ws.client.WebSocketFactory; -import com.neovisionaries.ws.client.WebSocketListener; +import com.neovisionaries.ws.client.*; import com.pengrad.telegrambot.BotUtils; import com.pengrad.telegrambot.Callback; import com.pengrad.telegrambot.TelegramBot; @@ -19,6 +16,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -41,6 +39,10 @@ public class TelegramBotHook { ws = new WebSocketFactory().createSocket("wss://ws.juick.com/_all"); ws.addListener(new WebSocketAdapter() { @Override + public void onConnected(WebSocket websocket, Map<String, List<String>> headers) { + logger.info("ws connected"); + } + @Override public void onTextMessage(WebSocket websocket, String text) throws Exception { super.onTextMessage(websocket, text); com.juick.Message jmsg = ms.deserialize(new JSONObject(text)); @@ -60,7 +62,8 @@ public class TelegramBotHook { }); } }); - } catch (IOException e) { + ws.connect(); + } catch (IOException | WebSocketException e) { logger.log(Level.SEVERE, "couldn't create ws connection", e); } } |