# HG changeset patch # User Matthew Wild # Date 1248804929 -3600 # Node ID c6e175a0d83b96f3488be683bd945f998c27f369 # Parent 80ea744f264329d2ba2b1e2c5f59b2edb9e11a81 xmpp{client,server,component]_listener: Open stream if sending an error and it isn't already open. Fixes #120 diff -r 80ea744f2643 -r c6e175a0d83b net/xmppclient_listener.lua --- 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(""); + 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, is: %s", reason); diff -r 80ea744f2643 -r c6e175a0d83b net/xmppcomponent_listener.lua --- a/net/xmppcomponent_listener.lua Tue Jul 28 18:47:59 2009 +0100 +++ b/net/xmppcomponent_listener.lua Tue Jul 28 19:15:29 2009 +0100 @@ -87,9 +87,14 @@ --- Closing a component connection 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(""); + 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 component, is: %s", reason); diff -r 80ea744f2643 -r c6e175a0d83b net/xmppserver_listener.lua --- a/net/xmppserver_listener.lua Tue Jul 28 18:47:59 2009 +0100 +++ b/net/xmppserver_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.sends2s(""); + session.sends2s(st.stanza("stream:stream", default_stream_attr):top_tag()); + end if reason then if type(reason) == "string" then -- assume stream error log("info", "Disconnecting %s[%s], is: %s", session.host or "(unknown host)", session.type, reason);