/// <summary>
        /// 销毁当前对象并且从服务器列表中删除
        /// </summary>
        public void Destroy()
        {
            // 不存活就不存在销毁
            if (!isAlive)
            {
                return;
            }
            isAlive = false;
            // 移除套接字参数
            sendEventArgs.Destroy();
            if (receiveEventArgs != null)
            {
                receiveEventArgs.Dispose();
            }

            // 移除管理器
            if (socketSvrMgr != null)
            {
                socketSvrMgr.RemoveExistClient(this);
            }
            // 重置
            receiveEventArgs = null;
            socket           = null;
            rBuffer          = null;
            Target           = null;
            hySocket         = null;
        }
Beispiel #2
0
        /// <summary>
        /// 关闭
        /// </summary>
        public virtual void Close()
        {
            if (!isRecving)
            {
                return;
            }
            isRecving = false;

            sendEventArgs.Destroy();

            Target = null;
            clientSocket.Close();
        }