Annotate

plugins/session.lua @ 62:d4b6f9e33c6e

verse.client: Load TLS along with other core plugins
author Matthew Wild <mwild1@gmail.com>
date Tue, 11 May 2010 23:05:26 +0100
parent 50:432ac110544f
child 68:1789dac44823
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
50
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 local st = require "util.stanza";
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 local xmlns_session = "urn:ietf:params:xml:ns:xmpp-session";
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 function verse.plugins.session(stream)
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 local function handle_binding(jid)
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 stream:debug("Establishing Session...");
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 stream:send_iq(st.iq({ type = "set" }):tag("session", {xmlns=xmlns_session}),
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 function (reply)
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 if reply.attr.type == "result" then
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 stream:event("session-success");
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 elseif reply.attr.type == "error" then
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 local err = reply:child_with_name("error");
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 local type, condition, text = reply:get_error();
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 stream:event("session-failure", { error = condition, text = text, type = type });
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 end
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 end);
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 end
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 stream:hook("binding-success", handle_binding);
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 return true;
432ac110544f Add support for 3921 session negotiation (makes ejabberd happy), thanks Chris!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 end