diff options
Diffstat (limited to 'juick-server/src/main')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/XMPPConnection.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/juick-server/src/main/java/com/juick/server/XMPPConnection.java b/juick-server/src/main/java/com/juick/server/XMPPConnection.java index 78995e7a..3f15a2b9 100644 --- a/juick-server/src/main/java/com/juick/server/XMPPConnection.java +++ b/juick-server/src/main/java/com/juick/server/XMPPConnection.java @@ -38,6 +38,7 @@ import org.springframework.context.annotation.DependsOn; import org.springframework.stereotype.Component; import rocks.xmpp.addr.Jid; import rocks.xmpp.core.XmppException; +import rocks.xmpp.core.session.XmppSession; import rocks.xmpp.core.stanza.AbstractIQHandler; import rocks.xmpp.core.stanza.model.*; import rocks.xmpp.core.stanza.model.client.ClientMessage; @@ -124,8 +125,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener { public void init() { logger.info("stream router start connecting to {}", componentPort); xmpp.addStanzaListener(this); - router = ExternalComponent.create(componentName, password, session.getConfiguration(), "localhost", - componentPort); + router = ExternalComponent.create(componentName, password, "localhost", componentPort); EntityCapabilitiesManager entityCapabilitiesManager = router.getManager(EntityCapabilitiesManager.class); entityCapabilitiesManager.setNode("https://juick.com/caps"); MessageDeliveryReceiptsManager messageDeliveryReceiptsManager = router.getManager(MessageDeliveryReceiptsManager.class); @@ -249,13 +249,18 @@ public class XMPPConnection implements StanzaListener, NotificationListener { logger.info("component connected"); } }); + router.addSessionStatusListener(event -> { + if (event.getStatus().equals(XmppSession.Status.AUTHENTICATED)) { + logger.info("Authenticated, broadcasting..."); + broadcastPresence(null); + } + }); router.addInboundPresenceListener(event -> { incomingPresence(event.getPresence()); }); service.submit(() -> { try { router.connect(); - broadcastPresence(null); } catch (XmppException e) { logger.warn("xmpp exception", e); } |