Skip to content

Commit f80d585

Browse files
committed
fix: Fixes invalid channelId handling
1 parent 73c2c74 commit f80d585

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

MLAPI/Transports/UNET/UnetTransport.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,16 @@ public override void Send(ulong clientId, ArraySegment<byte> data, string channe
4343
{
4444
GetUnetConnectionDetails(clientId, out byte hostId, out ushort connectionId);
4545

46-
int channelId = channelNameToId[channelName];
46+
int channelId = 0;
47+
48+
if (channelNameToId.ContainsKey(channelName))
49+
{
50+
channelId = channelNameToId[channelName];
51+
}
52+
else
53+
{
54+
channelId = channelNameToId["MLAPI_INTERNAL"];
55+
}
4756

4857
byte[] buffer;
4958

@@ -110,7 +119,14 @@ public override NetEventType PollEvent(out ulong clientId, out string channelNam
110119
payload = new ArraySegment<byte>(messageBuffer, 0, receivedSize);
111120
}
112121

113-
channelName = channelIdToName[channelId];
122+
if (channelIdToName.ContainsKey(channelId))
123+
{
124+
channelName = channelIdToName[channelId];
125+
}
126+
else
127+
{
128+
channelName = "MLAPI_INTERNAL";
129+
}
114130

115131
if (connectTask != null && hostId == serverHostId && connectionId == serverConnectionId)
116132
{

0 commit comments

Comments
 (0)