aboutsummaryrefslogtreecommitdiff
path: root/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-10-10 11:40:19 +0300
committerGravatar Vitaly Takmazov2017-10-10 11:40:19 +0300
commit0ad4b98456e5de96a9fea6e128a20a4624c72c6a (patch)
treeca91167b0c525d6083838970bca9637386c60826 /juick-xmpp/src/main/java/com/juick/components/XMPPServer.java
parent119966076222901579efa4b5378e227baff35de9 (diff)
xmpp: make jids inactive in case of socket exceptions
Diffstat (limited to 'juick-xmpp/src/main/java/com/juick/components/XMPPServer.java')
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/XMPPServer.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java b/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java
index 29d57d53..de9476a8 100644
--- a/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java
+++ b/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java
@@ -18,6 +18,7 @@
package com.juick.components;
import com.juick.components.s2s.*;
+import com.juick.service.UserService;
import com.juick.xmpp.extensions.JuickMessage;
import com.juick.xmpp.extensions.StreamError;
import org.slf4j.Logger;
@@ -37,9 +38,7 @@ import javax.xml.bind.Unmarshaller;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import java.io.*;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketException;
+import java.net.*;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.SecureRandom;
@@ -100,6 +99,8 @@ public class XMPPServer implements ConnectionListener, AutoCloseable {
@Inject
private BasicXmppSession session;
+ @Inject
+ private UserService userService;
@PostConstruct
public void init() throws KeyStoreException {
@@ -252,6 +253,12 @@ public class XMPPServer implements ConnectionListener, AutoCloseable {
addConnectionOut(socket, streamServerDialback);
streamServerDialback.addChildParser(new JuickMessage());
streamServerDialback.connect();
+ } catch (UnknownHostException | ConnectException e) {
+ userService.getActiveJIDs().stream().filter(j -> Jid.of(j).getDomain().equals(to))
+ .forEach(j -> {
+ userService.setActiveStatusForJID(j, UserService.ActiveStatus.Inactive);
+ logger.info("{} is inactive now", j);
+ });
} catch (Exception e) {
logger.error("s2s out error", e);
}