From 2c7fb63528ee2544d2c9f6f32047c9178618331b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 12 May 2016 22:58:07 +0300 Subject: forgot to connect --- src/main/java/com/juick/api/TelegramBotHook.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/main') 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; @@ -40,6 +38,10 @@ public class TelegramBotHook { try { ws = new WebSocketFactory().createSocket("wss://ws.juick.com/_all"); ws.addListener(new WebSocketAdapter() { + @Override + public void onConnected(WebSocket websocket, Map> headers) { + logger.info("ws connected"); + } @Override public void onTextMessage(WebSocket websocket, String text) throws Exception { super.onTextMessage(websocket, 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); } } -- cgit v1.2.3