| 314bc5df  zhengshouren
 
提交服务器初始代码 | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 |   local skynet = require "skynet"
  require "skynet.manager"
  local redis = require "skynet.db.redis"
  
  local db
  
  local command = {}
  
  function command.open(conf)
  	db = redis.connect({
  		host = conf.redishost,
  		port = conf.redisport,
  		db = conf.redisdb or 0,
  		auth = conf.auth,
  	})
 | 
| 314bc5df  zhengshouren
 
提交服务器初始代码 | 16
17
18
19
20
21
22
23
24
25
26 |   end
  
  skynet.start(function()
  	skynet.dispatch("lua", function(session, address, cmd, ...)
  		if cmd == "open" then
  			local f = command[string.lower(cmd)]
  			skynet.ret(skynet.pack(f(...)))
  		else
  			skynet.ret(skynet.pack(db[string.lower(cmd)](db, ...)))
  		end
  	end)
 |