コード例 #1
0
 private void method_10(GClass91 gclass91_1, ErrorReason errorReason_0, Exception exception_0)
 {
     if (!this.bool_1)
     {
         this.Disconnect(errorReason_0, exception_0, true);
     }
     this.bool_1 = true;
     GClass91.GClass92.GDelegate6 disconnected = this.Disconnected;
     if (disconnected == null)
     {
         return;
     }
     disconnected(gclass91_1, errorReason_0, exception_0);
 }
コード例 #2
0
    public void Connect(string host, int port, bool forceNonLoopback = true, ProxySettings proxySettings = null)
    {
        this.method_8();
        this.method_4(new TcpClient());
        if (proxySettings != null)
        {
            try
            {
                GClass124 gclass = new GClass124(proxySettings.Host, proxySettings.Port, proxySettings.User, proxySettings.Password);
                this.method_4(gclass.imethod_7(host, port));
                goto IL_AC;
            }
            catch (Exception exception)
            {
                GClass91.GClass92.GDelegate6 disconnected = this.Disconnected;
                if (disconnected != null)
                {
                    disconnected(this, ErrorReason.ProxyError, exception);
                }
                return;
            }
        }
        if (forceNonLoopback)
        {
            this.method_3().Client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            GClass91.smethod_0(this.method_3().Client);
        }
        try
        {
            this.method_3().Connect(host, port);
        }
        catch (Exception exception2)
        {
            GClass91.GClass92.GDelegate6 disconnected2 = this.Disconnected;
            if (disconnected2 != null)
            {
                disconnected2(this, ErrorReason.ConnectionLost, exception2);
            }
            return;
        }
IL_AC:
        this.method_6(new Thread(new ThreadStart(this.method_7)));
        this.method_5().IsBackground = true;
        this.method_5().Start();
    }
コード例 #3
0
    public void Disconnect(ErrorReason reason, Exception ex = null, bool fromEvent = false)
    {
        if (this.bool_1)
        {
            return;
        }
        this.bool_1 = true;
        this.method_14();
        GClass91 socket = this.Socket;

        if (socket != null)
        {
            socket.method_8();
        }
        if (!fromEvent)
        {
            GClass91.GClass92.GDelegate6 disconnected = this.Disconnected;
            if (disconnected == null)
            {
                return;
            }
            disconnected(this.Socket, reason, ex);
        }
    }
コード例 #4
0
    private void method_7()
    {
        try
        {
            TcpClient tcpClient = this.method_3();
            if (tcpClient == null || tcpClient.Client == null)
            {
                return;
            }
            GClass91.GClass92.GDelegate5 connected = this.Connected;
            if (connected != null)
            {
                connected(this);
            }
            if (tcpClient == null || !tcpClient.Connected)
            {
                GClass91.GClass92.GDelegate6 disconnected = this.Disconnected;
                if (disconnected != null)
                {
                    disconnected(this, ErrorReason.ConnectionLost, null);
                }
                return;
            }
            NetworkStream stream = tcpClient.GetStream();
            byte[]        array  = new byte[4096];
            using (MemoryStream memoryStream = new MemoryStream(array))
            {
                using (BinaryStream binaryStream = memoryStream.smethod_2(true))
                {
                    for (;;)
                    {
                        TcpClient tcpClient2 = this.method_3();
                        if (tcpClient2 == null)
                        {
                            goto IL_120;
                        }
                        bool flag = tcpClient2.Connected;
IL_70:
                        if (!flag)
                        {
                            break;
                        }
                        try
                        {
                            memoryStream.Position = 0L;
                            int num = stream.Read(array, (int)memoryStream.Position, (int)(4096L - memoryStream.Position));
                            if (num == 0)
                            {
                                GClass91.GClass92.GDelegate6 disconnected2 = this.Disconnected;
                                if (disconnected2 != null)
                                {
                                    disconnected2(this, ErrorReason.ConnectionLost, new Exception("Socket has been closed"));
                                }
                                return;
                            }
                            Stream stream2 = binaryStream;
                            memoryStream.Position = 0L;
                            stream2.Position      = 0L;
                            GClass91.GClass92.GDelegate7 gdelegate = this.gdelegate7_0;
                            if (gdelegate != null)
                            {
                                gdelegate(this, binaryStream, array, num);
                            }
                            continue;
                        }
                        catch (Exception exception)
                        {
                            GClass91.GClass92.GDelegate6 disconnected3 = this.Disconnected;
                            if (disconnected3 != null)
                            {
                                disconnected3(this, ErrorReason.ConnectionLost, exception);
                            }
                            return;
                        }
IL_120:
                        flag = false;
                        goto IL_70;
                    }
                }
            }
        }
        catch
        {
        }
        GClass91.GClass92.GDelegate6 disconnected4 = this.Disconnected;
        if (disconnected4 == null)
        {
            return;
        }
        disconnected4(this, ErrorReason.ConnectionLost, null);
    }