diff options
author | 2016-10-24 12:56:20 +0300 | |
---|---|---|
committer | 2016-10-24 13:13:31 +0300 | |
commit | 44806446ccb0fc845ab289b545e5a8bcb55925dc (patch) | |
tree | e915583efea79a6544679ca0082f670d356be625 /juick-ws/src/main/java/com/juick/ws/components/XMPPComponent.java | |
parent | 5e0c202f6d29d1146b3b6b643fc1c7fd477bf6ac (diff) |
s2s: fix router
Diffstat (limited to 'juick-ws/src/main/java/com/juick/ws/components/XMPPComponent.java')
-rw-r--r-- | juick-ws/src/main/java/com/juick/ws/components/XMPPComponent.java | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/juick-ws/src/main/java/com/juick/ws/components/XMPPComponent.java b/juick-ws/src/main/java/com/juick/ws/components/XMPPComponent.java index 6ce2482d..1db8c604 100644 --- a/juick-ws/src/main/java/com/juick/ws/components/XMPPComponent.java +++ b/juick-ws/src/main/java/com/juick/ws/components/XMPPComponent.java @@ -39,7 +39,7 @@ import java.util.logging.Logger; * @author ugnich */ @Component -public class XMPPComponent implements JuickComponent, DisposableBean, Stream.StreamListener, +public class XMPPComponent implements DisposableBean, Stream.StreamListener, Message.MessageListener, Iq.IqListener, Presence.PresenceListener { private static final Logger logger = Logger.getLogger(XMPPComponent.class.getName()); @@ -82,18 +82,19 @@ public class XMPPComponent implements JuickComponent, DisposableBean, Stream.Str childParsers.put(JuickMessage.XMLNS, new JuickMessage()); - Socket routerSocket = null; - try { - routerSocket = new Socket("localhost", componentPort); - setRouter(new StreamComponent(new JID("s2s"), routerSocket.getInputStream(), routerSocket.getOutputStream(), env.getProperty("xmpp_password"))); - getRouter().addChildParser(new JuickMessage()); - getRouter().addListener((Stream.StreamListener) this); - getRouter().addListener((Message.MessageListener) this); - getRouter().addListener((Iq.IqListener) this); - - } catch (IOException e) { - logger.log(Level.SEVERE, "router error", e); - } + executorService.submit(() -> { + try { + Socket routerSocket = new Socket("localhost", componentPort); + router = new StreamComponent(new JID("s2s"), routerSocket.getInputStream(), routerSocket.getOutputStream(), env.getProperty("xmpp_password")); + router.addChildParser(new JuickMessage()); + router.addListener((Stream.StreamListener) this); + router.addListener((Message.MessageListener) this); + router.addListener((Iq.IqListener) this); + router.startParsing(); + } catch (IOException e) { + logger.log(Level.SEVERE, "router error", e); + } + }); executorService.submit(() -> { final ServerSocket listener = new ServerSocket(s2sPort); logger.info("s2s listener ready"); @@ -231,13 +232,6 @@ public class XMPPComponent implements JuickComponent, DisposableBean, Stream.Str } } - @Async - @Override - public void init() { - getRouter().startParsing(); - } - - @Override public void destroy() { @@ -457,10 +451,6 @@ public class XMPPComponent implements JuickComponent, DisposableBean, Stream.Str return router; } - public void setRouter(StreamComponent router) { - this.router = router; - } - public List<ConnectionIn> getInConnections() { return inConnections; } |