Пример #1
0
        /// <summary>
        /// Close an existing session.
        /// </summary>
        /// <param name="sessionID">The session ID which uniquly identify a given session.</param>
        public static void EndSession(Guid sessionID)
        {
            if (!CurrentSessionList.ContainsKey(sessionID))
            {
                return;
            }

            lock (_syncHelper)
            {
                CurrentCallbackList.Remove(sessionID);
                CurrentSessionList.Remove(sessionID);
            }
        }
Пример #2
0
        /// <summary>
        /// Kill one or more sessions.
        /// </summary>
        /// <param name="sessionIDs">The session ID list.</param>
        public static void KillSessions(IList <Guid> sessionIDs)
        {
            lock (_syncHelper)
            {
                foreach (Guid sessionID in sessionIDs)
                {
                    if (!CurrentSessionList.ContainsKey(sessionID))
                    {
                        continue;
                    }

                    SessionInfo sessionInfo = CurrentSessionList[sessionID];
                    CurrentSessionList.Remove(sessionID);
                    CurrentCallbackList[sessionID].OnSessionKilled(sessionInfo);
                    CurrentCallbackList.Remove(sessionID);
                }
            }
        }
Пример #3
0
        private static void ClearSessions()
        {
            IList <Guid> sessionIDList = new List <Guid>();

            foreach (SessionInfo sessionInfo in CurrentSessionList.Values)
            {
                if (sessionInfo.IsTimeout)
                {
                    sessionIDList.Add(sessionInfo.SessionID);
                }
            }

            lock (_syncHelper)
            {
                Array.ForEach <Guid>(sessionIDList.ToArray <Guid>(), delegate(Guid sessionID)
                {
                    CurrentSessionList.Remove(sessionID);
                    CurrentCallbackList.Remove(sessionID);
                });
            }
        }