use of com.tvd12.example.lucky_wheel.entity.User 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);
}
}
use of com.tvd12.example.lucky_wheel.entity.User in project ezyfox-server by youngmonkeys.
the class EzySimpleAppUserDelegate method responseUserRemoved.
protected void responseUserRemoved(EzyUser user, EzyConstant reason) {
EzyResponse response = newExitedAppResponse(reason);
EzyZoneContext zoneContext = appContext.getParent();
zoneContext.send(response, user, false);
}
use of com.tvd12.example.lucky_wheel.entity.User in project ezyfox-server by youngmonkeys.
the class EzyUserDataHandler method newStreamingRequest.
protected EzyStreamingRequest newStreamingRequest(byte[] bytes) {
EzySimpleStreamingRequest request = new EzySimpleStreamingRequest();
request.setUser(user);
request.setSession(session);
request.setBytes(bytes);
return request;
}
use of com.tvd12.example.lucky_wheel.entity.User in project ezyfox-server by youngmonkeys.
the class EzyUserDataHandler method newRequest.
@SuppressWarnings({ "rawtypes" })
protected EzyRequest newRequest(EzyConstant cmd, EzyArray data) {
EzySimpleRequest request = requestFactory.newRequest(cmd);
request.setSession(session);
request.setUser(user);
request.deserializeParams(data);
return request;
}
use of com.tvd12.example.lucky_wheel.entity.User in project ezyfox-server by youngmonkeys.
the class EzyZoneUserManagerImpl method unmapSessionUser.
@Override
public void unmapSessionUser(EzySession session, EzyConstant reason) {
EzyUser user = usersBySession.remove(session);
if (user != null) {
user.removeSession(session);
logger.debug("zone: {} remove session {} from user {} by reason {}, " + "user remain: {} sessions, usersBySession.size: {}", zoneName, session.getClientAddress(), user, reason, user.getSessionCount(), usersBySession.size());
if (shouldRemoveUserNow(user)) {
removeUser(user, reason);
}
}
}
Aggregations