Changeset

37:0ccd523e110a

verse.client: Don't hook the stanza event every time a stanza comes in :)
author Matthew Wild <mwild1@gmail.com>
date Mon, 21 Dec 2009 14:25:44 +0000
parents 36:fc2cd2f36cdd
children 38:c40cc28ac7df
files client.lua
diffstat 1 files changed, 17 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/client.lua	Sun Dec 20 22:07:20 2009 +0000
+++ b/client.lua	Mon Dec 21 14:25:44 2009 +0000
@@ -33,23 +33,6 @@
 	elseif stanza.attr.xmlns then
 		return stream:event("stream/"..stanza.attr.xmlns, stanza);
 	end
-	
-	stream:hook("stanza", function (stanza)
-		if stanza.attr.xmlns == nil or stanza.attr.xmlns == "jabber:client" then
-			if stanza.name == "iq" and (stanza.attr.type == "get" or stanza.attr.type == "set") then
-				local xmlns = stanza.tags[1] and stanza.tags[1].attr.xmlns;
-				if xmlns then
-					ret = stream:event("iq/"..xmlns, stanza);
-					if not ret then
-						ret = stream:event("iq", stanza);
-					end
-				end
-			else
-				ret = stream:event(stanza.name, stanza);
-			end
-		end
-		return ret;
-	end, -1);
 
 	return stream:event("stanza", stanza);
 end
@@ -89,6 +72,23 @@
 		end
 	end);
 	
+	self:hook("stanza", function (stanza)
+		if stanza.attr.xmlns == nil or stanza.attr.xmlns == "jabber:client" then
+			if stanza.name == "iq" and (stanza.attr.type == "get" or stanza.attr.type == "set") then
+				local xmlns = stanza.tags[1] and stanza.tags[1].attr.xmlns;
+				if xmlns then
+					ret = self:event("iq/"..xmlns, stanza);
+					if not ret then
+						ret = self:event("iq", stanza);
+					end
+				end
+			else
+				ret = self:event(stanza.name, stanza);
+			end
+		end
+		return ret;
+	end, -1);
+
 	-- Initialise connection
 	self:connect(self.connect_host or self.host, self.connect_port or 5222);
 	--reset_stream(self);