aboutsummaryrefslogtreecommitdiff
path: root/juick-server-xmpp/src/main/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-04-09 14:21:09 +0300
committerGravatar Vitaly Takmazov2018-04-09 14:21:09 +0300
commitce3295d247c62a8ba1f0b31c4ddba0fed466bb3e (patch)
treea14cacedd3be271a41dbb565ed2458115408d4e7 /juick-server-xmpp/src/main/java/com/juick
parent227f767dbb34f9980501771b2159ece213599bfb (diff)
server: xmpp fixes
Diffstat (limited to 'juick-server-xmpp/src/main/java/com/juick')
-rw-r--r--juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java18
-rw-r--r--juick-server-xmpp/src/main/java/com/juick/server/XMPPServer.java16
2 files changed, 11 insertions, 23 deletions
diff --git a/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java b/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java
index 7cdb7fcc..ab0271b0 100644
--- a/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java
+++ b/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java
@@ -574,7 +574,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
}
}
- public void incomingMessage(Message msg) throws Exception {
+ public void incomingMessage(Message msg) {
User user_from;
user_from = userService.getUserByJID(msg.getFrom().asBareJid().toEscapedString());
if (user_from == null) {
@@ -625,8 +625,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
}
}
}
- private void incomingMessageJuick(User user_from, Jid from, String command, @Nonnull URI attachment)
- throws Exception {
+ private void incomingMessageJuick(User user_from, Jid from, String command, @Nonnull URI attachment) {
if (StringUtils.isBlank(command) && attachment.toString().isEmpty()) {
return;
}
@@ -638,10 +637,15 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
command = command.substring(3);
}
- CommandResult result = commandsManager.processCommand(user_from, command.trim(), attachment);
- if (StringUtils.isNotBlank(result.getText())) {
- sendReply(from, result.getText());
+ try {
+ CommandResult result = commandsManager.processCommand(user_from, command.trim(), attachment);
+ if (StringUtils.isNotBlank(result.getText())) {
+ sendReply(from, result.getText());
+ }
+ } catch (Exception e) {
+ sendReply(from, "Error processing command");
}
+
}
@Override
@@ -653,7 +657,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
}
} else if (xmlValue instanceof Message) {
Message msg = (Message) xmlValue;
- router.send(msg);
+ incomingMessage(msg);
} else if (xmlValue instanceof IQ) {
IQ iq = (IQ) xmlValue;
router.send(iq);
diff --git a/juick-server-xmpp/src/main/java/com/juick/server/XMPPServer.java b/juick-server-xmpp/src/main/java/com/juick/server/XMPPServer.java
index 31d338df..c14fdd18 100644
--- a/juick-server-xmpp/src/main/java/com/juick/server/XMPPServer.java
+++ b/juick-server-xmpp/src/main/java/com/juick/server/XMPPServer.java
@@ -196,22 +196,6 @@ public class XMPPServer implements ConnectionListener, AutoCloseable {
return inConnections.stream().filter(c -> c.streamID != null && c.streamID.equals(streamID)).findFirst();
}
- public void sendOut(Stanza s) {
- try {
- StringWriter stanzaWriter = new StringWriter();
- XMLStreamWriter xmppStreamWriter = XmppUtils.createXmppStreamWriter(
- session.getConfiguration().getXmlOutputFactory().createXMLStreamWriter(stanzaWriter));
- session.createMarshaller().marshal(s, xmppStreamWriter);
- xmppStreamWriter.flush();
- xmppStreamWriter.close();
- String xml = stanzaWriter.toString();
- logger.debug("s2s (out): {}", xml);
- sendOut(Jid.of(s.getTo().getDomain()), xml);
- } catch (XMLStreamException | JAXBException e1) {
- logger.info("jaxb exception", e1);
- }
- }
-
public void sendOut(Jid hostname, String xml) {
boolean haveAnyConn = false;