Diff

net/xmppclient_listener.lua @ 1617:c6e175a0d83b

xmpp{client,server,component]_listener: Open stream if sending an error and it isn't already open. Fixes #120
author Matthew Wild <mwild1@gmail.com>
date Tue, 28 Jul 2009 19:15:29 +0100
parent 1523:841d61be198f
child 1618:ba2a92230b77
line wrap: on
line diff
--- a/net/xmppclient_listener.lua	Tue Jul 28 18:47:59 2009 +0100
+++ b/net/xmppclient_listener.lua	Tue Jul 28 19:15:29 2009 +0100
@@ -69,9 +69,14 @@
 
 
 local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'};
+local default_stream_attr = { ["xmlns:stream"] = stream_callbacks.stream_tag:gsub("%|[^|]+$", ""), xmlns = stream_callbacks.default_ns, version = "1.0", id = "" };
 local function session_close(session, reason)
 	local log = session.log or log;
 	if session.conn then
+		if session.notopen then
+			session.send("<?xml version='1.0'?>");
+			session.send(st.stanza("stream:stream", default_stream_attr):top_tag());
+		end
 		if reason then
 			if type(reason) == "string" then -- assume stream error
 				log("info", "Disconnecting client, <stream:error> is: %s", reason);