Пример #1
0
        internal void NotifySessionUserChanged(ClientSession clientSession, IUser old, IUser user)
        {
            var user1 = old == null ? "[no user]" : old.Login;
            var user2 = user == null ? "[no user]" : user.Login;

            SetSessionByUser(user1, clientSession, false);
            SetSessionByUser(user2, clientSession, true);
        }
Пример #2
0
        private IClientSession GetSessionInternal(String sessionId, bool createIfNotExists)
        {
            sessionId = sessionId.HasValue() ? sessionId
                : (HttpContext.Current == null ? (string)ContextData.Get(CLIENT_SESSION_KEY)
                    : HttpContext.Current.Session[CLIENT_SESSION_KEY].AsString());

            if (sessionId.IsEmpty())
                sessionId = Guid.NewGuid().ToString("N").ToLower();

            IClientSession result = null;
            if (!_sessions.TryGetValue(sessionId, out result) && createIfNotExists)
            {
                lock (__lockObject)
                {
                    result = new ClientSession(sessionId, this);
                    if (HttpContext.Current == null)
                        ContextData.Set(CLIENT_SESSION_KEY, sessionId);
                    else
                        HttpContext.Current.Session[CLIENT_SESSION_KEY] = sessionId;
                    _sessions[sessionId] = result;
                }
            }
            else if (!result.isAlive)
                return GetSessionInternal(Guid.NewGuid().ToString("N").ToLower(), true);
            return result;
        }
Пример #3
0
 internal void DisposeSession(ClientSession session)
 {
     session.SetUser(null); // atualizar a lista de usuários.
     _sessionsByUser["[no user]"].Remove(session);
 }
Пример #4
0
 internal void DisposeSession(ClientSession session)
 {
     session.SetUser(null); // atualizar a lista de usuários.
     _sessionsByUser["[no user]"].Remove(session);
 }