首页 > Web开发 > 详细

Skynet入门范例之sproto

时间:2017-10-19 20:36:29      阅读:439      评论:0      收藏:0      [点我收藏+]

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!