Changeset

3424:9e0df614e5d0

util.xmppstream: Add set_session() method to change the session that a stream is associated with
author Matthew Wild <mwild1@gmail.com>
date Mon, 02 Aug 2010 10:21:26 +0100
parents 3423:929fb7b65d2c
children 3425:26751c628207
files util/xmppstream.lua
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/util/xmppstream.lua	Mon Aug 02 10:20:14 2010 +0100
+++ b/util/xmppstream.lua	Mon Aug 02 10:21:26 2010 +0100
@@ -145,7 +145,12 @@
 		stanza, chardata = nil, {};
 	end
 	
-	return xml_handlers, { reset = reset };
+	local function set_session(stream, new_session)
+		session = new_session;
+		log = new_session.log or default_log;
+	end
+	
+	return xml_handlers, { reset = reset, set_session = set_session };
 end
 
 function new(session, stream_callbacks)
@@ -161,7 +166,8 @@
 		end,
 		feed = function (self, data)
 			return parse(parser, data);
-		end
+		end,
+		set_session = meta.set_session;
 	};
 end