From c0d46cbf2a388233fc521743605c59a465e7acda Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 23 Dec 2015 11:17:26 +0000 Subject: util.events: Document data structures --- util/events.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/util/events.lua b/util/events.lua index 825ffb19..073d2a60 100644 --- a/util/events.lua +++ b/util/events.lua @@ -17,10 +17,15 @@ local next = next; local _ENV = nil; local function new() + -- Map event name to ordered list of handlers (lazily built): handlers[event_name] = array_of_handler_functions local handlers = {}; + -- Array of wrapper functions that wrap all events (nil if empty) local global_wrappers; + -- Per-event wrappers: wrappers[event_name] = wrapper_function local wrappers = {}; + -- Event map: event_map[handler_function] = priority_number local event_map = {}; + -- Called on-demand to build handlers entries local function _rebuild_index(handlers, event) local _handlers = event_map[event]; if not _handlers or next(_handlers) == nil then return; end -- cgit v1.2.3 From 3b1c2ebbd96a4da0baea1ede8edaae0a191aa7f4 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 2 Jan 2016 20:40:34 +0000 Subject: net.server_event: Add conn.type == 'server' for server sockets (fixes closeallservers() ) --- net/server_event.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/net/server_event.lua b/net/server_event.lua index ec8af2a4..e5705ab5 100644 --- a/net/server_event.lua +++ b/net/server_event.lua @@ -614,6 +614,7 @@ local function handleserver( server, addr, port, pattern, listener, sslctx ) -- local interface = { _connections = 0; + type = "server"; conn = server; onconnect = listener.onconnect; -- will be called when new client connected eventread = false; -- read event handler -- cgit v1.2.3 From e5691fed7972bf6c0d4e0e494f79850322b794c4 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 2 Jan 2016 20:42:20 +0000 Subject: net.server_select: Close all connections when quitting (and not just stepping), matches server_event --- net/server_select.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/net/server_select.lua b/net/server_select.lua index 9c5225c6..87921df4 100644 --- a/net/server_select.lua +++ b/net/server_select.lua @@ -911,6 +911,7 @@ loop = function(once) -- this is the main loop of the program socket_sleep( _sleeptime ) until quitting; if once and quitting == "once" then quitting = nil; return; end + closeall(); return "quitting" end -- cgit v1.2.3