Comparison

plugins/mod_s2s/mod_s2s.lua @ 6255:6167f8bc5a6b

mod_s2s: Decide on log function once
author Kim Alvefur <zash@zash.se>
date Thu, 22 May 2014 22:45:58 +0200
parent 6146:ac4f8770d9aa
child 6256:d05627c89c99
comparison
equal deleted inserted replaced
6176:02d366be7c2f 6255:6167f8bc5a6b
527 end 527 end
528 528
529 -- Session initialization logic shared by incoming and outgoing 529 -- Session initialization logic shared by incoming and outgoing
530 local function initialize_session(session) 530 local function initialize_session(session)
531 local stream = new_xmpp_stream(session, stream_callbacks); 531 local stream = new_xmpp_stream(session, stream_callbacks);
532 local log = session.log or log;
532 session.stream = stream; 533 session.stream = stream;
533 534
534 session.notopen = true; 535 session.notopen = true;
535 536
536 function session.reset_stream() 537 function session.reset_stream()
544 function session.data(data) 545 function session.data(data)
545 data = filter("bytes/in", data); 546 data = filter("bytes/in", data);
546 if data then 547 if data then
547 local ok, err = stream:feed(data); 548 local ok, err = stream:feed(data);
548 if ok then return; end 549 if ok then return; end
549 (session.log or log)("warn", "Received invalid XML: %s", data); 550 log("warn", "Received invalid XML: %s", data);
550 (session.log or log)("warn", "Problem was: %s", err); 551 log("warn", "Problem was: %s", err);
551 session:close("not-well-formed"); 552 session:close("not-well-formed");
552 end 553 end
553 end 554 end
554 555
555 session.close = session_close; 556 session.close = session_close;