sessionmanager: Added function send_to_interested_resources().
[prosody.git] / plugins / mod_bosh.lua
index fddd5c111090108f3506e1e83b6814b11a7d7fac..5de79eff187c4580ab88a5322a30991102b3a57c 100644 (file)
@@ -23,7 +23,7 @@ local logger = require "util.logger";
 local log = logger.init("mod_bosh");
 
 local xmlns_bosh = "http://jabber.org/protocol/httpbind"; -- (hard-coded into a literal in session.send)
-local stream_callbacks = { stream_tag = "http://jabber.org/protocol/httpbind|body", default_ns = xmlns_bosh };
+local stream_callbacks = { stream_tag = "http://jabber.org/protocol/httpbind\1body", default_ns = xmlns_bosh };
 
 local BOSH_DEFAULT_HOLD = tonumber(module:get_option("bosh_default_hold")) or 1;
 local BOSH_DEFAULT_INACTIVITY = tonumber(module:get_option("bosh_max_inactivity")) or 60;
@@ -70,7 +70,7 @@ function handle_request(method, body, request)
        --log("debug", "Handling new request %s: %s\n----------", request.id, tostring(body));
        request.notopen = true;
        request.log = log;
-       local parser = lxp.new(init_xmlhandlers(request, stream_callbacks), "|");
+       local parser = lxp.new(init_xmlhandlers(request, stream_callbacks), "\1");
        
        parser:parse(body);
        
@@ -152,7 +152,7 @@ function stream_callbacks.streamopened(request, attr)
                local r, send_buffer = session.requests, session.send_buffer;
                local response = { headers = default_headers }
                function session.send(s)
-                       log("debug", "Sending BOSH data: %s", tostring(s));
+                       --log("debug", "Sending BOSH data: %s", tostring(s));
                        local oldest_request = r[1];
                        while oldest_request and oldest_request.destroyed do
                                t_remove(r, 1);
@@ -160,7 +160,7 @@ function stream_callbacks.streamopened(request, attr)
                                oldest_request = r[1];
                        end
                        if oldest_request then
-                               log("debug", "We have an open request, so using that to send with");
+                               log("debug", "We have an open request, so sending on that");
                                response.body = t_concat{"<body xmlns='http://jabber.org/protocol/httpbind' sid='", sid, "' xmlns:stream = 'http://etherx.jabber.org/streams'>", tostring(s), "</body>" };
                                oldest_request:send(response);
                                --log("debug", "Sent");
@@ -254,6 +254,7 @@ function stream_callbacks.handlestanza(request, stanza)
                if stanza.attr.xmlns == xmlns_bosh then
                        stanza.attr.xmlns = "jabber:client";
                end
+               session.ip = request.handler.ip();
                core_process_stanza(session, stanza);
        end
 end