aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-07-17 15:19:28 +0300
committerGravatar Vitaly Takmazov2018-07-17 15:19:28 +0300
commit3dc905264185b1032842530305d012421c796363 (patch)
tree7a0da2d0e4e6f8f1db8e0d833b1c70e9b816688a /juick-server/src/main
parent44e40c92408dc0003cf82bb82ac12fdfa56ca361 (diff)
XMPP: start broadcasting only after component authentication
Diffstat (limited to 'juick-server/src/main')
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPConnection.java11
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);
}