diff --git a/examples/config.mc b/examples/config.mc new file mode 100644 index 00000000..2e019784 --- /dev/null +++ b/examples/config.mc @@ -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" diff --git a/test/testmulticast2.lua b/test/testmulticast2.lua new file mode 100644 index 00000000..0f55b77d --- /dev/null +++ b/test/testmulticast2.lua @@ -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)