Comparison

client.lua @ 10:3a422606a040

verse.client: Fire events on stream features, errors, etc. and on non-stream tags such as SASL and TLS
author Matthew Wild <mwild1@gmail.com>
date Sat, 28 Nov 2009 22:28:03 +0000
parent 1:7c8d0a2fc004
child 11:ce349990bd21
comparison
equal deleted inserted replaced
9:ca225a2d67b4 10:3a422606a040
4 local jid_split = require "jid".split; 4 local jid_split = require "jid".split;
5 local lxp = require "lxp"; 5 local lxp = require "lxp";
6 local st = require "util.stanza"; 6 local st = require "util.stanza";
7 local init_xmlhandlers = require "xmlhandlers"; 7 local init_xmlhandlers = require "xmlhandlers";
8 8
9 local xmlns_stream = "http://etherx.jabber.org/streams";
9 10
10 local stream_callbacks = { stream_tag = "http://etherx.jabber.org/streams|stream", 11 local stream_callbacks = { stream_tag = xmlns_stream.."|stream",
11 default_ns = "jabber:client" }; 12 default_ns = "jabber:client" };
12 13
13 function stream_callbacks.streamopened(stream, attr) 14 function stream_callbacks.streamopened(stream, attr)
14 if not stream:event("opened") then 15 if not stream:event("opened") then
15 stream.notopen = nil; 16 stream.notopen = nil;
20 function stream_callbacks.streamclosed(stream) 21 function stream_callbacks.streamclosed(stream)
21 return stream:event("closed"); 22 return stream:event("closed");
22 end 23 end
23 24
24 function stream_callbacks.handlestanza(stream, stanza) 25 function stream_callbacks.handlestanza(stream, stanza)
26 if stanza.attr.xmlns == xmlns_stream then
27 return stream:event("stream-"..stanza.name, stanza);
28 elseif stanza.attr.xmlns then
29 return stream:event("stream/"..stanza.attr.xmlns, stanza);
30 end
25 return stream:event("stanza", stanza); 31 return stream:event("stanza", stanza);
26 end 32 end
27 33
28 local function reset_stream(stream) 34 local function reset_stream(stream)
29 -- Reset stream 35 -- Reset stream