Beispiel #1
0
 void joinGame()
 {
     if (ClientNetworkManager.joinGame(GameObject.Find("textIP").GetComponent <Text>().text))
     {
         transform.Find("MenuPanel").gameObject.SetActive(false);
         transform.Find("LoginPanel").gameObject.SetActive(true);
     }
     else
     {
         transform.Find("PopupPanel").gameObject.SetActive(true);
         GameObject.Find("textPopup").GetComponent <Text>().text = "Error joining server";
     }
 }
    public static bool hostGame()
    {
        try
        {
            tcpListener = new TcpListener(IPAddress.Any, NET_PORT);
            tcpListener.Start();
            tcpListener.BeginAcceptTcpClient(acceptConnection, tcpListener);

            isHosting = true;
            Account.loadAccounts();
            clients = new List <Client>();
            return(ClientNetworkManager.joinGame("127.0.0.1"));
        }
        catch (Exception ex)
        {
            Debug.LogWarning("Hosting server failed: " + ex);
            return(false);
        }
    }