Example #1
0
 public virtual void Disconnect()
 {
     this.m_AsyncConnect = NetworkClient.ConnectState.Disconnected;
     ClientScene.HandleClientDisconnect(this.m_Connection);
     if (this.m_Connection != null)
     {
         this.m_Connection.Disconnect();
         this.m_Connection.Dispose();
         this.m_Connection = null;
         NetworkTransport.RemoveHost(this.m_ClientId);
     }
 }
Example #2
0
        /// <summary>
        ///   <para>This is used by a client that has lost the connection to the old host, to reconnect to the new host of a game.</para>
        /// </summary>
        /// <param name="serverIp">The IP address of the new host.</param>
        /// <param name="serverPort">The port of the new host.</param>
        /// <returns>
        ///   <para>True if able to reconnect.</para>
        /// </returns>
        public bool ReconnectToNewHost(string serverIp, int serverPort)
        {
            if (!NetworkClient.active)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError((object)"Reconnect - NetworkClient must be active");
                }
                return(false);
            }
            if (this.m_Connection == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError((object)"Reconnect - no old connection exists");
                }
                return(false);
            }
            if (LogFilter.logInfo)
            {
                Debug.Log((object)("NetworkClient Reconnect " + serverIp + ":" + (object)serverPort));
            }
            ClientScene.HandleClientDisconnect(this.m_Connection);
            ClientScene.ClearLocalPlayers();
            this.m_Connection.Disconnect();
            this.m_Connection = (NetworkConnection)null;
            this.m_ClientId   = NetworkTransport.AddHost(this.m_HostTopology, 0);
            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 (LogFilter.logDebug)
                {
                    Debug.Log((object)("Async DNS START:" + hostNameOrAddress));
                }
                this.m_AsyncConnect = NetworkClient.ConnectState.Resolving;
                Dns.BeginGetHostAddresses(hostNameOrAddress, new AsyncCallback(NetworkClient.GetHostAddressesCallback), (object)this);
            }
            return(true);
        }
 public NetworkClient(NetworkConnection conn)
 {
     if (LogFilter.logDev)
     {
         Debug.Log("Client created version " + Version.Current);
     }
     this.m_MsgBuffer = new byte[65535];
     this.m_MsgReader = new NetworkReader(this.m_MsgBuffer);
     NetworkClient.AddClient(this);
     NetworkClient.SetActive(true);
     this.m_Connection   = conn;
     this.m_AsyncConnect = NetworkClient.ConnectState.Connected;
     conn.SetHandlers(this.m_MessageHandlers);
     this.RegisterSystemHandlers(false);
 }
        private void ConnectWithRelay(MatchInfo info)
        {
            this.m_AsyncConnect = NetworkClient.ConnectState.Connecting;
            this.Update();
            byte b;

            this.m_ClientConnectionId = NetworkTransport.ConnectToNetworkPeer(this.m_ClientId, info.address, info.port, 0, 0, info.networkId, Utility.GetSourceID(), info.nodeId, out b);
            this.m_Connection         = (NetworkConnection)Activator.CreateInstance(this.m_NetworkConnectionClass);
            this.m_Connection.SetHandlers(this.m_MessageHandlers);
            this.m_Connection.Initialize(info.address, this.m_ClientId, this.m_ClientConnectionId, this.m_HostTopology);
            if (b != 0)
            {
                Debug.LogError("ConnectToNetworkPeer Error: " + b);
            }
        }
 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);
     }
 }
Example #6
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);
            }
        }
        internal virtual void Update()
        {
            if (this.m_ClientId != -1)
            {
                switch (this.m_AsyncConnect)
                {
                case NetworkClient.ConnectState.None:
                case NetworkClient.ConnectState.Resolving:
                case NetworkClient.ConnectState.Disconnected:
                    return;

                case NetworkClient.ConnectState.Resolved:
                    this.m_AsyncConnect = NetworkClient.ConnectState.Connecting;
                    this.ContinueConnect();
                    return;

                case NetworkClient.ConnectState.Failed:
                    this.GenerateConnectError(11);
                    this.m_AsyncConnect = NetworkClient.ConnectState.Disconnected;
                    return;
                }
                if (this.m_Connection != null)
                {
                    if ((int)Time.time != this.m_StatResetTime)
                    {
                        this.m_Connection.ResetStats();
                        this.m_StatResetTime = (int)Time.time;
                    }
                }
                int  num = 0;
                byte b;
                for (;;)
                {
                    int num2;
                    int channelId;
                    int numBytes;
                    NetworkEventType networkEventType = NetworkTransport.ReceiveFromHost(this.m_ClientId, out num2, out channelId, this.m_MsgBuffer, (int)((ushort)this.m_MsgBuffer.Length), out numBytes, out b);
                    if (this.m_Connection != null)
                    {
                        this.m_Connection.lastError = (NetworkError)b;
                    }
                    if (networkEventType != NetworkEventType.Nothing)
                    {
                        if (LogFilter.logDev)
                        {
                            Debug.Log(string.Concat(new object[]
                            {
                                "Client event: host=",
                                this.m_ClientId,
                                " event=",
                                networkEventType,
                                " error=",
                                b
                            }));
                        }
                    }
                    switch (networkEventType)
                    {
                    case NetworkEventType.DataEvent:
                        if (b != 0)
                        {
                            goto Block_11;
                        }
                        this.m_MsgReader.SeekZero();
                        this.m_Connection.TransportReceive(this.m_MsgBuffer, numBytes, channelId);
                        break;

                    case NetworkEventType.ConnectEvent:
                        if (LogFilter.logDebug)
                        {
                            Debug.Log("Client connected");
                        }
                        if (b != 0)
                        {
                            goto Block_10;
                        }
                        this.m_AsyncConnect = NetworkClient.ConnectState.Connected;
                        this.m_Connection.InvokeHandlerNoData(32);
                        break;

                    case NetworkEventType.DisconnectEvent:
                        if (LogFilter.logDebug)
                        {
                            Debug.Log("Client disconnected");
                        }
                        this.m_AsyncConnect = NetworkClient.ConnectState.Disconnected;
                        if (b != 0)
                        {
                            if (b != 6)
                            {
                                this.GenerateDisconnectError((int)b);
                            }
                        }
                        ClientScene.HandleClientDisconnect(this.m_Connection);
                        if (this.m_Connection != null)
                        {
                            this.m_Connection.InvokeHandlerNoData(33);
                        }
                        break;

                    case NetworkEventType.Nothing:
                        break;

                    default:
                        if (LogFilter.logError)
                        {
                            Debug.LogError("Unknown network message type received: " + networkEventType);
                        }
                        break;
                    }
                    if (++num >= 500)
                    {
                        goto Block_17;
                    }
                    if (this.m_ClientId == -1)
                    {
                        goto Block_19;
                    }
                    if (networkEventType == NetworkEventType.Nothing)
                    {
                        goto IL_2C6;
                    }
                }
Block_10:
                this.GenerateConnectError((int)b);
                return;

Block_11:
                this.GenerateDataError((int)b);
                return;

Block_17:
                if (LogFilter.logDebug)
                {
                    Debug.Log("MaxEventsPerFrame hit (" + 500 + ")");
                }
Block_19:
IL_2C6:
                if (this.m_Connection != null && this.m_AsyncConnect == NetworkClient.ConnectState.Connected)
                {
                    this.m_Connection.FlushChannels();
                }
            }
        }
        public void Connect(EndPoint secureTunnelEndPoint)
        {
            bool usePlatformSpecificProtocols = NetworkTransport.DoesEndPointUsePlatformProtocols(secureTunnelEndPoint);

            this.PrepareForConnect(usePlatformSpecificProtocols);
            if (LogFilter.logDebug)
            {
                Debug.Log("Client Connect to remoteSockAddr");
            }
            if (secureTunnelEndPoint == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("Connect failed: null endpoint passed in");
                }
                this.m_AsyncConnect = NetworkClient.ConnectState.Failed;
            }
            else if (secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetwork && secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetworkV6)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("Connect failed: Endpoint AddressFamily must be either InterNetwork or InterNetworkV6");
                }
                this.m_AsyncConnect = NetworkClient.ConnectState.Failed;
            }
            else
            {
                string fullName = secureTunnelEndPoint.GetType().FullName;
                if (fullName == "System.Net.IPEndPoint")
                {
                    IPEndPoint ipendPoint = (IPEndPoint)secureTunnelEndPoint;
                    this.Connect(ipendPoint.Address.ToString(), ipendPoint.Port);
                }
                else if (fullName != "UnityEngine.XboxOne.XboxOneEndPoint" && fullName != "UnityEngine.PS4.SceEndPoint" && fullName != "UnityEngine.PSVita.SceEndPoint")
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("Connect failed: invalid Endpoint (not IPEndPoint or XboxOneEndPoint or SceEndPoint)");
                    }
                    this.m_AsyncConnect = NetworkClient.ConnectState.Failed;
                }
                else
                {
                    byte b = 0;
                    this.m_RemoteEndPoint = secureTunnelEndPoint;
                    this.m_AsyncConnect   = NetworkClient.ConnectState.Connecting;
                    try
                    {
                        this.m_ClientConnectionId = NetworkTransport.ConnectEndPoint(this.m_ClientId, this.m_RemoteEndPoint, 0, out b);
                    }
                    catch (Exception arg)
                    {
                        if (LogFilter.logError)
                        {
                            Debug.LogError("Connect failed: Exception when trying to connect to EndPoint: " + arg);
                        }
                        this.m_AsyncConnect = NetworkClient.ConnectState.Failed;
                        return;
                    }
                    if (this.m_ClientConnectionId == 0)
                    {
                        if (LogFilter.logError)
                        {
                            Debug.LogError("Connect failed: Unable to connect to EndPoint (" + b + ")");
                        }
                        this.m_AsyncConnect = NetworkClient.ConnectState.Failed;
                    }
                    else
                    {
                        this.m_Connection = (NetworkConnection)Activator.CreateInstance(this.m_NetworkConnectionClass);
                        this.m_Connection.SetHandlers(this.m_MessageHandlers);
                        this.m_Connection.Initialize(this.m_ServerIp, this.m_ClientId, this.m_ClientConnectionId, this.m_HostTopology);
                    }
                }
            }
        }
        public bool ReconnectToNewHost(EndPoint secureTunnelEndPoint)
        {
            bool result;

            if (!NetworkClient.active)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("Reconnect - NetworkClient must be active");
                }
                result = false;
            }
            else if (this.m_Connection == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("Reconnect - no old connection exists");
                }
                result = false;
            }
            else
            {
                if (LogFilter.logInfo)
                {
                    Debug.Log("NetworkClient Reconnect to remoteSockAddr");
                }
                ClientScene.HandleClientDisconnect(this.m_Connection);
                ClientScene.ClearLocalPlayers();
                this.m_Connection.Disconnect();
                this.m_Connection = null;
                this.m_ClientId   = NetworkTransport.AddHost(this.m_HostTopology, this.m_HostPort);
                if (secureTunnelEndPoint == null)
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("Reconnect failed: null endpoint passed in");
                    }
                    this.m_AsyncConnect = NetworkClient.ConnectState.Failed;
                    result = false;
                }
                else if (secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetwork && secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetworkV6)
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("Reconnect failed: Endpoint AddressFamily must be either InterNetwork or InterNetworkV6");
                    }
                    this.m_AsyncConnect = NetworkClient.ConnectState.Failed;
                    result = false;
                }
                else
                {
                    string fullName = secureTunnelEndPoint.GetType().FullName;
                    if (fullName == "System.Net.IPEndPoint")
                    {
                        IPEndPoint ipendPoint = (IPEndPoint)secureTunnelEndPoint;
                        this.Connect(ipendPoint.Address.ToString(), ipendPoint.Port);
                        result = (this.m_AsyncConnect != NetworkClient.ConnectState.Failed);
                    }
                    else if (fullName != "UnityEngine.XboxOne.XboxOneEndPoint" && fullName != "UnityEngine.PS4.SceEndPoint")
                    {
                        if (LogFilter.logError)
                        {
                            Debug.LogError("Reconnect failed: invalid Endpoint (not IPEndPoint or XboxOneEndPoint or SceEndPoint)");
                        }
                        this.m_AsyncConnect = NetworkClient.ConnectState.Failed;
                        result = false;
                    }
                    else
                    {
                        byte b = 0;
                        this.m_RemoteEndPoint = secureTunnelEndPoint;
                        this.m_AsyncConnect   = NetworkClient.ConnectState.Connecting;
                        try
                        {
                            this.m_ClientConnectionId = NetworkTransport.ConnectEndPoint(this.m_ClientId, this.m_RemoteEndPoint, 0, out b);
                        }
                        catch (Exception arg)
                        {
                            if (LogFilter.logError)
                            {
                                Debug.LogError("Reconnect failed: Exception when trying to connect to EndPoint: " + arg);
                            }
                            this.m_AsyncConnect = NetworkClient.ConnectState.Failed;
                            return(false);
                        }
                        if (this.m_ClientConnectionId == 0)
                        {
                            if (LogFilter.logError)
                            {
                                Debug.LogError("Reconnect failed: Unable to connect to EndPoint (" + b + ")");
                            }
                            this.m_AsyncConnect = NetworkClient.ConnectState.Failed;
                            result = false;
                        }
                        else
                        {
                            this.m_Connection = (NetworkConnection)Activator.CreateInstance(this.m_NetworkConnectionClass);
                            this.m_Connection.SetHandlers(this.m_MessageHandlers);
                            this.m_Connection.Initialize(this.m_ServerIp, this.m_ClientId, this.m_ClientConnectionId, this.m_HostTopology);
                            result = true;
                        }
                    }
                }
            }
            return(result);
        }
        public bool ReconnectToNewHost(string serverIp, int serverPort)
        {
            bool result;

            if (!NetworkClient.active)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("Reconnect - NetworkClient must be active");
                }
                result = false;
            }
            else if (this.m_Connection == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("Reconnect - no old connection exists");
                }
                result = false;
            }
            else
            {
                if (LogFilter.logInfo)
                {
                    Debug.Log(string.Concat(new object[]
                    {
                        "NetworkClient Reconnect ",
                        serverIp,
                        ":",
                        serverPort
                    }));
                }
                ClientScene.HandleClientDisconnect(this.m_Connection);
                ClientScene.ClearLocalPlayers();
                this.m_Connection.Disconnect();
                this.m_Connection = null;
                this.m_ClientId   = NetworkTransport.AddHost(this.m_HostTopology, this.m_HostPort);
                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 (LogFilter.logDebug)
                    {
                        Debug.Log("Async DNS START:" + serverIp);
                    }
                    this.m_AsyncConnect = NetworkClient.ConnectState.Resolving;
                    Dns.BeginGetHostAddresses(serverIp, new AsyncCallback(NetworkClient.GetHostAddressesCallback), this);
                }
                result = true;
            }
            return(result);
        }
Example #11
0
        internal virtual void Update()
        {
            if (this.m_ClientId == -1)
            {
                return;
            }
            switch (this.m_AsyncConnect)
            {
            case NetworkClient.ConnectState.None:
                break;

            case NetworkClient.ConnectState.Resolving:
                break;

            case NetworkClient.ConnectState.Resolved:
                this.m_AsyncConnect = NetworkClient.ConnectState.Connecting;
                this.ContinueConnect();
                break;

            case NetworkClient.ConnectState.Disconnected:
                break;

            case NetworkClient.ConnectState.Failed:
                this.GenerateConnectError(11);
                this.m_AsyncConnect = NetworkClient.ConnectState.Disconnected;
                break;

            default:
                if (this.m_Connection != null && (int)Time.time != this.m_StatResetTime)
                {
                    this.m_Connection.ResetStats();
                    this.m_StatResetTime = (int)Time.time;
                }
                NetworkEventType fromHost;
                do
                {
                    int  num1 = 0;
                    int  connectionId;
                    int  channelId;
                    int  receivedSize;
                    byte error;
                    fromHost = NetworkTransport.ReceiveFromHost(this.m_ClientId, out connectionId, out channelId, this.m_MsgBuffer, (int)(ushort)this.m_MsgBuffer.Length, out receivedSize, out error);
                    if (fromHost != NetworkEventType.Nothing && LogFilter.logDev)
                    {
                        Debug.Log((object)("Client event: host=" + (object)this.m_ClientId + " event=" + (object)fromHost + " error=" + (object)error));
                    }
                    switch (fromHost)
                    {
                    case NetworkEventType.DataEvent:
                        if ((int)error != 0)
                        {
                            this.GenerateDataError((int)error);
                            return;
                        }
                        NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Incoming, (short)29, "msg", 1);
                        this.m_MsgReader.SeekZero();
                        this.m_Connection.TransportRecieve(this.m_MsgBuffer, receivedSize, channelId);
                        goto case NetworkEventType.Nothing;

                    case NetworkEventType.ConnectEvent:
                        if (LogFilter.logDebug)
                        {
                            Debug.Log((object)"Client connected");
                        }
                        if ((int)error != 0)
                        {
                            this.GenerateConnectError((int)error);
                            return;
                        }
                        this.m_AsyncConnect = NetworkClient.ConnectState.Connected;
                        this.m_Connection.InvokeHandlerNoData((short)32);
                        goto case NetworkEventType.Nothing;

                    case NetworkEventType.DisconnectEvent:
                        if (LogFilter.logDebug)
                        {
                            Debug.Log((object)"Client disconnected");
                        }
                        this.m_AsyncConnect = NetworkClient.ConnectState.Disconnected;
                        if ((int)error != 0 && (int)error != 6)
                        {
                            this.GenerateDisconnectError((int)error);
                        }
                        ClientScene.HandleClientDisconnect(this.m_Connection);
                        if (this.m_Connection != null)
                        {
                            this.m_Connection.InvokeHandlerNoData((short)33);
                            goto case NetworkEventType.Nothing;
                        }
                        else
                        {
                            goto case NetworkEventType.Nothing;
                        }

                    case NetworkEventType.Nothing:
                        int num2;
                        if ((num2 = num1 + 1) >= 500)
                        {
                            if (LogFilter.logDebug)
                            {
                                Debug.Log((object)("MaxEventsPerFrame hit (" + (object)500 + ")"));
                                goto label_34;
                            }
                            else
                            {
                                goto label_34;
                            }
                        }
                        else
                        {
                            continue;
                        }

                    default:
                        if (LogFilter.logError)
                        {
                            Debug.LogError((object)("Unknown network message type received: " + (object)fromHost));
                            goto case NetworkEventType.Nothing;
                        }
                        else
                        {
                            goto case NetworkEventType.Nothing;
                        }
                    }
                }while (this.m_ClientId != -1 && fromHost != NetworkEventType.Nothing);
label_34:
                if (this.m_Connection == null || this.m_AsyncConnect != NetworkClient.ConnectState.Connected)
                {
                    break;
                }
                this.m_Connection.FlushChannels();
                break;
            }
        }
 private void ConnectWithRelay(MatchInfo info)
 {
     this.m_AsyncConnect = NetworkClient.ConnectState.Connecting;
       this.Update();
       byte error;
       this.m_ClientConnectionId = NetworkTransport.ConnectToNetworkPeer(this.m_ClientId, info.address, info.port, 0, 0, info.networkId, Utility.GetSourceID(), info.nodeId, out error);
       this.m_Connection = new NetworkConnection();
       this.m_Connection.Initialize(info.address, this.m_ClientId, this.m_ClientConnectionId, this.m_hostTopology);
       if (LogFilter.logDebug)
     Debug.Log((object) ("Client Relay Slot Id: " + (object) this.m_RelaySlotId));
       if ((int) error == 0)
     return;
       Debug.LogError((object) ("ConnectToNetworkPeer Error: " + (object) error));
 }
        internal virtual void Update()
        {
            if (this.m_ClientId == -1)
            return;
              switch (this.m_AsyncConnect)
              {
            case NetworkClient.ConnectState.None:
              break;
            case NetworkClient.ConnectState.Resolving:
              break;
            case NetworkClient.ConnectState.Resolved:
              this.m_AsyncConnect = NetworkClient.ConnectState.Connecting;
              this.ContinueConnect();
              break;
            case NetworkClient.ConnectState.Disconnected:
              break;
            case NetworkClient.ConnectState.Failed:
              this.GenerateConnectError(11);
              this.m_AsyncConnect = NetworkClient.ConnectState.Disconnected;
              break;
            default:
              if (this.m_Connection != null && (int) Time.time != this.m_StatResetTime)
              {
            this.m_Connection.ResetStats();
            this.m_StatResetTime = (int) Time.time;
              }
              int num = 0;
              NetworkEventType networkEventType;
              do
              {
            int connectionId;
            int channelId;
            int receivedSize;
            byte error;
            networkEventType = NetworkTransport.ReceiveFromHost(this.m_ClientId, out connectionId, out channelId, this.m_MsgBuffer, (int) (ushort) this.m_MsgBuffer.Length, out receivedSize, out error);
            if (networkEventType != NetworkEventType.Nothing && LogFilter.logDev)
            {
              object[] objArray = new object[6];
              int index1 = 0;
              string str1 = "Client event: host=";
              objArray[index1] = (object) str1;
              int index2 = 1;
              // ISSUE: variable of a boxed type
              __Boxed<int> local1 = (ValueType) this.m_ClientId;
              objArray[index2] = (object) local1;
              int index3 = 2;
              string str2 = " event=";
              objArray[index3] = (object) str2;
              int index4 = 3;
              // ISSUE: variable of a boxed type
              __Boxed<NetworkEventType> local2 = (System.Enum) networkEventType;
              objArray[index4] = (object) local2;
              int index5 = 4;
              string str3 = " error=";
              objArray[index5] = (object) str3;
              int index6 = 5;
              // ISSUE: variable of a boxed type
              __Boxed<byte> local3 = (ValueType) error;
              objArray[index6] = (object) local3;
              Debug.Log((object) string.Concat(objArray));
            }
            switch (networkEventType)
            {
              case NetworkEventType.DataEvent:
                if ((int) error != 0)
                {
                  this.GenerateDataError((int) error);
                  return;
                }
                NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Incoming, (short) 29, "msg", 1);
                this.m_MsgReader.SeekZero();
                this.m_Connection.HandleMessage(this.m_MessageHandlers.GetHandlers(), this.m_MsgReader, receivedSize, channelId);
                goto case 3;

              case NetworkEventType.ConnectEvent:
                if (LogFilter.logDebug)
                  Debug.Log((object) "Client connected");
                if ((int) error != 0)
                {
                  this.GenerateConnectError((int) error);
                  return;
                }
                this.m_AsyncConnect = NetworkClient.ConnectState.Connected;
                this.m_MessageHandlers.InvokeHandlerNoData((short) 32, this.m_Connection);
                goto case 3;

              case NetworkEventType.DisconnectEvent:
                if (LogFilter.logDebug)
                  Debug.Log((object) "Client disconnected");
                this.m_AsyncConnect = NetworkClient.ConnectState.Disconnected;
                if ((int) error != 0)
                  this.GenerateDisconnectError((int) error);
                ClientScene.HandleClientDisconnect(this.m_Connection);
                this.m_MessageHandlers.InvokeHandlerNoData((short) 33, this.m_Connection);
                goto case 3;

              case NetworkEventType.Nothing:
                if (++num >= NetworkClient.MaxEventsPerFrame)
                {
                  if (LogFilter.logDebug)
                  {
                    Debug.Log((object) ("MaxEventsPerFrame hit (" + (object) NetworkClient.MaxEventsPerFrame + ")"));
                    goto label_34;
                  }
                  else
                    goto label_34;
                }
                else
                  continue;
              default:
                if (LogFilter.logError)
                {
                  Debug.LogError((object) ("Unknown network message type received: " + (object) networkEventType));
                  goto case 3;
                }
                else
                  goto case 3;
            }
              }
              while (this.m_ClientId != -1 && networkEventType != NetworkEventType.Nothing);
            label_34:
              if (this.m_Connection == null || this.m_AsyncConnect != NetworkClient.ConnectState.Connected)
            break;
              this.m_Connection.FlushInternalBuffer();
              break;
              }
        }
 /// <summary>
 /// 
 /// <para>
 /// Disconnect from server.
 /// </para>
 /// 
 /// </summary>
 public virtual void Disconnect()
 {
     this.m_AsyncConnect = NetworkClient.ConnectState.Disconnected;
       ClientScene.HandleClientDisconnect(this.m_Connection);
       if (this.m_Connection == null)
     return;
       this.m_Connection.Disconnect();
       this.m_Connection.Dispose();
       this.m_Connection = (NetworkConnection) null;
 }
 public void Connect(EndPoint secureTunnelEndPoint)
 {
     this.PrepareForConnect();
       if (LogFilter.logDebug)
     Debug.Log((object) "Client Connect to remoteSockAddr");
       if (secureTunnelEndPoint == null)
       {
     if (LogFilter.logError)
       Debug.LogError((object) "Connect failed: null endpoint passed in");
     this.m_AsyncConnect = NetworkClient.ConnectState.Failed;
       }
       else if (secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetwork && secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetworkV6)
       {
     if (LogFilter.logError)
       Debug.LogError((object) "Connect failed: Endpoint AddressFamily must be either InterNetwork or InterNetworkV6");
     this.m_AsyncConnect = NetworkClient.ConnectState.Failed;
       }
       else
       {
     string fullName = secureTunnelEndPoint.GetType().FullName;
     if (fullName == "System.Net.IPEndPoint")
     {
       IPEndPoint ipEndPoint = (IPEndPoint) secureTunnelEndPoint;
       this.Connect(ipEndPoint.Address.ToString(), ipEndPoint.Port);
     }
     else if (fullName != "UnityEngine.XboxOne.XboxOneEndPoint")
     {
       if (LogFilter.logError)
     Debug.LogError((object) "Connect failed: invalid Endpoint (not IPEndPoint or XboxOneEndPoint)");
       this.m_AsyncConnect = NetworkClient.ConnectState.Failed;
     }
     else
     {
       byte error = (byte) 0;
       this.m_RemoteEndPoint = secureTunnelEndPoint;
       this.m_AsyncConnect = NetworkClient.ConnectState.Connecting;
       try
       {
     this.m_ClientConnectionId = NetworkTransport.ConnectEndPoint(this.m_ClientId, this.m_RemoteEndPoint, 0, out error);
       }
       catch (Exception ex)
       {
     Debug.LogError((object) ("Connect failed: Exception when trying to connect to EndPoint: " + ex.ToString()));
       }
       if (this.m_ClientConnectionId == 0 && LogFilter.logError)
     Debug.LogError((object) ("Connect failed: Unable to connect to EndPoint (" + (object) error + ")"));
       this.m_Connection = new NetworkConnection();
       this.m_Connection.Initialize(this.m_ServerIp, this.m_ClientId, this.m_ClientConnectionId, this.m_hostTopology);
     }
       }
 }
 /// <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)
       {
     object[] objArray = new object[4];
     int index1 = 0;
     string str1 = "Client Connect: ";
     objArray[index1] = (object) str1;
     int index2 = 1;
     string str2 = serverIp;
     objArray[index2] = (object) str2;
     int index3 = 2;
     string str3 = ":";
     objArray[index3] = (object) str3;
     int index4 = 3;
     // ISSUE: variable of a boxed type
     __Boxed<int> local = (ValueType) serverPort;
     objArray[index4] = (object) local;
     Debug.Log((object) string.Concat(objArray));
       }
       string hostNameOrAddress = serverIp;
       this.m_ServerPort = serverPort;
       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 (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);
       }
 }