From 78caa7f9617ce2eb07cabd751a9d1594fe41976b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 27 Jun 2016 14:46:09 +0300 Subject: reconnect router --- src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/juick') diff --git a/src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java b/src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java index e68e030f..95878edd 100644 --- a/src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java +++ b/src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java @@ -12,7 +12,6 @@ import com.juick.xmpp.extensions.XOOB; import java.io.IOException; import java.net.Socket; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -25,12 +24,16 @@ public class ConnectionRouter implements Stream.StreamListener, private static final Logger logger = Logger.getLogger(ConnectionRouter.class.getName()); private String componentName; + private String password; Stream router; Socket socket; ConnectionRouter(String componentName, String password) { this.componentName = componentName; - logger.info("STREAM ROUTER START"); + this.password = password; + reconnect(); + } + public void reconnect() { try { socket = new Socket("localhost", 5347); router = new StreamComponent(new JID("s2s"), socket.getInputStream(), socket.getOutputStream(), password); @@ -39,6 +42,7 @@ public class ConnectionRouter implements Stream.StreamListener, router.addListener((Message.MessageListener) this); router.addListener((Iq.IqListener) this); router.startParsing(); + logger.info("STREAM ROUTER START"); } catch (IOException e) { logger.log(Level.SEVERE, "router failed", e); } @@ -240,5 +244,6 @@ public class ConnectionRouter implements Stream.StreamListener, @Override public void onStreamFail(Exception ex) { logger.log(Level.SEVERE, "STREAM ROUTER (FAIL)", ex); + reconnect(); } } -- cgit v1.2.3