Ejemplo n.º 1
0
        /// <summary>
        /// 检查列表(清除无效记录)
        /// </summary>
        internal static void Check(object o)
        {
            lock (UserSessionList)
            {
recheck:
                foreach (string key in UserSessionList.Keys)
                {
                    UserSessionModel userSession = (UserSessionModel)UserSessionList[key];
                    if (userSession.LastLifeTime + maxLifeTime * 10000 * 1000 <= DateTime.Now.Ticks)
                    {
                        UserSessionList.Remove(key);

                        goto recheck;
                    }


                    if (userSession.LastActiveTime + maxActiveTime * 10000 * 1000 <= DateTime.Now.Ticks)
                    {
                        UserSessionList.Remove(key);
                        goto recheck;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 添加一个USERSESSION对象
 /// </summary>
 /// <param name="userSession"></param>
 public static void Add(UserSessionModel userSession)
 {
     if (UserSessionList.ContainsKey(userSession.SessionId))
     {
         throw new Exception("已经存在的SESSIONID");
     }
     UserSessionList.Add(userSession.SessionId, userSession);
 }