From 972f29756d18c945f9c1d5df219a89fd6962bcf3 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 29 Aug 2014 11:39:56 +0100 Subject: net.server_{select,event}: Add 'ondetach' callback for listener objects, to notify them when another listener is being assigned to a connection --- net/server_select.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'net/server_select.lua') diff --git a/net/server_select.lua b/net/server_select.lua index e8964518..2b23b4f0 100644 --- a/net/server_select.lua +++ b/net/server_select.lua @@ -284,6 +284,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport local status = listeners.onstatus local disconnect = listeners.ondisconnect local drain = listeners.ondrain + local detach = listener.ondetach local bufferqueue = { } -- buffer array local bufferqueuelen = 0 -- end of buffer array @@ -313,10 +314,14 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport return disconnect end handler.setlistener = function( self, listeners ) + if detach then + detach(self) -- Notify listener that it is no longer responsible for this connection + end dispatch = listeners.onincoming disconnect = listeners.ondisconnect status = listeners.onstatus drain = listeners.ondrain + detach = listeners.ondetach end handler.getstats = function( ) return readtraffic, sendtraffic -- cgit v1.2.3 From 3d6dafb89a05a6aad4d102266172e377d9491360 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 2 Sep 2014 17:23:44 +0100 Subject: net.server_select: 'listener'->'listeners' (fixes undefined global access) --- net/server_select.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net/server_select.lua') diff --git a/net/server_select.lua b/net/server_select.lua index 2b23b4f0..7ac41523 100644 --- a/net/server_select.lua +++ b/net/server_select.lua @@ -284,7 +284,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport local status = listeners.onstatus local disconnect = listeners.ondisconnect local drain = listeners.ondrain - local detach = listener.ondetach + local detach = listeners.ondetach local bufferqueue = { } -- buffer array local bufferqueuelen = 0 -- end of buffer array -- cgit v1.2.3