Created
July 1, 2012 12:20
-
-
Save everplays/3028262 to your computer and use it in GitHub Desktop.
implemented ping protocol extension for hypervisor/vm in archipel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From ab1055cc3689e5f3a634654028ec14d3535fda6f Mon Sep 17 00:00:00 2001 | |
From: "behrooz shabani (everplays)" <behrooz@rock.com> | |
Date: Sun, 1 Jul 2012 16:48:09 +0430 | |
Subject: [PATCH] implemented ping protocol extension for hypervisor/vm | |
--- | |
.../archipel-core/archipelcore/archipelEntity.py | 17 +++++++++++++++++ | |
1 file changed, 17 insertions(+) | |
diff --git a/ArchipelAgent/archipel-core/archipelcore/archipelEntity.py b/ArchipelAgent/archipel-core/archipelcore/archipelEntity.py | |
index 1adcb35..af92745 100755 | |
--- a/ArchipelAgent/archipel-core/archipelcore/archipelEntity.py | |
+++ b/ArchipelAgent/archipel-core/archipelcore/archipelEntity.py | |
@@ -478,6 +478,7 @@ class TNArchipelEntity (object): | |
self.xmppclient.RegisterHandler('message', self.process_message, typ="chat") | |
self.xmppclient.RegisterHandler('iq', self.process_permission_iq, ns=ARCHIPEL_NS_PERMISSIONS) | |
self.xmppclient.RegisterHandler('iq', self.process_subscription_iq, ns=ARCHIPEL_NS_SUBSCRIPTION) | |
+ self.xmppclient.RegisterHandler('iq', self.process_ping_iq, typ="get") | |
for plugin in self.plugins: | |
self.log.info("PLUGIN: registering stanza handler for plugin %s" % plugin["info"]["identifier"]) | |
plugin["plugin"].register_handlers() | |
@@ -499,6 +500,7 @@ class TNArchipelEntity (object): | |
self.xmppclient.UnregisterHandler('message', self.process_message, typ="chat") | |
self.xmppclient.UnregisterHandler('iq', self.process_permission_iq, ns=ARCHIPEL_NS_PERMISSIONS) | |
self.xmppclient.UnregisterHandler('iq', self.process_subscription_iq, ns=ARCHIPEL_NS_SUBSCRIPTION) | |
+ self.xmppclient.UnregisterHandler('iq', self.process_ping_iq, typ="get") | |
for plugin in self.plugins: | |
self.log.info("PLUGIN: unregistering stanza handler for plugin %s" % plugin["info"]["identifier"]) | |
plugin["plugin"].unregister_handlers() | |
@@ -565,6 +567,21 @@ class TNArchipelEntity (object): | |
conn.send(reply) | |
raise xmpp.protocol.NodeProcessed | |
+ def process_ping_iq(self, conn, iq): | |
+ """ | |
+ check the iq, if we've got a ping then pong it. for more info | |
+ take a look at: http://xmpp.org/extensions/xep-0199.html | |
+ @type conn: xmpp.Dispatcher | |
+ @param conn: the instance of xmpp connection | |
+ @type iq: xmpp.Protocol.Iq | |
+ @param iq: the received IQ stanza | |
+ """ | |
+ ping = iq.getTag('ping') | |
+ if ping != None and ping.getNamespace()=="urn:xmpp:ping": | |
+ rep = iq.buildReply(typ="result") | |
+ conn.send(rep) | |
+ raise xmpp.protocol.NodeProcessed | |
+ | |
def iq_add_subscription(self, iq): | |
""" | |
Add a JID in the entity roster. | |
-- | |
1.7.11 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment