Changeset

97:ad6006779416

verse.client: Update stream:close() to use base stream:close(), and not add an XMPP-specific :close() to the base stream
author Matthew Wild <mwild1@gmail.com>
date Sat, 21 Aug 2010 14:37:10 +0100
parents 96:f0aec10023aa
children 98:1dccff7df2d5
files client.lua
diffstat 1 files changed, 8 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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;