aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-05-12 22:58:07 +0300
committerGravatar Vitaly Takmazov2016-05-12 22:58:07 +0300
commit2c7fb63528ee2544d2c9f6f32047c9178618331b (patch)
tree71c50b53b148e3e83487125ae74ec427f94145ef /src/main/java/com/juick
parenta24822ad17cc4be9ccaa01badfd17f193867e457 (diff)
forgot to connect
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r--src/main/java/com/juick/api/TelegramBotHook.java13
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);
}
}