I’ve been trying to get my head around the new MLAPI, but I can’t figure out why my Client-side will not connect to my dedicated server.
Here what I have Server:
Connection Address: 127.0.0.1
Server Listening Port: 1974
if (MLAPI.NetworkManager.Singleton.IsListening == false)
{
UNetTransport mTransport = MLAPI.NetworkManager.Singleton.GetComponent<UNetTransport>();
if (mTransport != null)
{
mTransport.ConnectAddress = this.TxtIPAddress.text;
mTransport.ServerListenPort = Convert.ToInt32(this.TxtPort.text);
MLAPI.NetworkManager.Singleton.StartServer();
if (MLAPI.NetworkManager.Singleton.IsListening == true)
{
ColorBlock mColours = BtnServer.colors;
mColours.normalColor = Color.red;
BtnServer.colors = mColours;
BtnServer.GetComponentInChildren<TMP_Text>().text = "stop";
}
Debug.LogWarning("Server Is Listening");
}
}
else
{
ColorBlock mColours = BtnServer.colors;
mColours.normalColor = Color.green;
BtnServer.colors = mColours;
BtnServer.GetComponentInChildren<TMP_Text>().text = "start";
MLAPI.NetworkManager.Singleton.StopServer();
}
Now I did open up a Command Prompt and run netstat eg. “netstat -a -n -o” and I found it was UDP 0.0.0.0 and 1974 which is my port number. normally you don’t initially connect to a UDP socket you hand it over from TCP, but I understand this is different.
Here is my Client:
Connection Address: 127.0.0.1
Connection Port: 1974
if (MLAPI.NetworkManager.Singleton.IsConnectedClient == false)
{
UNetTransport mTransport = MLAPI.NetworkManager.Singleton.GetComponent<UNetTransport>();
if (mTransport != null)
{
mTransport.ConnectAddress = this.TxtIPAddress.text;
mTransport.ConnectPort = Convert.ToInt32(this.TxtPort.text);
MLAPI.NetworkManager.Singleton.StartClient();
if (MLAPI.NetworkManager.Singleton.IsConnectedClient == true)
{
ColorBlock mColours = BtnClient.colors;
mColours.normalColor = Color.red;
BtnClient.colors = mColours;
BtnClient.GetComponentInChildren<TMP_Text>().text = "stop";
}
}
}
else
{
ColorBlock mColours = BtnClient.colors;
mColours.normalColor = Color.green;
BtnClient.colors = mColours;
BtnClient.GetComponentInChildren<TMP_Text>().text = "start";
MLAPI.NetworkManager.Singleton.StopClient();
}
I did try an override the OnClientConnectedCallback event, but I got nothing, as far as I can see UNetTransport which is the ONLY transport in the MLAPI that is available is UDP so it’s connectionless?
any advice in pointing me in the correct direction would be great cheers.