diff -r bd9f24178d67 -r 5bcdb71ef2f2 examples/oob.lua --- a/examples/oob.lua Mon Apr 12 00:41:23 2010 +0300 +++ b/examples/oob.lua Wed Apr 14 11:21:02 2010 +0300 @@ -44,38 +44,39 @@ local connection = main.connection () if connection then local conn = lm.connection.bless ( connection ) - conn:handler ( oob_iq_handler, 'iq', 'normal' ) - conn:handler ( oob_message_handler, 'message', 'normal' ) + conn:handler ( oob_iq_handler, 'iq', 'normal' ) + conn:handler ( oob_message_handler, 'message', 'normal' ) conn:handler ( oob_message_handler, 'presence', 'normal' ) oob_handler_registered = true end end -main.hook ( 'hook-post-connect', oob_pc_handler ) -main.hook ( 'hook-pre-disconnect', +local oob_pd_handler = function ( args ) if oob_handler_registered then local connection = main.connection () if connection then local conn = lm.connection.bless ( connection ) - conn:handler ( oob_iq_handler, 'iq' ) - conn:handler ( oob_message_handler, 'message' ) + conn:handler ( oob_iq_handler, 'iq' ) + conn:handler ( oob_message_handler, 'message' ) conn:handler ( oob_message_handler, 'presence' ) end oob_handler_registered = false end - end ) - + end +main.hook ( 'hook-post-connect', oob_pc_handler ) +main.hook ( 'hook-pre-disconnect', oob_pd_handler ) main.hook ( 'hook-lua-start', function ( args ) main.add_feature ( 'jabber:iq:oob' ) - main.add_feature ( 'jabber:x:oob' ) + main.add_feature ( 'jabber:x:oob' ) oob_pc_handler () end ) main.hook ( 'hook-lua-quit', function ( args ) main.del_feature ( 'jabber:iq:oob' ) - main.del_feature ( 'jabber:x:oob' ) + main.del_feature ( 'jabber:x:oob' ) + oob_pd_handler () end ) -- vim: se ts=4 sw=4: --