Skip to content

Commit 5310c40

Browse files
committed
Improved NetworkConfig init
1 parent 07178c6 commit 5310c40

File tree

1 file changed

+12
-33
lines changed

1 file changed

+12
-33
lines changed

MLAPI/MonoBehaviours/Core/NetworkingManager.cs

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,22 @@ private ConnectionConfig Init()
274274
if (NetworkConfig.Channels[i].Encrypted)
275275
{
276276
NetworkConfig.EncryptedChannels.Add(NetworkConfig.Channels[i].Name);
277+
NetworkConfig.EncryptedChannelsHashSet.Add(NetworkConfig.Channels[i].Name);
277278
}
278279
}
279280
}
280281

282+
if (NetworkConfig.AllowPassthroughMessages)
283+
{
284+
for (int i = 0; i < NetworkConfig.MessageTypes.Count; i++)
285+
{
286+
if (NetworkConfig.MessageTypes[i].Passthrough)
287+
NetworkConfig.PassthroughMessageHashSet.Add(MessageManager.messageTypes[NetworkConfig.MessageTypes[i].Name]);
288+
}
289+
}
290+
281291
HashSet<string> channelNames = new HashSet<string>();
292+
//Register internal channels
282293
for (int i = 0; i < internalChannels.Count; i++)
283294
{
284295
if (channelNames.Contains(internalChannels[i].Name))
@@ -354,33 +365,7 @@ private ConnectionConfig Init()
354365
NetworkSceneManager.SetCurrentSceneIndex();
355366
}
356367

357-
if(NetworkConfig.EnableEncryption)
358-
{
359-
List<string> channelNameList = NetworkConfig.Channels.Select(x => x.Name).ToList();
360-
for (int i = 0; i < NetworkConfig.EncryptedChannels.Count; i++)
361-
{
362-
if (NetworkConfig.EncryptedChannelsHashSet.Contains(NetworkConfig.EncryptedChannels[i]))
363-
{
364-
Debug.LogWarning("MLAPI: Duplicate encrypted channel: " + NetworkConfig.EncryptedChannels[i]);
365-
continue;
366-
}
367-
else if (!channelNameList.Contains(NetworkConfig.EncryptedChannels[i]))
368-
{
369-
Debug.LogWarning("MLAPI: Channel " + NetworkConfig.EncryptedChannels[i] + " doesn't exist");
370-
}
371-
NetworkConfig.EncryptedChannelsHashSet.Add(NetworkConfig.EncryptedChannels[i]);
372-
}
373-
}
374-
375-
if (NetworkConfig.AllowPassthroughMessages)
376-
{
377-
for (int i = 0; i < NetworkConfig.MessageTypes.Count; i++)
378-
{
379-
if (NetworkConfig.MessageTypes[i].Passthrough)
380-
NetworkConfig.PassthroughMessageHashSet.Add(MessageManager.messageTypes[NetworkConfig.MessageTypes[i].Name]);
381-
}
382-
}
383-
368+
//Register user channels
384369
for (int i = 0; i < NetworkConfig.Channels.Count; i++)
385370
{
386371
if(channelNames.Contains(NetworkConfig.Channels[i].Name))
@@ -622,12 +607,6 @@ private void Shutdown()
622607
NetworkTransport.Shutdown();
623608
}
624609

625-
//Receive stuff
626-
//internal int hostId;
627-
//private int clientId;
628-
//private int channelId;
629-
//private int receivedSize;
630-
//private byte error;
631610
private float lastReceiveTickTime;
632611
private float lastSendTickTime;
633612
private float lastEventTickTime;

0 commit comments

Comments
 (0)