BeardedManStudios.Network.DefaultServerTCP.ThreadedConnect C# (CSharp) Метод

ThreadedConnect() приватный Метод

private ThreadedConnect ( object hostAndPort ) : void
hostAndPort object
Результат void
		private void ThreadedConnect(object hostAndPort)
		{
			string hostAddress = (string)((object[])hostAndPort)[0];
			ushort port = (ushort)((object[])hostAndPort)[1];

			// Create an instance of the TcpListener class.
			tcpListener = null;
			if (string.IsNullOrEmpty(hostAddress) || hostAddress == "127.0.0.1" || hostAddress == "localhost")
				ipAddress = IPAddress.Any;
			else
				ipAddress = IPAddress.Parse(hostAddress);

			try
			{
				// Set the listener on the local IP address 
				// and specify the port.
				tcpListener = new TcpListener(ipAddress, (int)port);
				tcpListener.Start();

				Players = new List<NetworkingPlayer>();
				Me = new NetworkingPlayer(ServerPlayerCounter++, "127.0.0.1", tcpListener, "SERVER");

				listenWorker = new BackgroundWorker();
				listenWorker.WorkerSupportsCancellation = true;
				listenWorker.WorkerReportsProgress = true;
				listenWorker.DoWork += Listen;
				listenWorker.ProgressChanged += listenWorker_ProgressChanged;
				listenWorker.RunWorkerCompleted += WorkCompleted;
				listenWorker.RunWorkerAsync(tcpListener);

				readWorker = new BackgroundWorker();
				readWorker.WorkerSupportsCancellation = true;
				//readWorker.WorkerReportsProgress = true;
				//readWorker.ProgressChanged += StreamReceived;
				readWorker.DoWork += ReadAsync;
				readWorker.RunWorkerAsync();

				OnConnected();
			}
			catch (Exception e)
			{
				UnityEngine.Debug.LogException(e);
				Disconnect();
			}
		}