Diff

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
line wrap: on
line diff
--- a/client.lua	Sat Nov 28 22:25:54 2009 +0000
+++ b/client.lua	Sat Nov 28 22:28:03 2009 +0000
@@ -6,8 +6,9 @@
 local st = require "util.stanza";
 local init_xmlhandlers = require "xmlhandlers";
 
+local xmlns_stream = "http://etherx.jabber.org/streams";
 
-local stream_callbacks = { stream_tag = "http://etherx.jabber.org/streams|stream", 
+local stream_callbacks = { stream_tag = xmlns_stream.."|stream", 
 		default_ns = "jabber:client" };
 	
 function stream_callbacks.streamopened(stream, attr)
@@ -22,6 +23,11 @@
 end
 
 function stream_callbacks.handlestanza(stream, stanza)
+	if stanza.attr.xmlns == xmlns_stream then
+		return stream:event("stream-"..stanza.name, stanza);
+	elseif stanza.attr.xmlns then
+		return stream:event("stream/"..stanza.attr.xmlns, stanza);
+	end
 	return stream:event("stanza", stanza);
 end