ElvishJerricco, on 25 March 2015 - 11:19 PM, said:
If program A registers protocol A, and program B registers protocol B, then when program B calls pm.waitForMessage(), program A's registered callback functions will still get called if anything gets sent on protocol A, even if program A has terminated
That shouldn't happen
waitForMessage() requires you to specify which protocol's messages to look for:
--# From the Pastebin, line 118
function waitForMessage(protocol,timeout,useRaw)
protocol = protocol or default
timeout = tonumber(timeout)
nAssert(protocolSets[protocol],"protocol doesn't exist",2)
local pull = useRaw and os.pullEventRaw or os.pullEvent
if timeout then local timer = os.startTimer(timeout) end
while true do
local eArgs = {pull()}
if eArgs[1] == "modem_message" then
if type(eArgs[5]) == "table" and eArgs[5][1] == protocol and eArgs[5][2] == protocolSets[protocol].version then --# The second statment checks that the same protocol sent it, the third then references protocolSets using the protocol name provided in the function call
if protocolSets[protocol][eArgs[5][3]] then
protocolSets[protocol][eArgs[5][3]](eArgs[4],eArgs[6],unpack(eArgs[5][4]))
end
end
elseif eArgs[1] == "timer" and eArgs[2] == timer then
return false
end
end
return false
end