Search in sources :

Example 6 with EzyResponse

use of com.tvd12.ezyfoxserver.response.EzyResponse in project ezyfox-server by youngmonkeys.

the class EzyLoginController method responseLoginError.

protected void responseLoginError(EzyServerContext ctx, EzySession session, EzyILoginError error) {
    EzyResponse response = newLoginErrorResponse(error);
    ctx.send(response, session, false);
}
Also used : EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse)

Example 7 with EzyResponse

use of com.tvd12.ezyfoxserver.response.EzyResponse 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)

Example 8 with EzyResponse

use of com.tvd12.ezyfoxserver.response.EzyResponse in project ezyfox-server by youngmonkeys.

the class EzyPingController method handle.

@Override
public void handle(EzyServerContext ctx, EzyPingRequest request) {
    EzyResponse response = EzyPongResponse.getInstance();
    EzySession session = request.getSession();
    ctx.send(response, session, false);
}
Also used : EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse) EzySession(com.tvd12.ezyfoxserver.entity.EzySession)

Example 9 with EzyResponse

use of com.tvd12.ezyfoxserver.response.EzyResponse in project ezyfox-server by youngmonkeys.

the class EzyPluginInfoController method handle.

@Override
public void handle(EzyServerContext ctx, EzyPluginInfoRequest request) {
    EzyUser user = request.getUser();
    EzySession session = request.getSession();
    EzyPluginInfoParams params = request.getParams();
    EzyZoneContext zoneCtx = ctx.getZoneContext(user.getZoneId());
    EzyPluginContext pluginCtx = zoneCtx.getPluginContext(params.getPluginName());
    if (pluginCtx != null) {
        EzyPluginSetting setting = pluginCtx.getPlugin().getSetting();
        EzyResponse response = newPluginInfoResponse(setting);
        ctx.send(response, session, false);
    }
}
Also used : EzyUser(com.tvd12.ezyfoxserver.entity.EzyUser) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyPluginInfoParams(com.tvd12.ezyfoxserver.request.EzyPluginInfoParams) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) EzyPluginSetting(com.tvd12.ezyfoxserver.setting.EzyPluginSetting)

Example 10 with EzyResponse

use of com.tvd12.ezyfoxserver.response.EzyResponse in project ezyfox-server by youngmonkeys.

the class EzyAccessAppController method responseAccessAppError.

protected void responseAccessAppError(EzyServerContext ctx, EzySession session, EzyAccessAppException exception) {
    EzyResponse response = newAccessAppErrorResponse(exception.getError());
    ctx.send(response, session, false);
}
Also used : EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse)

Aggregations

EzyResponse (com.tvd12.ezyfoxserver.response.EzyResponse)25 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)17 Test (org.testng.annotations.Test)12 EzyResponseApi (com.tvd12.ezyfoxserver.api.EzyResponseApi)11 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)9 EzySendResponseImpl (com.tvd12.ezyfoxserver.command.impl.EzySendResponseImpl)8 EzySimpleResponse (com.tvd12.ezyfoxserver.response.EzySimpleResponse)8 EzySimpleSettings (com.tvd12.ezyfoxserver.setting.EzySimpleSettings)8 EzyPackage (com.tvd12.ezyfoxserver.response.EzyPackage)7 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)5 EzyUser (com.tvd12.ezyfoxserver.entity.EzyUser)4 EzyArray (com.tvd12.ezyfox.entity.EzyArray)3 EzyErrorParams (com.tvd12.ezyfoxserver.response.EzyErrorParams)3 EzyAppSetting (com.tvd12.ezyfoxserver.setting.EzyAppSetting)3 EzyApplication (com.tvd12.ezyfoxserver.EzyApplication)2 EzyBroadcastEvent (com.tvd12.ezyfoxserver.command.EzyBroadcastEvent)2 EzyAppContext (com.tvd12.ezyfoxserver.context.EzyAppContext)2 EzySimpleServerContext (com.tvd12.ezyfoxserver.context.EzySimpleServerContext)2 EzySimpleUser (com.tvd12.ezyfoxserver.entity.EzySimpleUser)2 EzySimpleServerReadyEvent (com.tvd12.ezyfoxserver.event.EzySimpleServerReadyEvent)2