Comparison

net/server_event.lua @ 6383:ec8878113907

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Tue, 02 Sep 2014 22:34:32 +0200
parent 6316:e144a1b67c30
parent 6382:57d23c26039b
child 6481:dbc72cd1332e
comparison
equal deleted inserted replaced
6372:305226a9e581 6383:ec8878113907
437 end 437 end
438 return false, "setoption not implemented"; 438 return false, "setoption not implemented";
439 end 439 end
440 440
441 function interface_mt:setlistener(listener) 441 function interface_mt:setlistener(listener)
442 self.onconnect, self.ondisconnect, self.onincoming, self.ontimeout, self.onreadtimeout, self.onstatus 442 self:ondetach(); -- Notify listener that it is no longer responsible for this connection
443 = listener.onconnect, listener.ondisconnect, listener.onincoming, 443 self.onconnect, self.ondisconnect, self.onincoming, self.ontimeout,
444 listener.ontimeout, listener.onreadtimeout, listener.onstatus; 444 self.onreadtimeout, self.onstatus, self.ondetach
445 = listener.onconnect, listener.ondisconnect, listener.onincoming, listener.ontimeout,
446 listener.onreadtimeout, listener.onstatus, listener.ondetach;
445 end 447 end
446 448
447 -- Stub handlers 449 -- Stub handlers
448 function interface_mt:onconnect() 450 function interface_mt:onconnect()
449 end 451 end
458 debug( "connection failed:", self.fatalerror ) 460 debug( "connection failed:", self.fatalerror )
459 self:_close() 461 self:_close()
460 self.eventread = nil 462 self.eventread = nil
461 end 463 end
462 function interface_mt:ondrain() 464 function interface_mt:ondrain()
465 end
466 function interface_mt:ondetach()
463 end 467 end
464 function interface_mt:onstatus() 468 function interface_mt:onstatus()
465 end 469 end
466 end 470 end
467 471
486 ondisconnect = listener.ondisconnect; -- will be called when client disconnects 490 ondisconnect = listener.ondisconnect; -- will be called when client disconnects
487 onincoming = listener.onincoming; -- will be called when client sends data 491 onincoming = listener.onincoming; -- will be called when client sends data
488 ontimeout = listener.ontimeout; -- called when fatal socket timeout occurs 492 ontimeout = listener.ontimeout; -- called when fatal socket timeout occurs
489 onreadtimeout = listener.onreadtimeout; -- called when socket inactivity timeout occurs 493 onreadtimeout = listener.onreadtimeout; -- called when socket inactivity timeout occurs
490 ondrain = listener.ondrain; -- called when writebuffer is empty 494 ondrain = listener.ondrain; -- called when writebuffer is empty
495 ondetach = listener.ondetach; -- called when disassociating this listener from this connection
491 onstatus = listener.onstatus; -- called for status changes (e.g. of SSL/TLS) 496 onstatus = listener.onstatus; -- called for status changes (e.g. of SSL/TLS)
492 eventread = false, eventwrite = false, eventclose = false, 497 eventread = false, eventwrite = false, eventclose = false,
493 eventhandshake = false, eventstarthandshake = false; -- event handler 498 eventhandshake = false, eventstarthandshake = false; -- event handler
494 eventconnect = false, eventsession = false; -- more event handler... 499 eventconnect = false, eventsession = false; -- more event handler...
495 eventwritetimeout = false; -- even more event handler... 500 eventwritetimeout = false; -- even more event handler...