-
-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Hello,
here the YouTube video describing the issue: https://youtu.be/aHU8hiAHERY
Tested: locally with public IP - MLAPI.Puncher.Server plus the two game instances were all running on the same device simultaneously.
Used code snippets:
`public void ui_setupHostSingle()
{
closeConnection();
m_listenTask = Task.Factory.StartNew(() =>
{
try
{
string puncherServerHost = puncherIPAddressInputField.text;
using (m_listenPeer = new PuncherClient(puncherServerHost, PUNCHER_SERVER_PORT))
{
Debug.Log("[LISTENER] Listening for single punch on our port 1234...");
IPEndPoint endpoint = m_listenPeer.ListenForSinglePunch(new IPEndPoint(IPAddress.Any, GAME_SERVER_PORT));
Debug.Log("[LISTENER] Connector: " + endpoint + " punched through our NAT");
}
}
catch (Exception e)
{
Debug.LogError(e);
}
});
NetworkingManager.Singleton.GetComponent<EnetTransport.EnetTransport>().Port = GAME_SERVER_PORT;
NetworkingManager.Singleton.ConnectionApprovalCallback += approvalCheck;
NetworkingManager.Singleton.StartHost();
}
public void ui_setupHostLoop()
{
closeConnection();
m_listenTask = Task.Factory.StartNew(() =>
{
try
{
string puncherServerHost = puncherIPAddressInputField.text;
using (m_listenPeer = new PuncherClient(puncherServerHost, PUNCHER_SERVER_PORT))
{
Debug.Log("[LISTENER] Listening for single punch on our port 1234...");
m_listenPeer.OnConnectorPunchSuccessful += (endpoint) =>
{
Debug.Log("[LISTENER] Connector: " + endpoint + " punched through our NAT");
};
m_listenPeer.ListenForPunches(new IPEndPoint(IPAddress.Any, GAME_SERVER_PORT));
}
}
catch (Exception e)
{
Debug.LogError(e);
}
});
NetworkingManager.Singleton.GetComponent<EnetTransport.EnetTransport>().Port = GAME_SERVER_PORT;
NetworkingManager.Singleton.ConnectionApprovalCallback += approvalCheck;
NetworkingManager.Singleton.StartHost();
}
public void ui_setupClient()
{
closeConnection();
string address = connectToIPAddressInputField.text;
string puncherServerHost = puncherIPAddressInputField.text;
using (PuncherClient connectPeer = new PuncherClient(puncherServerHost, PUNCHER_SERVER_PORT))
{
Debug.Log("[CONNECTOR] Punching...");
if (connectPeer.TryPunch(IPAddress.Parse(address), out IPEndPoint connectResult))
{
Debug.Log("[CONNECTOR] Punched through to peer: " + connectResult);
NetworkingManager.Singleton.GetComponent<EnetTransport.EnetTransport>().Port = (ushort)connectResult.Port;
NetworkingManager.Singleton.GetComponent<EnetTransport.EnetTransport>().Address = connectResult.Address.ToString();
NetworkingManager.Singleton.NetworkConfig.ConnectionData = System.Text.Encoding.ASCII.GetBytes("room password");
NetworkingManager.Singleton.StartClient();
}
else
{
Debug.LogError("[CONNECTOR] Failed to punch");
}
}
}`
Metadata
Metadata
Assignees
Labels
No labels