/// <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; }
/// <summary> /// 发送数据 /// </summary> /// <param name="sessionId">会话ID</param> /// <param name="buffer">数据</param> /// <param name="offset">数据偏移</param> /// <param name="count">数据大小</param> public bool Send(ushort sessionId, byte[] buffer, int offset, int count) { if (SocketSvrMgr != null) { return(SocketSvrMgr.SendAsyncEvent(this, sessionId, buffer, offset, count)); } return(false); }