net.http: Removed old HTTP parser, and updated to use util.httpstream.
[prosody.git] / net / xmppclient_listener.lua
index 623a98c8408f3b67eaf7005f73e2a242d5960e4e..da006d0ac91909263d5b3ecbbf3f763613ebc3e5 100644 (file)
@@ -63,8 +63,11 @@ function stream_callbacks.error(session, error, data)
 end
 
 local function handleerr(err) log("error", "Traceback[c2s]: %s: %s", tostring(err), debug.traceback()); end
-function stream_callbacks.handlestanza(a, b)
-       xpcall(function () core_process_stanza(a, b) end, handleerr);
+function stream_callbacks.handlestanza(session, stanza)
+       stanza = session.filter("stanzas/in", stanza);
+       if stanza then
+               return xpcall(function () return core_process_stanza(session, stanza) end, handleerr);
+       end
 end
 
 local sessions = {};
@@ -151,10 +154,7 @@ function xmppclient.onconnect(conn)
        
        local handlestanza = stream_callbacks.handlestanza;
        function session.dispatch_stanza(session, stanza)
-               stanza = filter("stanzas/in", stanza);
-               if stanza then
-                       return handlestanza(session, stanza);
-               end
+               return handlestanza(session, stanza);
        end
 end
 
@@ -175,4 +175,8 @@ function xmppclient.ondisconnect(conn, err)
        end
 end
 
+function xmppclient.associate_session(conn, session)
+       sessions[conn] = session;
+end
+
 connlisteners_register("xmppclient", xmppclient);