Comparison

plugins/mod_net_multiplex.lua @ 6380:4220ffb87b22

net.http, net.http.server, mod_c2s, mod_s2s, mod_component, mod_admin_telnet, mod_net_multiplex: Add ondetach to release connection from 'sessions' table (or equivalent)
author Matthew Wild <mwild1@gmail.com>
date Fri, 29 Aug 2014 11:54:34 +0100
parent 5120:bcabea740c00
child 7502:021d2b844c51
child 7806:00bca79ae778
comparison
equal deleted inserted replaced
6379:a280bd6ccce2 6380:4220ffb87b22
32 end 32 end
33 33
34 function listener.onincoming(conn, data) 34 function listener.onincoming(conn, data)
35 if not data then return; end 35 if not data then return; end
36 local buf = buffers[conn]; 36 local buf = buffers[conn];
37 buffers[conn] = nil;
38 buf = buf and buf..data or data; 37 buf = buf and buf..data or data;
39 for service, multiplex_pattern in pairs(available_services) do 38 for service, multiplex_pattern in pairs(available_services) do
40 if buf:match(multiplex_pattern) then 39 if buf:match(multiplex_pattern) then
41 module:log("debug", "Routing incoming connection to %s", service.name); 40 module:log("debug", "Routing incoming connection to %s", service.name);
42 local listener = service.listener; 41 local listener = service.listener;
55 54
56 function listener.ondisconnect(conn, err) 55 function listener.ondisconnect(conn, err)
57 buffers[conn] = nil; -- warn if no buffer? 56 buffers[conn] = nil; -- warn if no buffer?
58 end 57 end
59 58
59 listener.ondetach = listener.ondisconnect;
60
60 module:provides("net", { 61 module:provides("net", {
61 name = "multiplex"; 62 name = "multiplex";
62 config_prefix = ""; 63 config_prefix = "";
63 listener = listener; 64 listener = listener;
64 }); 65 });