Ejemplo n.º 1
0
        public void SignOff(object user)
        {
            ChatUser botUser = new ChatUser();

            foreach (System.Reflection.PropertyInfo pInfo in user.GetType().GetProperties())
            {
                string pName = pInfo.Name;
                foreach (System.Reflection.PropertyInfo pbInfo in botUser.GetType().GetProperties())
                {
                    if (pName.Equals(pbInfo.Name))
                    {
                        pbInfo.SetValue(botUser, pInfo.GetValue(user, null));
                        break;
                    }
                }
            }

            DBSupport.DeleteUser(botUser.Username);
            IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext <Chat>();

            hubContext.Clients.All.userLeft(botUser.Username);
            hubContext.Clients.All.totalUsers(DBSupport.GetUsersCount());
        }