libs/xstanza.lua

Sun, 30 May 2010 02:47:19 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sun, 30 May 2010 02:47:19 +0100
changeset 75
f5ac4e39e84f
parent 15
be4154ed4e3a
permissions
-rw-r--r--

verse.plugins.session: Only negotiate session when support is advertised by the server, and not marked as optional (saves a round-trip in a lot of cases)

local stanza_mt = getmetatable(require "util.stanza".stanza());

local xmlns_stanzas = "urn:ietf:params:xml:ns:xmpp-stanzas";

function stanza_mt:get_error()
	local type, condition, text;
	
	local error_tag = self:get_child("error");
	if not error_tag then
		return nil, nil;
	end
	type = error_tag.attr.type;
	
	for child in error_tag:children() do
		if child.attr.xmlns == xmlns_stanzas then
			if child.name == "text" then
				text = child:get_text();
			else
				condition = child.name;
			end
			if condition and text then
				break;
			end
		end
	end
	return type, condition, text;
end

mercurial