Ejemplo n.º 1
0
 public void Connect(string serverIp, int serverPort)
 {
     this.PrepareForConnect();
     if (LogFilter.logDebug)
     {
         Debug.Log(string.Concat(new object[]
         {
             "Client Connect: ",
             serverIp,
             ":",
             serverPort
         }));
     }
     this.m_ServerPort = serverPort;
     if (Application.platform == RuntimePlatform.WebGLPlayer)
     {
         this.m_ServerIp     = serverIp;
         this.m_AsyncConnect = NetworkClient.ConnectState.Resolved;
     }
     else if (serverIp.Equals("127.0.0.1") || serverIp.Equals("localhost"))
     {
         this.m_ServerIp     = "127.0.0.1";
         this.m_AsyncConnect = NetworkClient.ConnectState.Resolved;
     }
     else if (serverIp.IndexOf(":") != -1 && NetworkClient.IsValidIpV6(serverIp))
     {
         this.m_ServerIp     = serverIp;
         this.m_AsyncConnect = NetworkClient.ConnectState.Resolved;
     }
     else
     {
         if (LogFilter.logDebug)
         {
             Debug.Log("Async DNS START:" + serverIp);
         }
         this.m_RequestedServerHost = serverIp;
         this.m_AsyncConnect        = NetworkClient.ConnectState.Resolving;
         if (NetworkClient.< > f__mg$cache0 == null)
         {
             NetworkClient.< > f__mg$cache0 = new AsyncCallback(NetworkClient.GetHostAddressesCallback);
         }
         Dns.BeginGetHostAddresses(serverIp, NetworkClient.< > f__mg$cache0, this);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///   <para>Connect client to a NetworkServer instance.</para>
        /// </summary>
        /// <param name="serverIp">Target IP address or hostname.</param>
        /// <param name="serverPort">Target port number.</param>
        public void Connect(string serverIp, int serverPort)
        {
            this.PrepareForConnect();
            if (LogFilter.logDebug)
            {
                Debug.Log((object)("Client Connect: " + serverIp + ":" + (object)serverPort));
            }
            string hostNameOrAddress = serverIp;

            this.m_ServerPort = serverPort;
            if (Application.platform == RuntimePlatform.WebGLPlayer)
            {
                this.m_ServerIp     = hostNameOrAddress;
                this.m_AsyncConnect = NetworkClient.ConnectState.Resolved;
            }
            else if (serverIp.Equals("127.0.0.1") || serverIp.Equals("localhost"))
            {
                this.m_ServerIp     = "127.0.0.1";
                this.m_AsyncConnect = NetworkClient.ConnectState.Resolved;
            }
            else if (serverIp.IndexOf(":") != -1 && NetworkClient.IsValidIpV6(serverIp))
            {
                this.m_ServerIp     = serverIp;
                this.m_AsyncConnect = NetworkClient.ConnectState.Resolved;
            }
            else
            {
                if (LogFilter.logDebug)
                {
                    Debug.Log((object)("Async DNS START:" + hostNameOrAddress));
                }
                this.m_RequestedServerHost = hostNameOrAddress;
                this.m_AsyncConnect        = NetworkClient.ConnectState.Resolving;
                Dns.BeginGetHostAddresses(hostNameOrAddress, new AsyncCallback(NetworkClient.GetHostAddressesCallback), (object)this);
            }
        }