Minor config changes

This commit is contained in:
Albin Corén 2018-01-08 09:13:48 +01:00
parent fa85e53f05
commit 9389c1c9c4
3 changed files with 12 additions and 9 deletions

View File

@ -10,7 +10,7 @@ namespace MLAPI
public class NetworkingConfiguration public class NetworkingConfiguration
{ {
public ushort ProtocolVersion = 0; public ushort ProtocolVersion = 0;
public Dictionary<string, QosType> Channels = new Dictionary<string, QosType>(); public SortedDictionary<string, QosType> Channels = new SortedDictionary<string, QosType>();
public List<string> MessageTypes = new List<string>(); public List<string> MessageTypes = new List<string>();
public int MessageBufferSize = 65535; public int MessageBufferSize = 65535;
public int MaxMessagesPerFrame = 150; public int MaxMessagesPerFrame = 150;
@ -19,16 +19,16 @@ namespace MLAPI
public string Address = "127.0.0.1"; public string Address = "127.0.0.1";
public int ClientConnectionBufferTimeout = 10; public int ClientConnectionBufferTimeout = 10;
public bool ConnectionApproval = false; public bool ConnectionApproval = false;
public Action<byte[], int, Action<int, bool>> ConnectionApprovalCallback; public Action<byte[], int, Action<int, bool>> ConnectionApprovalCallback = null;
public byte[] ConnectionData; public byte[] ConnectionData = new byte[0];
public bool HandleObjectSpawning = true; public bool HandleObjectSpawning = true;
//TODO //TODO
public bool CompressMessages = false; 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 //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 //TODO
public bool EncryptMessages = false; public bool EncryptMessages = false;
public bool UseUPnP = true; public bool UseUPnP = false;
public Action<bool, IPAddress> UPnPCompleteCallback; public Action<bool, IPAddress> UPnPCompleteCallback = null;
//Cached config hash //Cached config hash
private byte[] ConfigHash = null; private byte[] ConfigHash = null;

View File

@ -9,8 +9,9 @@ using UnityEngine;
namespace MLAPI.Helper 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<bool, IPAddress> callback) internal static void AttemptPortMap(int port, Action<bool, IPAddress> callback)
{ {
bool invoked = false; bool invoked = false;
@ -49,7 +50,7 @@ namespace MLAPI.Helper
Mapping[] mappings = task.Result.ToArray(); Mapping[] mappings = task.Result.ToArray();
if(mappings.Length == 0) if(mappings.Length == 0)
{ {
if (!invoked) if (!invoked && callback != null)
callback(false, publicIPAddress); callback(false, publicIPAddress);
invoked = true; invoked = true;
} }
@ -59,7 +60,7 @@ namespace MLAPI.Helper
{ {
if(mappings[i].PrivatePort == port) if(mappings[i].PrivatePort == port)
{ {
if (!invoked) if (!invoked && callback != null)
callback(true, publicIPAddress); callback(true, publicIPAddress);
invoked = true; invoked = true;
} }
@ -76,7 +77,7 @@ namespace MLAPI.Helper
{ {
if (e.InnerException is NatDeviceNotFoundException) if (e.InnerException is NatDeviceNotFoundException)
{ {
if (!invoked) if (!invoked && callback != null)
callback(false, publicIPAddress); callback(false, publicIPAddress);
invoked = true; invoked = true;
} }

View File

@ -12,6 +12,8 @@
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>