Changeset

3706:b758e4ad30a0

xmppcomponent_listener: Switch to util.xmppstream from xmlhandlers
author Matthew Wild <mwild1@gmail.com>
date Tue, 07 Dec 2010 18:18:11 +0000
parents 3705:ddbac8737c2d
children 3707:79f62694d36e
files net/xmppcomponent_listener.lua
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/net/xmppcomponent_listener.lua	Tue Dec 07 22:55:28 2010 +0500
+++ b/net/xmppcomponent_listener.lua	Tue Dec 07 18:18:11 2010 +0000
@@ -19,7 +19,7 @@
 local jid_split = require "util.jid".split;
 local sha1 = require "util.hashes".sha1;
 local st = require "util.stanza";
-local init_xmlhandlers = require "core.xmlhandlers";
+local new_xmpp_stream = require "util.xmppstream".new;
 
 local sessions = {};
 
@@ -29,7 +29,7 @@
 
 local xmlns_component = 'jabber:component:accept';
 
---- Callbacks/data for xmlhandlers to handle streams for us ---
+--- Callbacks/data for xmppstream to handle streams for us ---
 
 local stream_callbacks = { default_ns = xmlns_component };
 
@@ -177,13 +177,18 @@
 		
 		session.log("info", "Incoming Jabber component connection");
 		
-		local parser = lxp.new(init_xmlhandlers(session, stream_callbacks), "\1");
-		session.parser = parser;
+		local stream = new_xmpp_stream(session, stream_callbacks);
+		session.stream = stream;
 		
 		session.notopen = true;
 		
+		function session.reset_stream()
+			session.notopen = true;
+			session.stream:reset();
+		end
+	
 		function session.data(conn, data)
-			local ok, err = parser:parse(data);
+			local ok, err = stream:feed(data);
 			if ok then return; end
 			log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "):gsub("[%z\1-\31]", "_"));
 			session:close("not-well-formed");