Software /
code /
prosody
Changeset
9385:58fe099043ed
net.server: Call a 'onattach' callback when replacing listeners
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 26 Sep 2018 14:25:59 +0200 |
parents | 9384:5c8006ce8cb8 |
children | 9386:0f395d82b4ea |
files | net/server_epoll.lua net/server_event.lua net/server_select.lua |
diffstat | 3 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/net/server_epoll.lua Wed Sep 26 14:57:09 2018 +0200 +++ b/net/server_epoll.lua Wed Sep 26 14:25:59 2018 +0200 @@ -139,6 +139,7 @@ function interface:setlistener(listeners) self:on("detach"); self.listeners = listeners; + self:on("attach"); end -- Call a listener callback
--- a/net/server_event.lua Wed Sep 26 14:57:09 2018 +0200 +++ b/net/server_event.lua Wed Sep 26 14:25:59 2018 +0200 @@ -424,7 +424,9 @@ self.onreadtimeout = listener.onreadtimeout; self.onstatus = listener.onstatus; self.ondetach = listener.ondetach; + self.onattach = listener.onattach; self.ondrain = listener.ondrain; + self:onattach(); end -- Stub handlers @@ -446,6 +448,8 @@ end function interface_mt:ondetach() end +function interface_mt:onattach() +end function interface_mt:onstatus() end
--- a/net/server_select.lua Wed Sep 26 14:57:09 2018 +0200 +++ b/net/server_select.lua Wed Sep 26 14:25:59 2018 +0200 @@ -331,6 +331,9 @@ drain = listeners.ondrain handler.onreadtimeout = listeners.onreadtimeout detach = listeners.ondetach + if listeners.onattach then + listeners.onattach(self) + end end handler.getstats = function( ) return readtraffic, sendtraffic