component.lua

changeset 161
b177bcea2006
parent 150
728cc7f2f0c2
child 282
52b971d9ebc3
--- a/component.lua	Sun Dec 05 01:06:29 2010 +0000
+++ b/component.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";
 local xmlns_component = "jabber:component:accept";
@@ -43,12 +43,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
 
@@ -57,7 +57,7 @@
 	self.username, self.host, self.resource = jid_split(jid);
 	
 	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