0

I'm writing a multiplayer game where multiple clients on their phone should be able to connect to a PC-based server. My editor testing has all worked and the editor client connects fine, I've now built the client project onto my phone and nothing happens when I press to join the server.

Server Creation Method:

public void StartServer()
{
    DontDestroyOnLoad(gameObject);

    Debug.Log("Started");
    IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());
    Debug.Log(Dns.GetHostName());
    foreach (IPAddress addr in localIPs)
    {
        if (addr.AddressFamily == AddressFamily.InterNetwork)
        {
            ip = addr;
        }
    }
    var config = new NetPeerConfiguration("TEC") { Port = 7777, LocalAddress = ip } ;
    config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
    server = new NetServer(config);
    server.Start();
    Debug.Log("Server Started");
    createButton.gameObject.SetActive(false);
    serverInfoGroup.SetActive(true);
    ipSlot.gameObject.SetActive(true);
    playerTextSlotsGroup.SetActive(true);
    foreach (var playerSlot in playerTextSlots)
    {
        playerSlot.gameObject.SetActive(false);
    }
    ipSlot.text = Convert.ToString(ip);

Client Joining Method:

public void JoinServer()
{
    string ip = ipBox.text;
    userName = userBox.text;
    var config = new NetPeerConfiguration("TEC");
    Debug.Log("Connecting with " + ip + " and " + userName);
    client = new NetClient(config);
    client.RegisterReceivedCallback(new SendOrPostCallback(GotMessage));
    client.Start();
    NetOutgoingMessage approval = client.CreateMessage();
    approval.Write("dunno");
    client.Connect(ip, 7777, approval);
    attemptedConnection = true;
    Debug.Log("Server joined");
}

JoinServer should be called when a client hits the enter button, the two input boxes are where I enter the IP and username. I have been using the IPv4 address of my computer, gained from the server creation method which the editor can join on, but my phone build not.

I have now tested the program on an android emulator, but the same thing happens, no reaction to the connect to server button.

0 Answers0