Пример #1
0
        public ActionResult Chat()
        {
            // Meta Tags
            ViewBag.Title           = "Chatfunky: Live Chat";
            ViewBag.MetaDescription = "Chatfunky allows you to live chat, communicate with people and make friends online.";
            ViewBag.MetaKeywords    = "online, chat, online chat, live, live chat, chat room, public chat, common, common chat, chatfunky";
            // Meta Tags

            ChatUser user = TempData["user"] as ChatUser;

            if (user != null)
            {
                if (DBSupport.GetUser(user) != null)
                {
                    if (SharedSupport.GetCookieUser() == null || (SharedSupport.GetCookieUser() != null &&
                                                                  SharedSupport.GetCookieUser().Id != DBSupport.GetUser(user).Id))
                    {
                        TempData["error"] = usernameExists.Replace("username", user.Username);
                        return(RedirectToAction("Home", new { logout = "true" }));
                    }
                }
                ViewBag.TotalUsers = DBSupport.GetUsersCount();
                if (SharedSupport.GetCookieUser() != null && DBSupport.GetUser(user) != null)
                {
                    ViewBag.DuplicateTab = SharedSupport.GetCookieUser().Id == DBSupport.GetUser(user).Id ? true : false;
                }
                SharedSupport.SetCookieUser(user);
                return(View(user));
            }

            TempData["error"] = Request.UrlReferrer != null ? (HttpContext.Session["usernameError"] != null ?
                                                               HttpContext.Session["usernameError"].ToString() : sessionExpired) : sessionExpired;
            HttpContext.Session.Remove("usernameError");
            return(RedirectToAction("Home"));
        }
Пример #2
0
        //private readonly string oneInstance = "Only one session can be made via one browser window for specific user!";

        //[OutputCache(Duration = 0, Location = System.Web.UI.OutputCacheLocation.Server, NoStore = true)]
        public ActionResult Home(string logout)
        {
            // Meta Tags
            ViewBag.Title           = "Chatfunky: Live Chat | Free Text & Media Messages";
            ViewBag.MetaDescription = "Join the funky network of Chatfunky. Live chat online, send instant text messages, share photos, connect & collaborate with people across the globe.";
            ViewBag.MetaKeywords    = "online, chat, online chat, live, live chat, chat room, chatfunky";
            // Meta Tags

            ViewBag.TotalUsers = DBSupport.GetUsersCount();
            ViewBag.Error      = TempData["error"];

            // If User press logout button then its clears the user info cookie

            if (logout == "true")
            {
                Response.Cookies["FunkyUser"].Values["Expiry"] = DateTime.UtcNow.AddDays(-1).ToString("dd MMM yyyy");
                return(View(new User()));
            }

            // Checking if User info cookie exists at first then fetch User information from it and then make him/her automatic login to chatroom
            if (SharedSupport.GetCookieUser() != null && Convert.ToDateTime(Request.Cookies["FunkyUser"].Values["Expiry"]) > DateTime.UtcNow)
            {
                TempData["user"] = SharedSupport.GetCookieUser();
                return(RedirectToAction("Chat"));
            }
            else
            {
                return(View(new User()));
            }
        }