refactor: enhance message handling for dual-mode channel compatibility using Channels.match()
This commit is contained in:
@@ -491,11 +491,13 @@ parallel.waitForAny(
|
||||
local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
|
||||
stats.messagesReceived = stats.messagesReceived + 1
|
||||
|
||||
if channel == STATUS_CHANNEL or channel == CHANNEL_RECEIVE then
|
||||
-- Uses Channels.match() for dual-mode safety: accepts messages on
|
||||
-- both legacy (101/102/103) and target (4211/4212/4213) during migration.
|
||||
if (Channels.match('remoteturtle.status', channel) or Channels.match('remoteturtle.response', channel)) then
|
||||
if type(message) == "table" then
|
||||
forwardToServer(message)
|
||||
end
|
||||
elseif channel == POCKET_CHANNEL then
|
||||
elseif Channels.match('remoteturtle.pocket', channel) then
|
||||
if type(message) == "table" then
|
||||
handlePocketMessage(message)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user