示例#1
0
        public override void Dispose()
        {
            if (this.IsDisposed)
            {
                return;
            }

            base.Dispose();

            try
            {
                if (this.Error == ErrorCode.ERR_Success)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        this.Disconnect();
                    }
                }
            }
            catch (Exception)
            {
                // ignored
            }

            if (this.kcp != IntPtr.Zero)
            {
                Kcp.KcpRelease(this.kcp);
                this.kcp = IntPtr.Zero;
            }
            this.socket = null;
            this.memoryStream.Dispose();
        }
示例#2
0
        public override void Dispose()
        {
            bool IsDisposeLocal = this.IsDispose;

            base.Dispose();
            this.IsDispose = true;
            if (IsDisposeLocal)
            {
                return;
            }

            this.OnError(ErrorCode.ERR_SocketError);

            try
            {
                if (this.Error == ErrorCode.ERR_Success)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        this.Disconnect();
                    }
                }
            }
            catch (Exception)
            {
                // ignored
            }

            if (this.kcp != IntPtr.Zero)
            {
                Kcp.KcpRelease(this.kcp);
                this.kcp = IntPtr.Zero;
            }
            this.socket = null;
            this.memoryStream.Dispose();
            kService = null;
        }