diff --git a/MLAPI/Data/NetworkingConfiguration.cs b/MLAPI/Data/NetworkingConfiguration.cs index eb043f2..a49e98f 100644 --- a/MLAPI/Data/NetworkingConfiguration.cs +++ b/MLAPI/Data/NetworkingConfiguration.cs @@ -10,7 +10,7 @@ namespace MLAPI public class NetworkingConfiguration { public ushort ProtocolVersion = 0; - public Dictionary Channels = new Dictionary(); + public SortedDictionary Channels = new SortedDictionary(); public List MessageTypes = new List(); public int MessageBufferSize = 65535; public int MaxMessagesPerFrame = 150; @@ -19,16 +19,16 @@ namespace MLAPI public string Address = "127.0.0.1"; public int ClientConnectionBufferTimeout = 10; public bool ConnectionApproval = false; - public Action> ConnectionApprovalCallback; - public byte[] ConnectionData; + public Action> ConnectionApprovalCallback = null; + public byte[] ConnectionData = new byte[0]; public bool HandleObjectSpawning = true; //TODO public bool CompressMessages = false; //Should only be used for dedicated servers and will require the servers RSA keypair being hard coded into clients in order to exchange a AES key //TODO public bool EncryptMessages = false; - public bool UseUPnP = true; - public Action UPnPCompleteCallback; + public bool UseUPnP = false; + public Action UPnPCompleteCallback = null; //Cached config hash private byte[] ConfigHash = null; diff --git a/MLAPI/Helper/UPnPHelper.cs b/MLAPI/Helper/UPnPHelper.cs index b617cc2..979f971 100644 --- a/MLAPI/Helper/UPnPHelper.cs +++ b/MLAPI/Helper/UPnPHelper.cs @@ -9,8 +9,9 @@ using UnityEngine; namespace MLAPI.Helper { - public class UPnPHelper + public static class UPnPHelper { + //Needs to be threaded, Currently freezes the game for up to 10 sec internal static void AttemptPortMap(int port, Action callback) { bool invoked = false; @@ -49,7 +50,7 @@ namespace MLAPI.Helper Mapping[] mappings = task.Result.ToArray(); if(mappings.Length == 0) { - if (!invoked) + if (!invoked && callback != null) callback(false, publicIPAddress); invoked = true; } @@ -59,7 +60,7 @@ namespace MLAPI.Helper { if(mappings[i].PrivatePort == port) { - if (!invoked) + if (!invoked && callback != null) callback(true, publicIPAddress); invoked = true; } @@ -76,7 +77,7 @@ namespace MLAPI.Helper { if (e.InnerException is NatDeviceNotFoundException) { - if (!invoked) + if (!invoked && callback != null) callback(false, publicIPAddress); invoked = true; } diff --git a/MLAPI/MLAPI.csproj b/MLAPI/MLAPI.csproj index 12ea40d..3090e03 100644 --- a/MLAPI/MLAPI.csproj +++ b/MLAPI/MLAPI.csproj @@ -12,6 +12,8 @@ v3.5 512 + + true