示例#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()));
            }
        }
示例#3
0
        public override void OnOpen()
        {
            if (DBSupport.GetUser(user) == null)
            {
                DBSupport.AddNewUser(user);
            }

            SocketMessage socMsg = new SocketMessage()
            {
                Type       = SocketMessage.MessageType.JoinedPub,
                Packetizer = new SocketMessage.DataGram
                {
                    User       = user,
                    UsersCount = DBSupport.GetUsersCount()
                }
            };

            chatClients.BroadcastExcept(chatClients, this.user, JsonConvert.SerializeObject(socMsg));

            socMsg = new SocketMessage()
            {
                Type       = SocketMessage.MessageType.JoinedPvt,
                Packetizer = new SocketMessage.DataGram
                {
                    User       = null,
                    Users      = DBSupport.GetAllUsers(),
                    UsersCount = DBSupport.GetUsersCount()
                }
            };
            this.Send(JsonConvert.SerializeObject(socMsg));
            chatClients.Add(this);
        }
示例#4
0
        public void userKicked(string username)
        {
            ChatUser currentUser = DBSupport.GetUser(new ChatUser {
                Username = username
            });

            DBSupport.DeleteUser(currentUser.Username);
            Clients.AllExcept(currentUser.ConnectionId).userLeft(currentUser.Username);
            Clients.Client(currentUser.ConnectionId).forceDisconnect();
            Clients.All.totalUsers(DBSupport.GetUsersCount());
            Clients.All.dcUserSessions(currentUser.Username);
        }
示例#5
0
        public ActionResult SiteMap()
        {
            // Meta Tags
            ViewBag.Title           = "Chatfunky: Sitemap";
            ViewBag.MetaDescription = "Chatfunky sitemap for users to navigate easily all the links of the website.";
            ViewBag.MetaKeywords    = "sitemap, map, chatfunky";
            // Meta Tags

            ViewBag.TotalUsers = DBSupport.GetUsersCount();

            return(View());
        }
示例#6
0
        public ActionResult Privacy()
        {
            // Meta Tags
            ViewBag.Title           = "Chatfunky: Privacy Policy";
            ViewBag.MetaDescription = "Chatfunky privacy policy for users.";
            ViewBag.MetaKeywords    = "privacy, policy, privacy policy, chatfunky";
            // Meta Tags

            ViewBag.TotalUsers = DBSupport.GetUsersCount();

            return(View());
        }
示例#7
0
        public ActionResult Terms()
        {
            // Meta Tags
            ViewBag.Title           = "Chatfunky: Terms of Service";
            ViewBag.MetaDescription = "Chatfunky terms of service for users.";
            ViewBag.MetaKeywords    = "terms, conditions, terms and conditions, service, terms of service, chatfunky";
            // Meta Tags

            ViewBag.TotalUsers = DBSupport.GetUsersCount();

            return(View());
        }
示例#8
0
 public void NewUserJoining(ChatUser user)
 {
     if (DBSupport.IsIdExist(user.Id))
     {
         DBSupport.UpdateUser(user);
     }
     else
     {
         DBSupport.AddNewUser(user);
     }
     Clients.Others.newUserJoined(user);
     Clients.Caller.youJoined(DBSupport.GetAllUsers());
     Clients.All.totalUsers(DBSupport.GetUsersCount());
 }
示例#9
0
        public ActionResult Mod()
        {
            // Meta Tags
            ViewBag.Title = "Chatfunky - Mod Login";
            // Meta Tags

            ViewBag.TotalUsers = DBSupport.GetUsersCount();

            if (TempData["error"] != null)
            {
                ViewBag.Error = TempData["error"];
            }

            return(View(new Mod()));
        }
示例#10
0
        public void DeleteReconnectingUser(string username)
        {
            ChatUser currentUser = DBSupport.GetUser(new ChatUser {
                Username = username
            });

            if (currentUser == null)
            {
                username    = HttpContext.Request.Cookies["FunkyUser"].Value.Substring(0, HttpContext.Request.Cookies["FunkyUser"].Value.IndexOf('&'));
                username    = username.Substring(username.IndexOf('=') + 1);
                currentUser = DBSupport.GetUser(new ChatUser {
                    Username = username
                });
            }
            DBSupport.DeleteUser(username);
            IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext <Chat>();

            hubContext.Clients.All.userLeft(currentUser.Username);
            hubContext.Clients.All.totalUsers(DBSupport.GetUsersCount());
            hubContext.Clients.All.dcUserSessions(currentUser.Username);
        }
示例#11
0
 public void Stop()
 {
     try
     {
         ChatUser currentUser = DBSupport.GetUser(new ChatUser {
             ConnectionId = Context.ConnectionId
         });
         if (currentUser == null)
         {
             string username = Context.RequestCookies["FunkyUser"].Value.Substring(0, Context.RequestCookies["FunkyUser"].Value.IndexOf('&'));
             username    = username.Substring(username.IndexOf('=') + 1);
             currentUser = DBSupport.GetUser(new ChatUser {
                 Username = username
             });
         }
         DBSupport.DeleteUser(currentUser.Username);
         Clients.Others.userLeft(currentUser.Username);
         Clients.All.totalUsers(DBSupport.GetUsersCount());
         Clients.All.dcUserSessions(currentUser.Username);
     }
     catch { }
 }
示例#12
0
 public string GetTotalUsers()
 {
     return(DBSupport.GetUsersCount().ToString());
 }
示例#13
0
 //Called from client in case of duplicate tab in order to retreive the same session for same client
 public void LoadSameSession()
 {
     Clients.Caller.youJoined(DBSupport.GetAllUsers());
     Clients.All.totalUsers(DBSupport.GetUsersCount());
 }