plugins/session.lua

changeset 197
7e98cf2c1d8d
parent 78
f4188eff53a7
child 250
a5ac643a7fd6
equal deleted inserted replaced
196:eb9d69d3f0b5 197:7e98cf2c1d8d
1 local st = require "util.stanza";
2 local xmlns_session = "urn:ietf:params:xml:ns:xmpp-session"; 1 local xmlns_session = "urn:ietf:params:xml:ns:xmpp-session";
3 2
4 function verse.plugins.session(stream) 3 function verse.plugins.session(stream)
5 4
6 local function handle_features(features) 5 local function handle_features(features)
7 local session_feature = features:get_child("session", xmlns_session); 6 local session_feature = features:get_child("session", xmlns_session);
8 if session_feature and not session_feature:get_child("optional") then 7 if session_feature and not session_feature:get_child("optional") then
9 local function handle_binding(jid) 8 local function handle_binding(jid)
10 stream:debug("Establishing Session..."); 9 stream:debug("Establishing Session...");
11 stream:send_iq(st.iq({ type = "set" }):tag("session", {xmlns=xmlns_session}), 10 stream:send_iq(verse.iq({ type = "set" }):tag("session", {xmlns=xmlns_session}),
12 function (reply) 11 function (reply)
13 if reply.attr.type == "result" then 12 if reply.attr.type == "result" then
14 stream:event("session-success"); 13 stream:event("session-success");
15 elseif reply.attr.type == "error" then 14 elseif reply.attr.type == "error" then
16 local err = reply:child_with_name("error"); 15 local err = reply:child_with_name("error");

mercurial