client.lua

changeset 161
b177bcea2006
parent 137
e4b9d3c5332c
child 166
3499b4ea3277
--- a/client.lua	Sun Dec 05 01:06:29 2010 +0000
+++ b/client.lua	Tue Dec 14 16:04:29 2010 +0000
@@ -10,7 +10,7 @@
 verse.message, verse.presence, verse.iq, verse.stanza, verse.reply, verse.error_reply =
 	st.message, st.presence, st.iq, st.stanza, st.reply, st.error_reply;
 
-local init_xmlhandlers = require "core.xmlhandlers";
+local new_xmpp_stream = require "util.xmppstream".new;
 
 local xmlns_stream = "http://etherx.jabber.org/streams";
 
@@ -46,12 +46,12 @@
 end
 
 function stream:reset()
-	-- Reset stream
-	local parser = lxp.new(init_xmlhandlers(self, stream_callbacks), "\1");
-	self.parser = parser;
-	
+	if self.stream then
+		self.stream:reset();
+	else
+		self.stream = new_xmpp_stream(self, stream_callbacks);
+	end
 	self.notopen = true;
-	
 	return true;
 end
 
@@ -66,7 +66,7 @@
 	self:add_plugin("session");
 	
 	function self.data(conn, data)
-		local ok, err = self.parser:parse(data);
+		local ok, err = self.stream:feed(data);
 		if ok then return; end
 		stream:debug("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "));
 		stream:close("xml-not-well-formed");

mercurial