Mercurial > prosody-hg
diff net/server_select.lua @ 6379:a280bd6ccce2
net.server_{select,event}: Add 'ondetach' callback for listener objects, to notify them when another listener is being assigned to a connection
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 29 Aug 2014 11:39:56 +0100 |
| parents | 8029b8a5f37a |
| children | 9ffd582c65d8 |
line wrap: on
line diff
--- a/net/server_select.lua Tue Sep 02 17:24:25 2014 +0200 +++ b/net/server_select.lua Fri Aug 29 11:39:56 2014 +0100 @@ -284,6 +284,7 @@ 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 @@ 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
