I am using parallel processing to speed up processing of my game data.
This requires repeated uses of :SendMessage() and :BindToMessage(). But it seems that each time I use :SendMessage() it stacks and repeats the return message. As if I were constantly using :Connect() (which results in one event firing multiple functions, similar to what happens in my code)
In the deferred threads section, you see 8 green lines that correspond to a message being returned.
But here there are many more returns!
It seems that each time a message is sent, it returns the total amount of messages sent.
I.e.
send two messages, return two
send another two messages, return four
But when printing out each time a message is returned, it still just prints the two messages sent.
I am wondering if there is a way to disconnect(?) and prevent so many return messages from being sent.
Script Code:
debug.profilebegin("Send Messages")
local Messages=0
for i,column in pairs(ToUnzip) do
for o,chunk in pairs(column) do
Messages+=1
Actors[CurrentActor]:SendMessage("Unzip",world[i][o],i,o)
CurrentActor+=1
if CurrentActor>#Actors then
CurrentActor=1
end
end
end
print(Messages)
debug.profileend()
local MessageReturns=0
script.Parent:BindToMessage("ReturningChunk",function(Chunk,posX,posZ,num)
debug.profilebegin("SettingChunk")
MessageReturns+=1
if not Unzipped[posX] then
Unzipped[posX]={}
end
Unzipped[posX][posZ]=Chunk
debug.profileend()
end)
task.wait()
print(MessageReturns)
Actors Code:
local http=game:GetService("HttpService")
script.Parent:BindToMessageParallel("Unzip",function(Chunk,PositionX,PositionZ)
local UnzippedChunk=http:JSONDecode(Chunk)
game.ServerScriptService.Actor:SendMessage("ReturningChunk",UnzippedChunk,PositionX,PositionZ)
end)