Software /
code /
prosody
Comparison
net/server_event.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 |
parent | 6314:8029b8a5f37a |
child | 6382:57d23c26039b |
child | 7222:168d03dd09c7 |
comparison
equal
deleted
inserted
replaced
6378:3cec0eef0b70 | 6379:a280bd6ccce2 |
---|---|
436 end | 436 end |
437 return false, "setoption not implemented"; | 437 return false, "setoption not implemented"; |
438 end | 438 end |
439 | 439 |
440 function interface_mt:setlistener(listener) | 440 function interface_mt:setlistener(listener) |
441 self.onconnect, self.ondisconnect, self.onincoming, self.ontimeout, self.onstatus | 441 self:ondetach(); -- Notify listener that it is no longer responsible for this connection |
442 = listener.onconnect, listener.ondisconnect, listener.onincoming, listener.ontimeout, listener.onstatus; | 442 self.onconnect, self.ondisconnect, self.onincoming, |
443 self.ontimeout, self.onstatus, self.ondetach | |
444 = listener.onconnect, listener.ondisconnect, listener.onincoming, | |
445 listener.ontimeout, listener.onstatus, listener.ondetach; | |
443 end | 446 end |
444 | 447 |
445 -- Stub handlers | 448 -- Stub handlers |
446 function interface_mt:onconnect() | 449 function interface_mt:onconnect() |
447 end | 450 end |
450 function interface_mt:ondisconnect() | 453 function interface_mt:ondisconnect() |
451 end | 454 end |
452 function interface_mt:ontimeout() | 455 function interface_mt:ontimeout() |
453 end | 456 end |
454 function interface_mt:ondrain() | 457 function interface_mt:ondrain() |
458 end | |
459 function interface_mt:ondetach() | |
455 end | 460 end |
456 function interface_mt:onstatus() | 461 function interface_mt:onstatus() |
457 end | 462 end |
458 end | 463 end |
459 | 464 |
477 onconnect = listener.onconnect; -- will be called when client disconnects | 482 onconnect = listener.onconnect; -- will be called when client disconnects |
478 ondisconnect = listener.ondisconnect; -- will be called when client disconnects | 483 ondisconnect = listener.ondisconnect; -- will be called when client disconnects |
479 onincoming = listener.onincoming; -- will be called when client sends data | 484 onincoming = listener.onincoming; -- will be called when client sends data |
480 ontimeout = listener.ontimeout; -- called when fatal socket timeout occurs | 485 ontimeout = listener.ontimeout; -- called when fatal socket timeout occurs |
481 ondrain = listener.ondrain; -- called when writebuffer is empty | 486 ondrain = listener.ondrain; -- called when writebuffer is empty |
487 ondetach = listener.ondetach; -- called when disassociating this listener from this connection | |
482 onstatus = listener.onstatus; -- called for status changes (e.g. of SSL/TLS) | 488 onstatus = listener.onstatus; -- called for status changes (e.g. of SSL/TLS) |
483 eventread = false, eventwrite = false, eventclose = false, | 489 eventread = false, eventwrite = false, eventclose = false, |
484 eventhandshake = false, eventstarthandshake = false; -- event handler | 490 eventhandshake = false, eventstarthandshake = false; -- event handler |
485 eventconnect = false, eventsession = false; -- more event handler... | 491 eventconnect = false, eventsession = false; -- more event handler... |
486 eventwritetimeout = false; -- even more event handler... | 492 eventwritetimeout = false; -- even more event handler... |