diff options
Diffstat (limited to 'juick-xmpp/src/main/java/com/juick/components/s2s')
-rw-r--r-- | juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionRouter.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionRouter.java b/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionRouter.java index b28298a2..37d3c59f 100644 --- a/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionRouter.java +++ b/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionRouter.java @@ -29,13 +29,14 @@ import java.util.concurrent.TimeUnit; /** * @author ugnich */ -public class ConnectionRouter extends Connection implements Runnable { +public class ConnectionRouter extends Connection implements Runnable, AutoCloseable { private static final Logger logger = LoggerFactory.getLogger(ConnectionRouter.class); private String componentName; private int componentPort; private String password; + private Execution execution; public ConnectionRouter(XMPPServer s2s, String componentName, int componentPort, String password) throws Exception { super(s2s); @@ -51,7 +52,7 @@ public class ConnectionRouter extends Connection implements Runnable { .withBackoff(1, 30, TimeUnit.SECONDS) .withJitter(0.1) .retryOn(IOException.class, XmlPullParserException.class); - Execution execution = new Execution(retryPolicy); + execution = new Execution(retryPolicy); xmpp.service.submit(() -> { while (!execution.isComplete()) { try { @@ -109,6 +110,9 @@ public class ConnectionRouter extends Connection implements Runnable { } } } + } else if (tag.equals("iq") || tag.equals("presence")) { + String xml = XmlUtils.parseToString(parser, true); + logger.info("stream router (stanza): {}", xml); } } else if (jid.Host.endsWith(xmpp.HOSTNAME) && (jid.Host.equals(xmpp.HOSTNAME) || jid.Host.endsWith("." + xmpp.HOSTNAME))) { String xml = XmlUtils.parseToString(parser, true); @@ -129,6 +133,9 @@ public class ConnectionRouter extends Connection implements Runnable { } logger.warn("stream router finished"); + } catch (InterruptedException ex) { + logger.info("shutting down"); + execution.complete(); } catch (Exception e) { logger.warn("router error, reconnection ", e); execution.recordFailure(e); @@ -260,4 +267,9 @@ public class ConnectionRouter extends Connection implements Runnable { } } } + + @Override + public void close() throws Exception { + execution.complete(); + } } |