private bool TryConnect()

in UnityProject/Assets/Scripts/Client/NetworkClient.cs [82:110]


	private bool TryConnect()
	{
		try
		{
			//Connect with matchmaking info
			Debug.Log("Connect..");
			Debug.Log(this.gameSessionInfo.publicIP);
			Debug.Log(this.gameSessionInfo.port);
			this.client = new TcpClient();
			var result = client.BeginConnect(this.gameSessionInfo.publicIP, this.gameSessionInfo.port, null, null);

			var success = result.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(2));

			if (!success)
			{
				throw new Exception("Failed to connect.");
			}
            client.NoDelay = true; // Use No Delay to send small messages immediately. UDP should be used for even faster messaging
			Debug.Log("Done");

			return true;
		}
		catch (Exception e)
		{
			Debug.Log(e.Message);
			client = null;
			return false;
		}
	}