mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 04:33:05 +00:00
bugfix. remote publish first, see issue #391
This commit is contained in:
@@ -66,6 +66,16 @@ end
|
|||||||
-- publish a message, for local node, use the message pointer (call mc.bind to add the reference)
|
-- publish a message, for local node, use the message pointer (call mc.bind to add the reference)
|
||||||
-- for remote node, call remote_publish. (call mc.unpack and skynet.tostring to convert message pointer to string)
|
-- for remote node, call remote_publish. (call mc.unpack and skynet.tostring to convert message pointer to string)
|
||||||
local function publish(c , source, pack, size)
|
local function publish(c , source, pack, size)
|
||||||
|
local remote = channel_remote[c]
|
||||||
|
if remote then
|
||||||
|
-- remote publish should unpack the pack, because we should not publish the pointer out.
|
||||||
|
local _, msg, sz = mc.unpack(pack, size)
|
||||||
|
local msg = skynet.tostring(msg,sz)
|
||||||
|
for node in pairs(remote) do
|
||||||
|
remote_publish(node, c, source, msg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local group = channel[c]
|
local group = channel[c]
|
||||||
if group == nil or next(group) == nil then
|
if group == nil or next(group) == nil then
|
||||||
-- dead channel, delete the pack. mc.bind returns the pointer in pack
|
-- dead channel, delete the pack. mc.bind returns the pointer in pack
|
||||||
@@ -79,15 +89,6 @@ local function publish(c , source, pack, size)
|
|||||||
-- the msg is a pointer to the real message, publish pointer in local is ok.
|
-- the msg is a pointer to the real message, publish pointer in local is ok.
|
||||||
skynet.redirect(k, source, "multicast", c , msg)
|
skynet.redirect(k, source, "multicast", c , msg)
|
||||||
end
|
end
|
||||||
local remote = channel_remote[c]
|
|
||||||
if remote then
|
|
||||||
-- remote publish should unpack the pack, because we should not publish the pointer out.
|
|
||||||
local _, msg, sz = mc.unpack(pack, size)
|
|
||||||
local msg = skynet.tostring(msg,sz)
|
|
||||||
for node in pairs(remote) do
|
|
||||||
remote_publish(node, c, source, msg)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
skynet.register_protocol {
|
skynet.register_protocol {
|
||||||
|
|||||||
Reference in New Issue
Block a user