Ejemplo n.º 1
0
    // Start is called before the first frame update
    public void Start()
    {
        Instance = this;
        DontDestroyOnLoad(gameObject);
        connectMenu.SetActive(false);

        Host(() => {
            try
            {
                Server s = Instantiate(ServerPrefab).GetComponent <Server>();
                s.Init();

                ClientTCP c = Instantiate(ClientTCPPrefab).GetComponent <ClientTCP>();
            }
            catch (Exception e)
            {
                Debug.Log(e.Message);
            }
        });
        Back(() => {
            Global.WinnerInt = -1;
            SceneManager.LoadScene("MultiplayerScene");
        });
        Connect(() => {
            string hostAddress = GameObject.Find("HostInput").GetComponent <TMP_InputField>().text;
            if (hostAddress == "")
            {
                hostAddress = "127.0.0.1";
            }

            try
            {
                ClientTCP c = Instantiate(ClientTCPPrefab).GetComponent <ClientTCP>();
                c.Connect();
                Debug.Log("by connect button");
            }
            catch (Exception e)
            {
                Debug.Log(e.Message);
            }
        });
    }
Ejemplo n.º 2
0
 void Start()
 {
     clientTCP.Connect();
 }
 public void Test_async_connect()
 {
     Debug.Log("Attempting to connect -- listening for server reply .. ");
     clientConnection.Connect( );
     clientConnection.ListenAndRecvAsync( );
 }
Ejemplo n.º 4
0
 public void Connect()
 {
     clientTCP.Connect();
 }