net.xmpp{client,server,component}_listener: s/xml-not-well-formed/not-well-formed...
[prosody.git] / net / xmppclient_listener.lua
index a7da6d229c2419fdebf1cbce32374b4477777ded..7cffc0ca92591dd5b1de6dfcaf7aa07a4f2252ad 100644 (file)
@@ -41,7 +41,7 @@ function stream_callbacks.error(session, error, data)
                session:close("invalid-namespace");
        elseif error == "parse-error" then
                (session.log or log)("debug", "Client XML parse error: %s", tostring(data));
-               session:close("xml-not-well-formed");
+               session:close("not-well-formed");
        elseif error == "stream-error" then
                local condition, text = "undefined-condition";
                for child in data:children() do
@@ -66,7 +66,7 @@ local function handleerr(err) log("error", "Traceback[c2s]: %s: %s", tostring(er
 function stream_callbacks.handlestanza(session, stanza)
        stanza = session.filter("stanzas/in", stanza);
        if stanza then
-               xpcall(function () core_process_stanza(session, stanza) end, handleerr);
+               return xpcall(function () return core_process_stanza(session, stanza) end, handleerr);
        end
 end
 
@@ -148,7 +148,7 @@ function xmppclient.onconnect(conn)
                        local ok, err = stream:feed(data);
                        if ok then return; end
                        log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "):gsub("[%z\1-\31]", "_"));
-                       session:close("xml-not-well-formed");
+                       session:close("not-well-formed");
                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);