add test for multicast

This commit is contained in:
Cloud Wu
2014-04-30 12:29:11 +08:00
parent 4a92dfaa65
commit 091f91ede3
2 changed files with 38 additions and 0 deletions

14
examples/config.mc Normal file
View File

@@ -0,0 +1,14 @@
root = "./"
thread = 8
logger = nil
harbor = 2
address = "127.0.0.1:2527"
master = "127.0.0.1:2013"
start = "testmulticast2" -- main script
bootstrap = "snlua bootstrap" -- The service for bootstrap
--standalone = "0.0.0.0:2013"
luaservice = root.."service/?.lua;"..root.."test/?.lua;"..root.."examples/?.lua"
lualoader = "lualib/loader.lua"
-- preload = "./examples/preload.lua" -- run preload.lua before every lua service run
snax = root.."examples/?.lua;"..root.."test/?.lua"
cpath = root.."cservice/?.so"

24
test/testmulticast2.lua Normal file
View File

@@ -0,0 +1,24 @@
local skynet = require "skynet"
local dc = require "datacenter"
local mc = require "multicast"
skynet.start(function()
print("remote start")
skynet.monitor("simplemonitor", true)
local console = skynet.newservice("console")
local channel = dc.get "MCCHANNEL"
for i=1,10 do
local sub = skynet.newservice("testmulticast", "sub")
skynet.call(sub, "lua", "init", channel)
end
local c = mc.new {
channel = channel ,
dispatch = function(...) print("======>", ...) end,
}
c:subscribe()
c:publish("Remote message")
c:unsubscribe()
c:publish("Remote message2")
c:delete()
skynet.exit()
end)