Comparison

plugins/mod_component.lua @ 7301:995777582044

mod_component: Some cleanup [luacheck]
author Matthew Wild <mwild1@gmail.com>
date Fri, 18 Mar 2016 14:03:14 +0000
parent 7300:66e7517bd8f3
child 7359:a5a080c12c96
child 7665:2e553f80aedd
comparison
equal deleted inserted replaced
7300:66e7517bd8f3 7301:995777582044
38 env.connected = false; 38 env.connected = false;
39 env.session = false; 39 env.session = false;
40 40
41 local send; 41 local send;
42 42
43 local function on_destroy(session, err) 43 local function on_destroy(session, err) --luacheck: ignore 212/err
44 env.connected = false; 44 env.connected = false;
45 env.session = false; 45 env.session = false;
46 send = nil; 46 send = nil;
47 session.on_destroy = nil; 47 session.on_destroy = nil;
48 end 48 end
147 147
148 local stream_callbacks = { default_ns = xmlns_component }; 148 local stream_callbacks = { default_ns = xmlns_component };
149 149
150 local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams"; 150 local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams";
151 151
152 function stream_callbacks.error(session, error, data, data2) 152 function stream_callbacks.error(session, error, data)
153 if session.destroyed then return; end 153 if session.destroyed then return; end
154 module:log("warn", "Error processing component stream: %s", tostring(error)); 154 module:log("warn", "Error processing component stream: %s", tostring(error));
155 if error == "no-stream" then 155 if error == "no-stream" then
156 session:close("invalid-namespace"); 156 session:close("invalid-namespace");
157 elseif error == "parse-error" then 157 elseif error == "parse-error" then
293 function session.reset_stream() 293 function session.reset_stream()
294 session.notopen = true; 294 session.notopen = true;
295 session.stream:reset(); 295 session.stream:reset();
296 end 296 end
297 297
298 function session.data(conn, data) 298 function session.data(_, data)
299 local ok, err = stream:feed(data); 299 local ok, err = stream:feed(data);
300 if ok then return; end 300 if ok then return; end
301 module:log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "):gsub("[%z\1-\31]", "_")); 301 module:log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "):gsub("[%z\1-\31]", "_"));
302 session:close("not-well-formed"); 302 session:close("not-well-formed");
303 end 303 end
321 if k ~= "log" and k ~= "close" then 321 if k ~= "log" and k ~= "close" then
322 session[k] = nil; 322 session[k] = nil;
323 end 323 end
324 end 324 end
325 session.destroyed = true; 325 session.destroyed = true;
326 session = nil;
327 end 326 end
328 end 327 end
329 328
330 function listener.ondetach(conn) 329 function listener.ondetach(conn)
331 sessions[conn] = nil; 330 sessions[conn] = nil;