in the examples create a new directory with the same level directory Myexample , the following new files are created under this directory:
Myexample/config , Content:
?
Root = "./"
Luaservice = root: " service/?. Lua; ". Root: " Myexample/eg1/?. Lua
Lualoader = root. "Lualib/loader.lua"
Lua_path = root: " Lualib/?. Lua; ". Root: " Lualib/?/init.lua "
Lua_cpath = root. "luaclib/?" So
Snax = root: " Examples/?. Lua; ". Root: " Test/?. Lua
?
--preload = "./examples/preload.lua"--run Preload.lua before every LUA service run
Thread = 8
Logger = Nil
LogPath = "."
Harbor = 1
Address = "127.0.0.1:2526"
master = "127.0.0.1:2013"
Start = "Main"--main script
Bootstrap = "Snlua Bootstrap"-The service for Bootstrap
standalone = "0.0.0.0:2013"
--Snax_interface_g = "Snax_g"
CPath = root: " cservice/?. So
--Daemon = "./skynet.pid"
?
Proto.lua is to define the communication protocol, code:
LocalSprotoparser=require"Sprotoparser"
LocalProto = {}
Proto.c2s = Sprotoparser.parse [[
. Package {
Type 0:integer
session 1:integer
}
handshake 1 {
Response {
msg 0:string
}
}
say 2 {
Request {
name 0:string
msg 1:s Tring
}
}
quit 3 {}
]]
proto.s2c = Sprotoparser.parse [[
. Package {
Type 0:integer
Session 1:integer
}
Heartbeat 1 {}
]]
return Proto
Skynet introductory example of Sproto