Skip to content

Commit 9389c1c

Browse files
committed
Minor config changes
1 parent fa85e53 commit 9389c1c

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

MLAPI/Data/NetworkingConfiguration.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace MLAPI
1010
public class NetworkingConfiguration
1111
{
1212
public ushort ProtocolVersion = 0;
13-
public Dictionary<string, QosType> Channels = new Dictionary<string, QosType>();
13+
public SortedDictionary<string, QosType> Channels = new SortedDictionary<string, QosType>();
1414
public List<string> MessageTypes = new List<string>();
1515
public int MessageBufferSize = 65535;
1616
public int MaxMessagesPerFrame = 150;
@@ -19,16 +19,16 @@ public class NetworkingConfiguration
1919
public string Address = "127.0.0.1";
2020
public int ClientConnectionBufferTimeout = 10;
2121
public bool ConnectionApproval = false;
22-
public Action<byte[], int, Action<int, bool>> ConnectionApprovalCallback;
23-
public byte[] ConnectionData;
22+
public Action<byte[], int, Action<int, bool>> ConnectionApprovalCallback = null;
23+
public byte[] ConnectionData = new byte[0];
2424
public bool HandleObjectSpawning = true;
2525
//TODO
2626
public bool CompressMessages = false;
2727
//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
2828
//TODO
2929
public bool EncryptMessages = false;
30-
public bool UseUPnP = true;
31-
public Action<bool, IPAddress> UPnPCompleteCallback;
30+
public bool UseUPnP = false;
31+
public Action<bool, IPAddress> UPnPCompleteCallback = null;
3232

3333
//Cached config hash
3434
private byte[] ConfigHash = null;

MLAPI/Helper/UPnPHelper.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99

1010
namespace MLAPI.Helper
1111
{
12-
public class UPnPHelper
12+
public static class UPnPHelper
1313
{
14+
//Needs to be threaded, Currently freezes the game for up to 10 sec
1415
internal static void AttemptPortMap(int port, Action<bool, IPAddress> callback)
1516
{
1617
bool invoked = false;
@@ -49,7 +50,7 @@ internal static void AttemptPortMap(int port, Action<bool, IPAddress> callback)
4950
Mapping[] mappings = task.Result.ToArray();
5051
if(mappings.Length == 0)
5152
{
52-
if (!invoked)
53+
if (!invoked && callback != null)
5354
callback(false, publicIPAddress);
5455
invoked = true;
5556
}
@@ -59,7 +60,7 @@ internal static void AttemptPortMap(int port, Action<bool, IPAddress> callback)
5960
{
6061
if(mappings[i].PrivatePort == port)
6162
{
62-
if (!invoked)
63+
if (!invoked && callback != null)
6364
callback(true, publicIPAddress);
6465
invoked = true;
6566
}
@@ -76,7 +77,7 @@ internal static void AttemptPortMap(int port, Action<bool, IPAddress> callback)
7677
{
7778
if (e.InnerException is NatDeviceNotFoundException)
7879
{
79-
if (!invoked)
80+
if (!invoked && callback != null)
8081
callback(false, publicIPAddress);
8182
invoked = true;
8283
}

MLAPI/MLAPI.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<TargetFrameworkProfile />
15+
<NuGetPackageImportStamp>
16+
</NuGetPackageImportStamp>
1517
</PropertyGroup>
1618
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1719
<DebugSymbols>true</DebugSymbols>

0 commit comments

Comments
 (0)