util/xmppstream.lua
changeset 6063 e626ee2fe106
parent 6054 7a5ddbaf758d
child 6084 3c02a9ed399e
--- 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);