aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-06-27 14:46:09 +0300
committerGravatar Vitaly Takmazov2016-06-27 14:46:09 +0300
commit78caa7f9617ce2eb07cabd751a9d1594fe41976b (patch)
tree1ddf6c385dd4fdc9c5d6327bb37eac28709df98b /src
parent3983a459e1756d21cdb2ca3811a99800ae1bf3b1 (diff)
reconnect router
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java9
1 files changed, 7 insertions, 2 deletions
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();
}
}