Software /
code /
verse
Comparison
plugins/session.lua @ 73:b416751df2ca
verse.plugins.session: Convert from spaces to tabs
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 30 May 2010 02:37:03 +0100 |
parent | 68:1789dac44823 |
child | 75:f5ac4e39e84f |
comparison
equal
deleted
inserted
replaced
72:1649a6022adb | 73:b416751df2ca |
---|---|
1 local st = require "util.stanza"; | 1 local st = require "util.stanza"; |
2 local xmlns_session = "urn:ietf:params:xml:ns:xmpp-session"; | 2 local xmlns_session = "urn:ietf:params:xml:ns:xmpp-session"; |
3 | 3 |
4 function verse.plugins.session(stream) | 4 function verse.plugins.session(stream) |
5 local function handle_binding(jid) | 5 local function handle_binding(jid) |
6 stream:debug("Establishing Session..."); | 6 stream:debug("Establishing Session..."); |
7 stream:send_iq(st.iq({ type = "set" }):tag("session", {xmlns=xmlns_session}), | 7 stream:send_iq(st.iq({ type = "set" }):tag("session", {xmlns=xmlns_session}), |
8 function (reply) | 8 function (reply) |
9 if reply.attr.type == "result" then | 9 if reply.attr.type == "result" then |
10 stream:event("session-success"); | 10 stream:event("session-success"); |
11 elseif reply.attr.type == "error" then | 11 elseif reply.attr.type == "error" then |
12 local err = reply:child_with_name("error"); | 12 local err = reply:child_with_name("error"); |
13 local type, condition, text = reply:get_error(); | 13 local type, condition, text = reply:get_error(); |
14 stream:event("session-failure", { error = condition, text = text, type = type }); | 14 stream:event("session-failure", { error = condition, text = text, type = type }); |
15 end | 15 end |
16 end); | 16 end); |
17 end | 17 end |
18 stream:hook("binding-success", handle_binding); | 18 stream:hook("binding-success", handle_binding); |
19 return true; | 19 return true; |
20 end | 20 end |