Search in sources :

Example 1 with EzyConstant

use of com.tvd12.ezyfox.constant.EzyConstant in project ezyfox-server by youngmonkeys.

the class EzySimpleDataHandler method handleRequest.

@SuppressWarnings({ "rawtypes", "unchecked" })
protected void handleRequest(EzyConstant cmd, EzyArray data) {
    try {
        EzyRequest request = newRequest(cmd, data);
        try {
            EzyInterceptor interceptor = controllers.getInterceptor(cmd);
            interceptor.intercept(context, request);
            EzyController controller = controllers.getController(cmd);
            controller.handle(context, request);
        } finally {
            request.release();
        }
    } catch (Exception e) {
        if (context != null) {
            Throwable throwable = requestHandleException(session, cmd, data, e);
            context.handleException(Thread.currentThread(), throwable);
        } else {
            if (active) {
                logger.warn("fatal error, please add an issue to ezyfox-server github " + "with log: {}\nand stacktrace: ", this, e);
            } else {
                logger.warn("can't handle command: {} and data: {}, this session " + "maybe destroyed (session: {}), error message: {}", cmd, data, session, e.getMessage());
            }
        }
    }
}
Also used : EzyController(com.tvd12.ezyfoxserver.controller.EzyController) EzyRequest(com.tvd12.ezyfoxserver.request.EzyRequest) EzyInterceptor(com.tvd12.ezyfoxserver.interceptor.EzyInterceptor) EzyRequestHandleException.requestHandleException(com.tvd12.ezyfoxserver.exception.EzyRequestHandleException.requestHandleException)

Example 2 with EzyConstant

use of com.tvd12.ezyfox.constant.EzyConstant in project ezyfox-server by youngmonkeys.

the class EzySimpleDataHandler method notifySessionRemoved.

protected void notifySessionRemoved(EzyConstant reason) {
    if (zoneContext != null) {
        EzyEvent event = newSessionRemovedEvent(reason);
        notifyAppsSessionRemoved(event);
        notifyPluginsSessionRemoved(event);
    }
}
Also used : EzyEvent(com.tvd12.ezyfoxserver.event.EzyEvent)

Example 3 with EzyConstant

use of com.tvd12.ezyfox.constant.EzyConstant in project ezyfox-server by youngmonkeys.

the class EzySimpleAppUserDelegate method handleUserRemovedEvent.

protected void handleUserRemovedEvent(EzyUser user, EzyConstant reason) {
    EzyEvent event = new EzySimpleUserRemovedEvent(user, reason);
    appContext.handleEvent(EzyEventType.USER_REMOVED, event);
}
Also used : EzyEvent(com.tvd12.ezyfoxserver.event.EzyEvent) EzySimpleUserRemovedEvent(com.tvd12.ezyfoxserver.event.EzySimpleUserRemovedEvent)

Example 4 with EzyConstant

use of com.tvd12.ezyfox.constant.EzyConstant in project ezyfox-server by youngmonkeys.

the class EzySimpleUserDelegate method onUserRemoved.

@Override
public void onUserRemoved(EzyUser user, EzyConstant reason) {
    EzyZoneContext zoneContext = serverContext.getZoneContext(user.getZoneId());
    EzySocketUserRemoval removal = new EzySimpleSocketUserRemoval(zoneContext, user, reason);
    userRemovalQueue.add(removal);
}
Also used : EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzySimpleSocketUserRemoval(com.tvd12.ezyfoxserver.socket.EzySimpleSocketUserRemoval) EzySocketUserRemoval(com.tvd12.ezyfoxserver.socket.EzySocketUserRemoval)

Example 5 with EzyConstant

use of com.tvd12.ezyfox.constant.EzyConstant in project ezyfox-server by youngmonkeys.

the class EzyBroadcastPluginsEventImpl method getPluginContextMaps.

private EzyMapSet<EzyConstant, EzyPluginContext> getPluginContextMaps() {
    Collection<EzyPluginContext> pluginContexts = context.getPluginContexts();
    EzyMapSet<EzyConstant, EzyPluginContext> pluginContextMaps = new EzyHashMapSet<>();
    for (EzyPluginContext pluginContext : pluginContexts) {
        EzyPluginSetting pluginSetting = pluginContext.getPlugin().getSetting();
        Set<EzyConstant> listenEvents = pluginSetting.getListenEvents().getEvents();
        for (EzyConstant listenEvent : listenEvents) {
            pluginContextMaps.addItem(listenEvent, pluginContext);
        }
    }
    return pluginContextMaps;
}
Also used : EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzyConstant(com.tvd12.ezyfox.constant.EzyConstant) EzyHashMapSet(com.tvd12.ezyfox.util.EzyHashMapSet) EzyPluginSetting(com.tvd12.ezyfoxserver.setting.EzyPluginSetting)

Aggregations

EzyConstant (com.tvd12.ezyfox.constant.EzyConstant)6 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)4 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)3 EzyPluginContext (com.tvd12.ezyfoxserver.context.EzyPluginContext)2 EzyUser (com.tvd12.ezyfoxserver.entity.EzyUser)2 EzyEvent (com.tvd12.ezyfoxserver.event.EzyEvent)2 EzyResponse (com.tvd12.ezyfoxserver.response.EzyResponse)2 EzyArray (com.tvd12.ezyfox.entity.EzyArray)1 EzyHashMapSet (com.tvd12.ezyfox.util.EzyHashMapSet)1 EzyController (com.tvd12.ezyfoxserver.controller.EzyController)1 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)1 EzySimpleUserRemovedEvent (com.tvd12.ezyfoxserver.event.EzySimpleUserRemovedEvent)1 EzyUserRemovedEvent (com.tvd12.ezyfoxserver.event.EzyUserRemovedEvent)1 EzyRequestHandleException.requestHandleException (com.tvd12.ezyfoxserver.exception.EzyRequestHandleException.requestHandleException)1 EzyInterceptor (com.tvd12.ezyfoxserver.interceptor.EzyInterceptor)1 EzyRequest (com.tvd12.ezyfoxserver.request.EzyRequest)1 EzySimpleRequest (com.tvd12.ezyfoxserver.request.EzySimpleRequest)1 EzyDisconnectParams (com.tvd12.ezyfoxserver.response.EzyDisconnectParams)1 EzyDisconnectResponse (com.tvd12.ezyfoxserver.response.EzyDisconnectResponse)1 EzyExitedAppParams (com.tvd12.ezyfoxserver.response.EzyExitedAppParams)1