Diff

util/xmppstream.lua @ 6063:e626ee2fe106

mod_c2s, mod_s2s, mod_component, util.xmppstream: Move all session:open_stream() functions to util.xmppstream
author Kim Alvefur <zash@zash.se>
date Thu, 10 Apr 2014 13:13:07 +0200
parent 6054:7a5ddbaf758d
child 6084:3c02a9ed399e
line wrap: on
line diff
--- a/util/xmppstream.lua	Thu Apr 10 00:24:29 2014 +0200
+++ b/util/xmppstream.lua	Thu Apr 10 13:13:07 2014 +0200
@@ -241,6 +241,22 @@
 	local parser = new_parser(handlers, ns_separator, false);
 	local parse = parser.parse;
 
+	function session.open_stream(session, from, to)
+		local send = session.sends2s or session.send;
+
+		local attr = {
+			["xmlns:stream"] = "http://etherx.jabber.org/streams",
+			["xml:lang"] = "en",
+			xmlns = stream_callbacks.default_ns,
+			version = session.version and (session.version > 0 and "1.0" or nil),
+			id = session.streamid or "",
+			from = from or session.host, to = to,
+		};
+		send("<?xml version='1.0'?>");
+		send(st.stanza("stream:stream", attr):top_tag());
+		return true;
+	end
+
 	return {
 		reset = function ()
 			parser = new_parser(handlers, ns_separator, false);