use of com.tvd12.ezyfoxserver.response.EzyAccessAppParams in project ezyfox-server by youngmonkeys.
the class EzyAccessAppResponseTest method test.
@Test
public void test() {
EzySimpleAppSetting setting = new EzySimpleAppSetting();
EzyAccessAppParams params = new EzyAccessAppParams();
EzyData data = EzyEntityFactory.EMPTY_ARRAY;
params.setData(data);
params.setApp(setting);
assert params.getApp() == setting;
assert params.getData() == data;
EzyAccessAppResponse response = new EzyAccessAppResponse(params);
assert response.getParams() == params;
assert response.getCommand() == EzyCommand.APP_ACCESS;
assert response.serialize().size() > 0;
response.release();
}
use of com.tvd12.ezyfoxserver.response.EzyAccessAppParams 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);
}
}
Aggregations