Changeset

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
parents 49:9c10ff584e87
children 51:d044a726fef0
files client.lua plugins/session.lua squishy
diffstat 3 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/client.lua	Wed Feb 17 00:26:30 2010 +0000
+++ b/client.lua	Fri Apr 02 16:07:43 2010 +0100
@@ -62,6 +62,7 @@
 	
 	self:add_plugin("sasl");
 	self:add_plugin("bind");
+	self:add_plugin("session");
 	
 	self:hook("incoming-raw", function (data) return self.data(self.conn, data); end);
 	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/session.lua	Fri Apr 02 16:07:43 2010 +0100
@@ -0,0 +1,20 @@
+local st = require "util.stanza";
+local xmlns_session = "urn:ietf:params:xml:ns:xmpp-session";
+
+function verse.plugins.session(stream)
+        local function handle_binding(jid)
+                stream:debug("Establishing Session...");
+                stream:send_iq(st.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 err = reply:child_with_name("error");
+                                        local type, condition, text = reply:get_error();
+                                        stream:event("session-failure", { error = condition, text = text, type = type });
+                                end
+                        end);
+        end
+        stream:hook("binding-success", handle_binding);
+        return true;
+end
--- a/squishy	Wed Feb 17 00:26:30 2010 +0000
+++ b/squishy	Fri Apr 02 16:07:43 2010 +0100
@@ -22,6 +22,7 @@
 Module "verse.plugins.bind"	"plugins/bind.lua"
 Module "verse.plugins.version"	"plugins/version.lua"
 Module "verse.plugins.ping"	"plugins/ping.lua"
+Module "verse.plugins.session"  "plugins/session.lua"
 
 Module "verse.client" "client.lua"