Comparison

net/server_event.lua @ 6481:dbc72cd1332e

Move timer code out of util.timer and into relevant net.server backends
author daurnimator <quae@daurnimator.com>
date Mon, 20 Oct 2014 16:13:24 -0400
parent 6383:ec8878113907
child 6791:e813e8cf6046
comparison
equal deleted inserted replaced
6480:37b12475f648 6481:dbc72cd1332e
846 end 846 end
847 end 847 end
848 sender:set_mode("*a"); 848 sender:set_mode("*a");
849 end 849 end
850 850
851 local add_task do
852 local EVENT_LEAVE = (event.core and event.core.LEAVE) or -1;
853 local socket_gettime = socket.gettime
854 function add_task(delay, callback)
855 local event_handle;
856 event_handle = base:addevent(nil, 0, function ()
857 local ret = callback(socket_gettime());
858 if ret then
859 return 0, ret;
860 elseif event_handle then
861 return EVENT_LEAVE;
862 end
863 end
864 , delay);
865 end
866 end
867
851 return { 868 return {
852 869
853 cfg = cfg, 870 cfg = cfg,
854 base = base, 871 base = base,
855 loop = loop, 872 loop = loop,
862 wrapclient = wrapclient, 879 wrapclient = wrapclient,
863 setquitting = setquitting, 880 setquitting = setquitting,
864 closeall = closeallservers, 881 closeall = closeallservers,
865 get_backend = get_backend, 882 get_backend = get_backend,
866 hook_signal = hook_signal, 883 hook_signal = hook_signal,
884 add_task = add_task,
867 885
868 __NAME = SCRIPT_NAME, 886 __NAME = SCRIPT_NAME,
869 __DATE = LAST_MODIFIED, 887 __DATE = LAST_MODIFIED,
870 __AUTHOR = SCRIPT_AUTHOR, 888 __AUTHOR = SCRIPT_AUTHOR,
871 __VERSION = SCRIPT_VERSION, 889 __VERSION = SCRIPT_VERSION,