Skip to content

Commit aea515e

Browse files
Messages will be consumed when the side channel registers (#3573)
* Messages will be consumed when the side channel registers * addressing the comment * Update com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs Co-Authored-By: Chris Elion <chris.elion@unity3d.com> Co-authored-by: Chris Elion <celion@gmail.com>
1 parent 29ee576 commit aea515e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,20 @@ public void RegisterSideChannel(SideChannel sideChannel)
504504
"A side channel with type index {0} is already registered. You cannot register multiple " +
505505
"side channels of the same id.", channelId));
506506
}
507+
508+
var numMessages = m_CachedMessages.Count;
509+
for (int i = 0; i < numMessages; i++)
510+
{
511+
var cachedMessage = m_CachedMessages.Dequeue();
512+
if (channelId == cachedMessage.ChannelId)
513+
{
514+
sideChannel.OnMessageReceived(cachedMessage.Message);
515+
}
516+
else
517+
{
518+
m_CachedMessages.Enqueue(cachedMessage);
519+
}
520+
}
507521
m_SideChannels.Add(channelId, sideChannel);
508522
}
509523

0 commit comments

Comments
 (0)