Ejemplo n.º 1
0
        /// <summary>
        /// 释放接收数据缓冲区与异步事件对象
        /// </summary>
        private void close()
        {
            if (Socket != null)
            {
                try
                {
#if DOTNET2
                DisposeSocket();
#else
                    if (asyncEventArgs == null) DisposeSocket();
                    else
                    {
                        asyncEventArgs.Completed -= onReceive;
                        DisposeSocket();
                        SocketAsyncEventArgsPool.PushNotNull(ref asyncEventArgs);
                    }
#endif
                }
                catch (Exception error)
                {
                    Server.AddLog(error);
                }
                Buffer.Free();
                ReceiveBigBuffer.TryFree();
                FreeSerializer();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 释放接收数据缓冲区与异步事件对象
        /// </summary>
        private void close()
        {
            if (isClose) freeOutput();
            else
            {
                isClose = true;
                try
                {
#if DOTNET2
                    if (onSendAsyncCallback != null)
                    {
                        onSendAsyncCallback = null;
                        ServerSocket.DisposeSocket();
                    }
#else
                    if (sendAsyncEventArgs != null)
                    {
                        sendAsyncEventArgs.Completed -= onSend;
                        ServerSocket.DisposeSocket();
                        SocketAsyncEventArgsPool.PushNotNull(ref sendAsyncEventArgs);
                    }
#endif
                }
                catch (Exception error)
                {
                    Server.AddLog(error);
                }
                freeBuffer();
                callOnClose();
            }
        }
Ejemplo n.º 3
0
        internal void Free()
        {
#if !DOTNET2
            receiveAsyncEventArgs.Completed -= onReceive;
            SocketAsyncEventArgsPool.PushNotNull(ref receiveAsyncEventArgs);
#endif
            Buffer.Free();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 释放资源
        /// </summary>
        public override void Dispose()
        {
#if DOTNET2
            if (onReceiveAsyncCallback != null)
#else
            if (receiveAsyncEventArgs != null)
#endif
            {
#if DOTNET2
                onReceiveAsyncCallback = onSendAsyncCallback = null;
#else
                receiveAsyncEventArgs.Completed -= onReceiveAsyncCallback;
                sendAsyncEventArgs.Completed -= onSendAsyncCallback;
                SocketAsyncEventArgsPool.PushNotNull(ref receiveAsyncEventArgs);
                SocketAsyncEventArgsPool.PushNotNull(ref sendAsyncEventArgs);
#endif
                Buffer.Free();
                Header.Free();
#if !DOTNET2
                if (boundaryReceiver == null) boundaryReceiver.Free();
#endif
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 释放接收数据缓冲区与异步事件对象
        /// </summary>
        private void close()
        {
            try
            {
#if DOTNET2
                DisposeSocket();
#else
                if (receiveAsyncEventArgs == null) DisposeSocket();
                else
                {
                    receiveAsyncEventArgs.Completed -= onReceive;
                    DisposeSocket();
                    SocketAsyncEventArgsPool.PushNotNull(ref receiveAsyncEventArgs);
                }
#endif
            }
            catch (Exception error)
            {
                Server.AddLog(error);
            }
            CloseFree();
            if (Sender != null) Sender.Close();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 释放接收数据缓冲区与异步事件对象
        /// </summary>
        private void close()
        {
            isClose = true;
            try
            {
#if DOTNET2
                DisposeSocket();
#else
                if (receiveAsyncEventArgs == null) DisposeSocket();
                else
                {
                    receiveAsyncEventArgs.Completed -= onReceive;
                    DisposeSocket();
                    SocketAsyncEventArgsPool.PushNotNull(ref receiveAsyncEventArgs);
                }
#endif
            }
            catch (Exception error)
            {
                ClientCreator.CommandClient.AddLog(error);
            }
            CloseFree();
        }
Ejemplo n.º 7
0
 internal void Free()
 {
     socketAsyncEventArgs.Completed -= onReceiveAsyncCallback;
     SocketAsyncEventArgsPool.PushNotNull(ref socketAsyncEventArgs);
 }