aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/xmpp/ping/PingPacketHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/xmpp/ping/PingPacketHandler.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/ping/PingPacketHandler.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/ping/PingPacketHandler.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/ping/PingPacketHandler.java
new file mode 100644
index 00000000..14e8f57c
--- /dev/null
+++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/ping/PingPacketHandler.java
@@ -0,0 +1,22 @@
+package de.thedevstack.conversationsplus.xmpp.ping;
+
+import de.thedevstack.conversationsplus.entities.Account;
+import de.thedevstack.conversationsplus.utils.XmppSendUtil;
+import de.thedevstack.conversationsplus.xmpp.IqPacketHandler;
+import de.thedevstack.conversationsplus.xmpp.exceptions.IqPacketErrorException;
+import de.thedevstack.conversationsplus.xmpp.exceptions.NotAllowedIqException;
+import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket;
+import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacketGenerator;
+
+/**
+ */
+public class PingPacketHandler implements IqPacketHandler {
+ @Override
+ public void handleIqPacket(Account account, IqPacket packet) throws IqPacketErrorException {
+ if (packet.getType() == IqPacket.TYPE.GET) {
+ XmppSendUtil.sendIqPacket(account, IqPacketGenerator.generateIqResultResponse(packet));
+ } else {
+ throw new NotAllowedIqException(packet, "only type=get allowed for processing an XMPP Ping (XEP-0199)");
+ }
+ }
+}