Diff

net/xmppclient_listener.lua @ 331:830fd67f9378

Quite some changes, to: - Small logging fix for s2smanager - Send a stream error if an incoming s2s connection is to an unrecognised hostname (fixes #11) - init_xmlhandlers now takes a table of callbacks (includes changes to net/xmpp*_listener for this) - Move sending of unavailable presence to where it should be, sessionmanager.destroy_session - Fix sending of stream errors to wrong connection
author Matthew Wild <mwild1@gmail.com>
date Tue, 18 Nov 2008 17:52:33 +0000
parent 330:d9d4c1de16ce
child 333:8d15b073fdbe
line wrap: on
line diff
--- a/net/xmppclient_listener.lua	Tue Nov 18 14:42:45 2008 +0000
+++ b/net/xmppclient_listener.lua	Tue Nov 18 17:52:33 2008 +0000
@@ -13,8 +13,11 @@
 local format = string.format;
 local sm_new_session, sm_destroy_session = sessionmanager.new_session, sessionmanager.destroy_session; --import("core.sessionmanager", "new_session", "destroy_session");
 local sm_streamopened = sessionmanager.streamopened;
+local sm_streamclosed = sessionmanager.streamclosed;
 local st = stanza;
 
+local stream_callbacks = { streamopened = sm_streamopened, streamclosed = sm_streamclosed };
+
 local sessions = {};
 local xmppclient = { default_port = 5222 };
 
@@ -22,7 +25,7 @@
 
 local function session_reset_stream(session)
 	-- Reset stream
-		local parser = lxp.new(init_xmlhandlers(session, sm_streamopened), "|");
+		local parser = lxp.new(init_xmlhandlers(session, stream_callbacks), "|");
 		session.parser = parser;
 		
 		session.notopen = true;
@@ -107,12 +110,6 @@
 function xmppclient.disconnect(conn, err)
 	local session = sessions[conn];
 	if session then
-		if session.presence and session.presence.attr.type ~= "unavailable" then
-			local pres = st.presence{ type = "unavailable" };
-			if err == "closed" then err = "connection closed"; end
-			pres:tag("status"):text("Disconnected: "..err);
-			session.stanza_dispatch(pres);
-		end
 		(session.log or log)("info", "Client disconnected: %s", err);
 		sm_destroy_session(session);
 		sessions[conn]  = nil;