forked from External/mage
server: added logs with a max users online stats
This commit is contained in:
parent
c87f8f5db3
commit
161835fd76
3 changed files with 19 additions and 3 deletions
|
|
@ -41,7 +41,7 @@ public class User {
|
|||
Created, // Used if user is created an not connected to the session
|
||||
Connected, // Used if user is correctly connected
|
||||
Disconnected, // Used if the user lost connection
|
||||
Offline // set if the user was disconnected and expired or regularly left XMage. Removed is the user later after some time
|
||||
Offline // Used if user was disconnected too long, offline users removes from users list by service routines
|
||||
}
|
||||
|
||||
private final ManagerFactory managerFactory;
|
||||
|
|
@ -854,4 +854,9 @@ public class User {
|
|||
AuthorizedUserRepository.getInstance().update(authorizedUser);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOnlineUser() {
|
||||
return this.getUserState() != User.UserState.Offline
|
||||
&& !this.getName().equals(User.ADMIN_NAME);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ public class UserManagerImpl implements UserManager {
|
|||
protected final ScheduledExecutorService userListExecutor = Executors.newSingleThreadScheduledExecutor();
|
||||
|
||||
private List<UserView> userInfoList = new ArrayList<>(); // all users list for main room/chat
|
||||
private int maxUsersOnline = 0;
|
||||
private final ManagerFactory managerFactory;
|
||||
|
||||
|
||||
|
|
@ -283,6 +284,7 @@ public class UserManagerImpl implements UserManager {
|
|||
private void updateUserInfoList() {
|
||||
try {
|
||||
List<UserView> newUserInfoList = new ArrayList<>();
|
||||
int currentOnlineCount = 0;
|
||||
for (User user : getUsers()) {
|
||||
newUserInfoList.add(new UserView(
|
||||
user.getName(),
|
||||
|
|
@ -297,8 +299,18 @@ public class UserManagerImpl implements UserManager {
|
|||
user.getEmail(),
|
||||
user.getUserIdStr()
|
||||
));
|
||||
|
||||
if (user.isOnlineUser()) {
|
||||
currentOnlineCount++;
|
||||
}
|
||||
}
|
||||
userInfoList = newUserInfoList;
|
||||
|
||||
// max users online stats
|
||||
if (currentOnlineCount > maxUsersOnline) {
|
||||
maxUsersOnline = currentOnlineCount;
|
||||
logger.info(String.format("New max users online: %d", maxUsersOnline));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,8 +81,7 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
matchView = matchList;
|
||||
List<UsersView> users = new ArrayList<>();
|
||||
for (User user : managerFactory.userManager().getUsers()) {
|
||||
if (user.getUserState() != User.UserState.Offline
|
||||
&& !user.getName().equals(User.ADMIN_NAME)) {
|
||||
if (user.isOnlineUser()) {
|
||||
try {
|
||||
users.add(new UsersView(user.getUserData().getFlagName(), user.getName(),
|
||||
user.getMatchHistory(), user.getMatchQuitRatio(), user.getTourneyHistory(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue