/// <summary>
        /// 处理发送之后的事件
        /// </summary>
        /// <param name="e"></param>
        private void ProcessSentHandler(SocketAsyncEventArgs e)
        {
            try
            {
                tokenPool.Push(e);

                isConnected = (e.SocketError == SocketError.Success);

                SentCallback?.Invoke(e.UserToken as SocketToken, e.BytesTransferred);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        /// <summary>
        /// 处理发送的数据
        /// </summary>
        /// <param name="e"></param>
        private void ProcessSent(SocketAsyncEventArgs e)
        {
            try
            {
                //用完的对象放回对象池
                sendPool.Push(e);

                if (e.SocketError == SocketError.Success)
                {
                    //事件回调传递
                    SentCallback?.Invoke(e.UserToken as SocketToken, e.BytesTransferred);
                }
                else
                {
                    CloseClientSocket(e.UserToken as SocketToken);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }