Software /
code /
verse
File
plugins/session.lua @ 496:c4ae7aa2958a
util.sasl.oauthbearer: Fix message syntax
Each key-value pair has a \001 trailer, and then the whole thing has a
\001 trailer as well, so it should always end with two \001.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 23 Jun 2023 10:11:25 +0200 |
parent | 395:e86144a4eaa1 |
line wrap: on
line source
local verse = require "verse"; local xmlns_session = "urn:ietf:params:xml:ns:xmpp-session"; function verse.plugins.session(stream) local function handle_features(features) local session_feature = features:get_child("session", xmlns_session); if session_feature and not session_feature:get_child("optional") then local function handle_binding(jid) stream:debug("Establishing Session..."); stream:send_iq(verse.iq({ type = "set" }):tag("session", {xmlns=xmlns_session}), function (reply) if reply.attr.type == "result" then stream:event("session-success"); elseif reply.attr.type == "error" then local type, condition, text = reply:get_error(); stream:event("session-failure", { error = condition, text = text, type = type }); end end); return true; end stream:hook("bind-success", handle_binding); end end stream:hook("stream-features", handle_features); return true; end