Add remote listening cancelling
This commit is contained in:
parent
06d37428b6
commit
45904104f7
2 changed files with 8 additions and 2 deletions
2
bc.lua
2
bc.lua
|
|
@ -115,6 +115,8 @@ function bc:init(my_address, local_nouns, local_verbs)
|
|||
o.listening_remotes[message.noun] = o.listening_remotes[message.noun] or {}
|
||||
o.listening_remotes[message.noun][remoteAddress] = o.listening_remotes[message.noun][remoteAddress] or {}
|
||||
o.listening_remotes[message.noun][remoteAddress][message.id] = {query=message.query, qparam=message.qparam}
|
||||
elseif message.ty == message_type.request_stop_listening then
|
||||
o.listening_remotes[message.noun][remoteAddress][message.id] = nil
|
||||
elseif message.ty == message_type.listener_update then
|
||||
o.remote_listeners[message.noun][message.id].callback(o, message.value)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -80,12 +80,16 @@ function test_multinode_listening()
|
|||
i = false
|
||||
bc1:listen_cancel("foo", id) -- Test wether cancelling works
|
||||
local j = false
|
||||
bc2:listen_noun("foo", "onchange", nil, function(bc, foo)
|
||||
local rid = bc2:listen_noun("foo", "onchange", nil, function(bc, foo)
|
||||
j = true
|
||||
end)
|
||||
bc1:set_noun("foo", 1234)
|
||||
assert_true(j, "Remote listening failed")
|
||||
assert_false(i, "Cancelling listener failed")
|
||||
assert_false(i, "Cancelling local listener failed")
|
||||
bc2:listen_cancel("foo", rid)
|
||||
j = false
|
||||
bc1:set_noun("foo", 34)
|
||||
assert_false(j, "Cancelling remote listener failed")
|
||||
end
|
||||
|
||||
function test_listen_modes()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue