Software /
code /
verse
Comparison
plugins/session.lua @ 50:432ac110544f
Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 02 Apr 2010 16:07:43 +0100 |
child | 68:1789dac44823 |
comparison
equal
deleted
inserted
replaced
49:9c10ff584e87 | 50:432ac110544f |
---|---|
1 local st = require "util.stanza"; | |
2 local xmlns_session = "urn:ietf:params:xml:ns:xmpp-session"; | |
3 | |
4 function verse.plugins.session(stream) | |
5 local function handle_binding(jid) | |
6 stream:debug("Establishing Session..."); | |
7 stream:send_iq(st.iq({ type = "set" }):tag("session", {xmlns=xmlns_session}), | |
8 function (reply) | |
9 if reply.attr.type == "result" then | |
10 stream:event("session-success"); | |
11 elseif reply.attr.type == "error" then | |
12 local err = reply:child_with_name("error"); | |
13 local type, condition, text = reply:get_error(); | |
14 stream:event("session-failure", { error = condition, text = text, type = type }); | |
15 end | |
16 end); | |
17 end | |
18 stream:hook("binding-success", handle_binding); | |
19 return true; | |
20 end |