Comparison

net/xmppserver_listener.lua @ 3332:c941d1191709

xmpp{client,server}_listener: Put stanzas/in filtering code in the correct place to make it actually work :)
author Matthew Wild <mwild1@gmail.com>
date Thu, 08 Jul 2010 14:28:42 +0100
parent 3147:bc8c31399520
child 3333:e6bb6bc4cfbe
comparison
equal deleted inserted replaced
3331:57a9cf5f4259 3332:c941d1191709
47 session:close(nil, text); 47 session:close(nil, text);
48 end 48 end
49 end 49 end
50 50
51 local function handleerr(err) log("error", "Traceback[s2s]: %s: %s", tostring(err), debug.traceback()); end 51 local function handleerr(err) log("error", "Traceback[s2s]: %s: %s", tostring(err), debug.traceback()); end
52 function stream_callbacks.handlestanza(a, b) 52 function stream_callbacks.handlestanza(session, stanza)
53 if b.attr.xmlns == "jabber:client" then --COMPAT: Prosody pre-0.6.2 may send jabber:client 53 if stanza.attr.xmlns == "jabber:client" then --COMPAT: Prosody pre-0.6.2 may send jabber:client
54 b.attr.xmlns = nil; 54 stanza.attr.xmlns = nil;
55 end 55 end
56 xpcall(function () core_process_stanza(a, b) end, handleerr); 56 stanza = session.filter("stanzas/in", stanza);
57 if stanza then
58 xpcall(function () core_process_stanza(a, b) end, handleerr);
59 end
57 end 60 end
58 61
59 local connlisteners_register = require "net.connlisteners".register; 62 local connlisteners_register = require "net.connlisteners".register;
60 63
61 local t_insert = table.insert; 64 local t_insert = table.insert;
138 end 141 end
139 142
140 session.close = session_close; 143 session.close = session_close;
141 local handlestanza = stream_callbacks.handlestanza; 144 local handlestanza = stream_callbacks.handlestanza;
142 function session.dispatch_stanza(session, stanza) 145 function session.dispatch_stanza(session, stanza)
143 stanza = filters("stanzas/in", stanza); 146 return handlestanza(session, stanza);
144 if stanza then
145 return handlestanza(session, stanza);
146 end
147 end 147 end
148 end 148 end
149 149
150 function xmppserver.onconnect(conn) 150 function xmppserver.onconnect(conn)
151 if not sessions[conn] then -- May be an existing outgoing session 151 if not sessions[conn] then -- May be an existing outgoing session