mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
add test for multicast
This commit is contained in:
14
examples/config.mc
Normal file
14
examples/config.mc
Normal 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
24
test/testmulticast2.lua
Normal 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)
|
||||||
Reference in New Issue
Block a user