Esempio n. 1
0
    /// <summary>
    /// Starts a server.
    /// </summary>
    public void StartServer()
    {
        try
        {
            Instantiate(Server).GetComponent <BackgammonServer>();

            BackgammonClient client = Instantiate(Client).GetComponent <BackgammonClient>();
            client.ClientName = GameManager.Instance.UserName;
            client.IsHost     = true;
            client.ConnectToServer("127.0.0.1", 9000);
        }
        catch (Exception e)
        {
            Debug.Log(e.Message);
        }
    }
Esempio n. 2
0
    /// <summary>
    /// Starts a client using the specified host address.
    /// </summary>
    /// <param name="hostAddress"></param>
    public void StartClient(string hostAddress)
    {
        if (string.IsNullOrEmpty(hostAddress))
        {
            hostAddress = "127.0.0.1";
        }

        try
        {
            BackgammonClient client = Instantiate(Client).GetComponent <BackgammonClient>();
            client.ClientName = GameManager.Instance.UserName;
            client.IsHost     = false;
            client.ConnectToServer(hostAddress, 9000);
        }
        catch (Exception e)
        {
            Debug.Log(e.Message);
        }
    }