Software /
code /
prosody
Comparison
net/server.lua @ 2094:c69cb5c171e0
net.server: New net.server to choose the appropriate library from server_select/server_event based on the availability of luaevent and the use_libevent config option
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 21 Nov 2009 02:39:08 +0000 |
child | 2105:fecf33cb2913 |
comparison
equal
deleted
inserted
replaced
2093:abfa1cc3a42f | 2094:c69cb5c171e0 |
---|---|
1 local have_luaevent = pcall(require, "luaevent.core"); | |
2 local use_luaevent = require "core.configmanager".get("*", "core", "use_libevent"); | |
3 | |
4 local server; | |
5 | |
6 if have_luaevent and use_luaevent == true then | |
7 server = require "net.server_event"; | |
8 package.loaded["net.server"] = server; | |
9 | |
10 -- Backwards compatibility for timers, addtimer | |
11 -- called a function roughly every second | |
12 local add_task = require "util.timer"; | |
13 function server.addtimer(f) | |
14 return add_task(1, function (...) f(...); return 1; end); | |
15 end | |
16 else | |
17 server = require "net.server_select"; | |
18 package.loaded["net.server"] = server; | |
19 end | |
20 | |
21 return server; |