BeardedManStudios.Network.Networking.Connect C# (CSharp) Метод

Connect() публичный статический Метод

Create and connect a client to the specified server ip and port
public static Connect ( string ip, ushort port, TransportationProtocolType comType, bool winRT = false, bool useNat = false, bool standAlone = false ) : BeardedManStudios.Network.NetWorker
ip string The host (usually ip address or domain name) to connect to
port ushort The port for the particular server that this connection is attempting
comType TransportationProtocolType The transportation protocol type that is to be used
winRT bool If this is Windows Phone or Windows Store, this should be true, otherwise default to false
useNat bool
standAlone bool
Результат BeardedManStudios.Network.NetWorker
		public static NetWorker Connect(string ip, ushort port, TransportationProtocolType comType, bool winRT = false, bool useNat = false, bool standAlone = false)
		{
			Threading.ThreadManagement.Initialize();
			Unity.MainThreadManager.Create();

			if (Sockets == null) Sockets = new Dictionary<ushort, NetWorker>();

			if (Sockets.ContainsKey(port))
			{
#if UNITY_IOS || UNITY_IPHONE
				if (comType == TransportationProtocolType.UDP)
					Sockets[port] = new CrossPlatformUDP(false, 0);
				else
					Sockets[port] = new DefaultClientTCP();
#else
				if (Sockets[port].Connected)
					throw new NetworkException(8, "Socket has already been initialized on that port");
				else if (Sockets[port].Disconnected)
					Sockets.Remove(port);
				else
					return Sockets[port];	// It has not finished connecting yet
#endif
			}
			else if (comType == TransportationProtocolType.UDP)
				Sockets.Add(port, new CrossPlatformUDP(false, 0));
			else
			{
				if (winRT)
					Sockets.Add(port, new WinMobileClient());
				else
					Sockets.Add(port, new DefaultClientTCP());
			}

			Sockets[port].connected += delegate()
			{
				if (connectedInvoker != null)
					connectedInvoker(Sockets[port]);
			};

			Sockets[port].UseNatHolePunch = useNat;
			Sockets[port].Connect(ip, port);

			if (!standAlone)
				SimpleNetworkedMonoBehavior.Initialize(Sockets[port]);

			return Sockets[port];
		}