support multi protocol

This commit is contained in:
云风
2012-08-31 21:18:19 +08:00
parent 1ee802c5c5
commit 0a886cd57c
47 changed files with 542 additions and 520 deletions

View File

@@ -13,16 +13,18 @@ function command.SET(key, value)
skynet.ret(last)
end
skynet.dispatch(function(msg, sz , session, from)
local message = skynet.tostring(msg,sz)
print("simpledb",message, skynet.address(from), session)
local cmd, key , value = string.match(message, "(%w+) (%w+) ?(.*)")
local f = command[cmd]
if f then
f(key,value)
else
skynet.ret("Invalid command : "..message)
end
skynet.start(function()
skynet.dispatch("text", function(session, address, message)
print("simpledb",message, skynet.address(address), session)
local cmd, key , value = string.match(message, "(%w+) (%w+) ?(.*)")
local f = command[cmd]
if f then
f(key,value)
else
skynet.ret("Invalid command : "..message)
end
end)
skynet.register "SIMPLEDB"
end)
skynet.register "SIMPLEDB"