Search in sources :

Example 1 with EzyStreamingSetting

use of com.tvd12.ezyfoxserver.setting.EzyStreamingSetting in project ezyfox-server by youngmonkeys.

the class EzyLoginProcessor method apply.

public void apply(EzyZoneContext zoneContext, EzyUserLoginEvent event) {
    EzyZone zone = zoneContext.getZone();
    EzyZoneSetting zoneSetting = zone.getSetting();
    EzyUserManagementSetting userManagementSetting = zoneSetting.getUserManagement();
    String username = checkUsername(event.getUsername(), userManagementSetting.getUserNamePattern(), userManagementSetting.isAllowGuestLogin(), userManagementSetting.getGuestNamePrefix());
    String password = event.getPassword();
    EzyZoneUserManager userManager = zone.getUserManager();
    EzyUser user;
    EzySession session = event.getSession();
    boolean alreadyLoggedIn;
    Lock lock = userManager.getLock(username);
    lock.lock();
    try {
        alreadyLoggedIn = userManager.containsUser(username);
        if (alreadyLoggedIn) {
            user = userManager.getUser(username);
        } else {
            user = newUser(zoneSetting, userManagementSetting, username, password, event.getUserProperties());
        }
        int maxSessionPerUser = userManagementSetting.getMaxSessionPerUser();
        boolean allowChangeSession = userManagementSetting.isAllowChangeSession();
        EzyStreamingSetting streamingSetting = zoneSetting.getStreaming();
        boolean streamingEnable = streamingSetting.isEnable() && event.isStreamingEnable();
        processUserSessions(user, session, maxSessionPerUser, allowChangeSession, streamingEnable);
        addUserToManager(userManager, user, session, alreadyLoggedIn);
    } finally {
        lock.unlock();
        userManager.removeLock(username);
    }
    fireUserAddedEvent(zoneContext, user, session, event.getData(), alreadyLoggedIn);
    EzyResponse response = newLoginResponse(zoneContext, user, event.getOutput());
    serverContext.send(response, session, false);
}
Also used : EzyZone(com.tvd12.ezyfoxserver.EzyZone) EzyUser(com.tvd12.ezyfoxserver.entity.EzyUser) EzyStreamingSetting(com.tvd12.ezyfoxserver.setting.EzyStreamingSetting) EzyUserManagementSetting(com.tvd12.ezyfoxserver.setting.EzyUserManagementSetting) EzyZoneSetting(com.tvd12.ezyfoxserver.setting.EzyZoneSetting) EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) EzyZoneUserManager(com.tvd12.ezyfoxserver.wrapper.EzyZoneUserManager) Lock(java.util.concurrent.locks.Lock)

Aggregations

EzyZone (com.tvd12.ezyfoxserver.EzyZone)1 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)1 EzyUser (com.tvd12.ezyfoxserver.entity.EzyUser)1 EzyResponse (com.tvd12.ezyfoxserver.response.EzyResponse)1 EzyStreamingSetting (com.tvd12.ezyfoxserver.setting.EzyStreamingSetting)1 EzyUserManagementSetting (com.tvd12.ezyfoxserver.setting.EzyUserManagementSetting)1 EzyZoneSetting (com.tvd12.ezyfoxserver.setting.EzyZoneSetting)1 EzyZoneUserManager (com.tvd12.ezyfoxserver.wrapper.EzyZoneUserManager)1 Lock (java.util.concurrent.locks.Lock)1