diff options
author | Vitaly Takmazov | 2016-10-24 12:56:20 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-10-24 13:13:31 +0300 |
commit | 44806446ccb0fc845ab289b545e5a8bcb55925dc (patch) | |
tree | e915583efea79a6544679ca0082f670d356be625 /juick-ws/src/main/java | |
parent | 5e0c202f6d29d1146b3b6b643fc1c7fd477bf6ac (diff) |
s2s: fix router
Diffstat (limited to 'juick-ws/src/main/java')
3 files changed, 15 insertions, 26 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; } diff --git a/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java b/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java index 495a3c91..3b75028e 100644 --- a/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java +++ b/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java @@ -103,7 +103,6 @@ public class WebsocketConfiguration extends WebMvcConfigurationSupport implement @Bean public XMPPComponent xmpp() { XMPPComponent xmpp = new XMPPComponent(env); - xmpp.init(); return xmpp; } @Bean diff --git a/juick-ws/src/main/java/com/juick/ws/s2s/JuickBot.java b/juick-ws/src/main/java/com/juick/ws/s2s/JuickBot.java index f5500242..14c63b59 100644 --- a/juick-ws/src/main/java/com/juick/ws/s2s/JuickBot.java +++ b/juick-ws/src/main/java/com/juick/ws/s2s/JuickBot.java @@ -218,7 +218,7 @@ public class JuickBot { xmpp.sendOut(reply); } - return true; + return false; } private static Pattern regexPM = Pattern.compile("^\\@(\\S+)\\s+([\\s\\S]+)$"); |