/// <summary> /// 构造会话管理器 /// </summary> /// <param name="context"></param> /// <param name="bufferSize"></param> /// <param name="count"></param> /// <param name="completed"></param> public SessionManager(IContext context, int bufferSize, int count, EventHandler <SocketAsyncEventArgs> completed, TimeSpan timeOut) { _userTokenPool = new UserTokenPool(context, count); _session = new MemoryCacheHelper <IUserToken>(); _timeOut = timeOut; _bufferSize = bufferSize; _completed = completed; _bufferManager = new BufferManager(_bufferSize * count, _bufferSize); _bufferManager.InitBuffer(); _argsPool = new SocketAsyncEventArgsPool(count * 2); _argsPool.InitPool(_completed); //不存在时处理 _session.OnChanged += _session_OnChanged; }