simple rpc support

This commit is contained in:
云风
2012-08-06 17:04:06 +08:00
parent 594ab07b5e
commit b33d438715
18 changed files with 266 additions and 73 deletions

22
simpledb.lua Normal file
View File

@@ -0,0 +1,22 @@
local skynet = require "skynet"
local db = {}
local command = {}
function command.GET(key)
skynet.ret(db[key])
end
function command.SET(key, value)
local last = db[key]
db[key] = value
skynet.ret(last)
end
skynet.dispatch(function(message, from, session)
print("simpledb",message, from, session)
local cmd, key , value = string.match(message, "(%w+) (%w+) ?(.*)")
command[cmd](key,value)
end)
skynet.register "SIMPLEDB"