Exemplo n.º 1
0
        public void NewMessage(string msgMarkup)
        {
            ChatUser chatClient = DBSupport.GetUser(new ChatUser {
                ConnectionId = Context.ConnectionId
            });

            string[] exceptUsers = null;
            if (chatClient == null)
            {
                string username = Context.RequestCookies["FunkyUser"].Value.Substring(0, Context.RequestCookies["FunkyUser"].Value.IndexOf('&'));
                username   = username.Substring(username.IndexOf('=') + 1);
                chatClient = DBSupport.GetUser(new ChatUser {
                    Username = username
                });
                exceptUsers = SharedSupport.ExceptUsers(chatClient);
                exceptUsers = exceptUsers.Concat(new string[] { Context.ConnectionId }).ToArray();
                exceptUsers = exceptUsers.ToList().Where(x => !x.Equals(chatClient.ConnectionId)).ToArray();
            }
            else
            {
                exceptUsers = SharedSupport.ExceptUsers(chatClient);
            }

            //For updating context user connect time
            DBSupport.UpdateUser(chatClient);

            Clients.AllExcept(exceptUsers).newUserMessage(msgMarkup);
        }
Exemplo n.º 2
0
 void Start()
 {
     conn       = new MySqlConnection(connectdb);
     _DBSupport = new DBSupport();
     _DBSupport.Init();
     _WantSave = false;
 }
Exemplo n.º 3
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"));
        }
Exemplo n.º 4
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()));
            }
        }
Exemplo n.º 5
0
 public void JoinedOnReconnected(ChatUser user)
 {
     if (DBSupport.IsIdExist(user.Id))
     {
         DBSupport.UpdateUser(user);
     }
 }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
 public bool AddNew(Mod mod)
 {
     if (Session["admin"] != null)
     {
         return(DBSupport.AddNewMod(mod));
     }
     return(false);
 }
Exemplo n.º 8
0
 public bool DeleteMod(string modName)
 {
     if (Session["admin"] != null)
     {
         return(DBSupport.DeleteMod(modName));
     }
     return(false);
 }
Exemplo n.º 9
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            DBSupport.InitializeDB();
        }
Exemplo n.º 10
0
        public void UserBlocked(string username)
        {
            ChatUser currentUser = DBSupport.GetUser(new ChatUser {
                ConnectionId = Context.ConnectionId
            });

            currentUser.Blocks += username + ";";

            DBSupport.BlockUser(currentUser);
        }
Exemplo n.º 11
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());
        }
Exemplo n.º 12
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());
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
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());
        }
Exemplo n.º 15
0
    void Start()
    {
        conn       = new MySqlConnection(connectdb);
        _DBSupport = new DBSupport();
        _DBSupport.Init();
        //PlayerPrefs.SetInt("Initiate", 0);

        StaticMng.Instance._Stage_Chapter = 1;

        StartCoroutine(StartLoading());

        Debug.Log(StaticMng.Instance._AppVersion);
    }
Exemplo n.º 16
0
        public ActionResult ModList()
        {
            // Meta Tags
            ViewBag.Title = "Chatfunky - Admin Panel";
            // Meta Tags

            if (Session["admin"] != null)
            {
                IEnumerable <string> mods = DBSupport.GetMods();
                return(View(mods));
            }
            return(RedirectToAction("Login"));
        }
Exemplo n.º 17
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());
 }
Exemplo n.º 18
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()));
        }
Exemplo n.º 19
0
        public string UserSignup(SignupUser data)
        {
            SignupUser filteredSignupUser = SharedSupport.FilterSignupUser(data);

            if (DBSupport.IsSignupUserExist(filteredSignupUser))
            {
                return(usernameExists.Replace("username", data.Username));
            }
            else if (DBSupport.SignupNewUser(filteredSignupUser))
            {
                return("True");
            }

            return("False");
        }
Exemplo n.º 20
0
        public string UserForm(SignupUser data)
        {
            SignupUser user = DBSupport.GetSignupUser(data);

            if (user == null)
            {
                return(invalidUsername);
            }
            else
            {
                ChatUser chatUser = new ChatUser {
                    Id = user.Id, IsMod = 0, Username = user.Username, Gender = user.Gender, Age = user.Age
                };
                return(JsonConvert.SerializeObject(chatUser));
            }
        }
Exemplo n.º 21
0
 public void UserTyping(bool isUserTyping, string username)
 {
     try
     {
         ChatUser pvtChatClient = DBSupport.GetUser(new ChatUser {
             ConnectionId = Context.ConnectionId
         });
         ChatUser pvtChatRecipent = DBSupport.GetUser(new ChatUser {
             Username = username
         });
         if (!pvtChatClient.Blocks.Contains(pvtChatRecipent.Username) && !pvtChatRecipent.Blocks.Contains(pvtChatClient.Username))
         {
             Clients.Client(pvtChatRecipent.ConnectionId).userIsTyping(isUserTyping, pvtChatClient.Username);
         }
     }
     catch { }
 }
Exemplo n.º 22
0
        public ActionResult ModForm(Mod mod)
        {
            TempData["user"] = SharedSupport.FilterMod(mod);

            if (TempData["user"] != null)
            {
                if (DBSupport.ValidateMod(mod))
                {
                    return(RedirectToAction("Chat", "Main"));
                }
                TempData["error"] = "Invalid Modname or Password!";
                return(RedirectToAction("Mod"));
            }

            TempData["error"] = Request.UrlReferrer != null ? (HttpContext.Session["usernameError"] != null ?
                                                               HttpContext.Session["usernameError"].ToString() : sessionExpired) : sessionExpired;
            HttpContext.Session.Remove("usernameError");
            return(RedirectToAction("Mod"));
        }
Exemplo n.º 23
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);
        }
Exemplo n.º 24
0
        //Depreciated Method
        private string UserForm(User data)
        {
            string webpath = string.Empty;

            if (!string.IsNullOrEmpty(data.SocialProfilePicture))
            {
                byte[] binaryData = Convert.FromBase64String(data.SocialProfilePicture
                                                             .Replace("data:image/jpg;base64,", "")
                                                             .Replace("data:image/jpeg;base64,", "")
                                                             .Replace("data:image/gif;base64,", "")
                                                             .Replace("data:image/png;base64,", "")
                                                             .Replace("data:image/bmp;base64,", "")
                                                             );

                string slashSubStr   = data.SocialProfilePicture.Substring(data.SocialProfilePicture.IndexOf('/') + 1);
                string fileExtension = slashSubStr.Substring(0, slashSubStr.IndexOf(';'));
                webpath = SharedSupport.SharedImagesPath + data.Username + "." + fileExtension;
                string fileSystemPath = SharedSupport.GetImageFolderPath() + data.Username + "." + fileExtension;
                Stream sampleStream   = new MemoryStream(binaryData);
                using (FileStream writerStream = File.Open(fileSystemPath, FileMode.Append))
                {
                    Byte[] byteData = new Byte[binaryData.Count()];
                    for (byte i = 0; i < 100; i++)
                    {
                        Int32 readeDataLength = sampleStream.Read(byteData, 0, byteData.Count());
                        writerStream.Write(byteData, 0, readeDataLength);
                    }
                }
            }

            ChatUser filteredUser = SharedSupport.FilterUser(data, webpath);

            if (DBSupport.GetUser(filteredUser) != null)
            {
                return(usernameExists.Replace("username", data.Username));
            }

            return(JsonConvert.SerializeObject(filteredUser));
        }
Exemplo n.º 25
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 { }
 }
Exemplo n.º 26
0
        public void NewPrivateMessage(string msgMarkup, string username)
        {
            if (DBSupport.GetUser(new ChatUser {
                Username = username
            }) == null)
            {
                return;
            }

            ChatUser pvtChatClient = DBSupport.GetUser(new ChatUser {
                ConnectionId = Context.ConnectionId
            });
            ChatUser pvtChatRecipent = DBSupport.GetUser(new ChatUser {
                Username = username
            });

            //For updating context user connect time
            DBSupport.UpdateUser(pvtChatClient);

            if (!pvtChatClient.Blocks.Contains(pvtChatRecipent.Username) && !pvtChatRecipent.Blocks.Contains(pvtChatClient.Username))
            {
                Clients.Client(pvtChatRecipent.ConnectionId).newUserPrivateMessage(msgMarkup, pvtChatClient.Username);
            }
        }
Exemplo n.º 27
0
 public string GetTotalUsers()
 {
     return(DBSupport.GetUsersCount().ToString());
 }
Exemplo n.º 28
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());
 }