Search in sources :

Example 31 with EzyResponse

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

the class EzyLoginProcessor method newLoginResponse.

protected EzyResponse newLoginResponse(EzyZoneContext zoneContext, EzyUser user, EzyData loginOutputData) {
    EzyZoneSetting zoneSetting = getZoneSetting(zoneContext);
    EzyLoginParams params = new EzyLoginParams();
    params.setData(loginOutputData);
    params.setUserId(user.getId());
    params.setUsername(user.getName());
    params.setZoneId(zoneSetting.getId());
    params.setZoneName(zoneSetting.getName());
    return new EzyLoginResponse(params);
}
Also used : EzyZoneSetting(com.tvd12.ezyfoxserver.setting.EzyZoneSetting) EzyLoginParams(com.tvd12.ezyfoxserver.response.EzyLoginParams) EzyLoginResponse(com.tvd12.ezyfoxserver.response.EzyLoginResponse)

Example 32 with EzyResponse

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

the class EzyRequestAppController method responseRequestAppError.

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

Example 33 with EzyResponse

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

the class EzyRequestAppController method newRequestAppErrorResponse.

protected EzyResponse newRequestAppErrorResponse() {
    EzyErrorParams params = new EzyErrorParams();
    params.setError(EzyRequestAppError.HAS_NOT_ACCESSED);
    return new EzyRequestAppErrorResponse(params);
}
Also used : EzyErrorParams(com.tvd12.ezyfoxserver.response.EzyErrorParams) EzyRequestAppErrorResponse(com.tvd12.ezyfoxserver.response.EzyRequestAppErrorResponse)

Example 34 with EzyResponse

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

the class EzyAccessAppController method newAccessAppErrorResponse.

protected EzyResponse newAccessAppErrorResponse(EzyIAccessAppError error) {
    EzyErrorParams params = new EzyErrorParams();
    params.setError(error);
    return new EzyAccessAppErrorResponse(params);
}
Also used : EzyErrorParams(com.tvd12.ezyfoxserver.response.EzyErrorParams) EzyAccessAppErrorResponse(com.tvd12.ezyfoxserver.response.EzyAccessAppErrorResponse)

Example 35 with EzyResponse

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

the class EzyAccessAppController method doHandle.

protected void doHandle(EzyServerContext ctx, EzyAccessAppRequest request) {
    EzyUser user = request.getUser();
    int zoneId = user.getZoneId();
    EzyAccessAppParams params = request.getParams();
    EzyZoneContext zoneContext = ctx.getZoneContext(zoneId);
    EzyAppContext appContext = zoneContext.getAppContext(params.getAppName());
    EzyApplication app = appContext.getApp();
    EzyAppSetting appSetting = app.getSetting();
    EzyAppUserManager appUserManger = app.getUserManager();
    EzySession session = request.getSession();
    String username = user.getName();
    Lock lock = appUserManger.getLock(username);
    lock.lock();
    try {
        boolean hasNotAccessed = !appUserManger.containsUser(user);
        if (hasNotAccessed) {
            checkAppUserMangerAvailable(appUserManger);
        }
        EzyUserAccessAppEvent accessAppEvent = new EzySimpleUserAccessAppEvent(user);
        appContext.handleEvent(EzyEventType.USER_ACCESS_APP, accessAppEvent);
        if (hasNotAccessed) {
            addUser(appUserManger, user, appSetting);
            EzyUserAccessedAppEvent accessedAppEvent = new EzySimpleUserAccessedAppEvent(user);
            appContext.handleEvent(EzyEventType.USER_ACCESSED_APP, accessedAppEvent);
        }
        EzyArray output = accessAppEvent.getOutput();
        EzyResponse accessAppResponse = newAccessAppResponse(appSetting, output);
        ctx.send(accessAppResponse, session, false);
    } finally {
        lock.unlock();
        appUserManger.removeLock(username);
    }
}
Also used : EzyUser(com.tvd12.ezyfoxserver.entity.EzyUser) EzyAccessAppParams(com.tvd12.ezyfoxserver.request.EzyAccessAppParams) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyAppContext(com.tvd12.ezyfoxserver.context.EzyAppContext) EzySimpleUserAccessedAppEvent(com.tvd12.ezyfoxserver.event.EzySimpleUserAccessedAppEvent) EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) Lock(java.util.concurrent.locks.Lock) EzyAppSetting(com.tvd12.ezyfoxserver.setting.EzyAppSetting) EzyApplication(com.tvd12.ezyfoxserver.EzyApplication) EzyAppUserManager(com.tvd12.ezyfoxserver.wrapper.EzyAppUserManager) EzyUserAccessedAppEvent(com.tvd12.ezyfoxserver.event.EzyUserAccessedAppEvent) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzyUserAccessAppEvent(com.tvd12.ezyfoxserver.event.EzyUserAccessAppEvent) EzySimpleUserAccessAppEvent(com.tvd12.ezyfoxserver.event.EzySimpleUserAccessAppEvent)

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