Skip to content
This repository has been archived by the owner on Mar 24, 2019. It is now read-only.

Commit

Permalink
Updated examples to use UPnP when using Host mode
Browse files Browse the repository at this point in the history
  • Loading branch information
TwoTenPvP committed Jan 7, 2018
1 parent 974f22b commit 401d56d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .gitignore
Expand Up @@ -35,4 +35,8 @@ sysinfo.txt
*.unitypackage
Assets/MLAPI.dll.meta
Assets/UnityEngine.dll*
Assets/UnityEngine.xml*
Assets/UnityEngine.xml*
Assets/Open.Nat.dll.meta
Assets/Open.Nat.xml*
Assets/System.Threading.dll.meta
Assets/System.Threading.xml*
Binary file modified Assets/MLAPI.dll
Binary file not shown.
11 changes: 11 additions & 0 deletions Assets/NetManagerHud.cs
@@ -1,4 +1,5 @@
using MLAPI;
using System.Net;
using UnityEngine;
using UnityEngine.Networking;

Expand Down Expand Up @@ -38,11 +39,21 @@ private void OnGUI()
{
Address = "127.0.0.1",
Port = 7777,
UseUPnP = true,
UPnPCompleteCallback = OnUPnPComplete
};
config.Channels.Add("PositionUpdates", QosType.Reliable);
config.MessageTypes.Add("PositionUpdate");
config.MessageTypes.Add("SetClientPosition");
NetworkingManager.singleton.StartHost(config);
}
}

private void OnUPnPComplete(bool success, IPAddress ipAddress)
{
//Did UPNP succeed
Debug.Log(success);
//If it succeded. This is the public ip address
Debug.Log(ipAddress);
}
}
Binary file added Assets/Open.Nat.dll
Binary file not shown.
Binary file added Assets/System.Threading.dll
Binary file not shown.

0 comments on commit 401d56d

Please sign in to comment.