Example #1
0
        public void LoginUserToLobby(string userId, string username, string userWebClientId)
        {
            Users logUser = new Users();
            logUser.DeviceId = userId;
            logUser.Username = username;
            logUser.IsOnline = true;
            logUser.UserWebClientId = userWebClientId;

            var existDevice = context.Users.FirstOrDefault(x => x.DeviceId == userId);
            if (existDevice != null)
            {
                existDevice.Username = username;
                existDevice.UserWebClientId = userWebClientId;
            }
            else
            {
                context.Users.Add(logUser);
            }
            context.SaveChanges();
            //Clients.All.allertAMessageOnly("users: " + username + " Id:" + userId);
            // Call the broadcastMessage method to update clients.
            var users = context.Users.Where(x => x.IsOnline).ToList();

            foreach (var user in users)
            {
                Clients.All.broadcastUsers(user.DeviceId, user.Username);
            }

            foreach (var item in UserHandler.ConnectedIds)
            {

                //Clients.All.allertAMessage(logUser.DeviceId, logUser.DeviceId,"users: " + item + " ");
            }
        }
Example #2
0
 public Users(Users user)
 {
     this.DeviceId = user.DeviceId;
     this.UserWebClientId = user.UserWebClientId;
 }