public ErrorCode ChechUserToken(long time) { if (time < this._lastReprot) { return(ErrorCode.Success); } this._lastReprot = time + 2000; foreach (KeyValuePair <string, SUserToken> kv in this._userTokenList) { SUserToken userToken = kv.Value; if (userToken.netSessionID == 0 && time > userToken.overTime) //最大重练超时限制 { this._tokensToDelete.Add(kv.Key); } } int count = this._tokensToDelete.Count; if (count > 0) { for (int i = 0; i < count; i++) { this._userTokenList.Remove(this._tokensToDelete[i]); } this._tokensToDelete.Clear(); } return(ErrorCode.Success); }
public void AddUserToken(string userName, string token) { if (!this._userTokenList.TryGetValue(userName, out SUserToken userToken)) { userToken = new SUserToken(); } userToken.userName = userName; userToken.userToken = token; userToken.overTime = TimeUtils.utcTime + 60000; if (userToken.netSessionID > 0) { this._userTokenListByNsId.Remove(userToken.netSessionID); userToken.netSessionID = 0; } userToken.reconnectCount = 0; this._userTokenList[userName] = userToken; }
public void Push(SUserToken userToken) { this._pool.Enqueue(userToken); }