client.lua

changeset 97
ad6006779416
parent 83
8221f3c25fd4
child 137
e4b9d3c5332c
--- a/client.lua	Sat Aug 21 14:36:21 2010 +0100
+++ b/client.lua	Sat Aug 21 14:37:10 2010 +0100
@@ -108,6 +108,14 @@
 	self:hook("session-success", stream_ready, -1)
 	self:hook("bind-success", stream_ready, -1);
 
+	local _base_close = self.close;
+	function self:close(reason)
+		if not self.notopen then
+			self:send("</stream:stream>");
+		end
+		return _base_close(self);
+	end
+	
 	-- Initialise connection
 	self:connect(self.connect_host or self.host, self.connect_port or 5222);
 	self:reopen();
@@ -119,15 +127,6 @@
 		xmlns = "jabber:client", version = "1.0" }):top_tag());
 end
 
-function stream:close(reason)
-	if not self.notopen then
-		self:send("</stream:stream>");
-	end
-	local on_disconnect = self.conn.disconnect();
-	self.conn:close();
-	on_disconnect(conn, reason);
-end
-
 function stream:send_iq(iq, callback)
 	local id = self:new_id();
 	self.tracked_iqs[id] = callback;

mercurial