Exemple #1
0
        public ActionResult Index()
        {
            var currentUser = HttpContext.User.Identity;
            if (currentUser.IsAuthenticated && !ApplicationManager.IsUserAlreadyLogged(new ChatUser(currentUser.Name)))
            {
                //user is already logged, but his login doesn't exist
                //in the global list of logged users
                //this occur in situation, when authentication cookie
                //was already available in the browser, so we must add the user manually
                //and add him to the global application cache
                //and mark old messages as readed
                lock (locker)
                {
                    ApplicationManager.LoggedUsers.Add(new ChatUser(Guid.NewGuid(), currentUser.Name));
                    usersService.AddUserToCache(currentUser.Name);
                    messagesService.MarkPreviousMessagesInCacheAsReceived(currentUser.Name);
                }
            }

            return View();
        }