码迷,mamicode.com
首页 > Web开发 > 详细

Skynet入门范例之sproto

时间:2017-10-19 21:13:18      阅读:637      评论:0      收藏:0      [点我收藏+]

标签:integer   interface   reload   新建   pre   ade   pid   str   stand   

examples同一级目录新建目录myexample,该目录下面新建以下几个文件:

myexample/config,内容:

?

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是定义通信协议,代码:

local sprotoparser = require "sprotoparser"

local proto = {}

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 : string
}
}

quit 3 {}

]]

proto.s2c = sprotoparser.parse [[
.package {
type 0 : integer
session 1 : integer
}

heartbeat 1 {}
]]

return proto

Skynet入门范例之sproto

标签:integer   interface   reload   新建   pre   ade   pid   str   stand   

原文地址:http://www.cnblogs.com/skiing886/p/7694813.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!