Search in sources :

Example 6 with EzyConstant

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

the class EzyCloseSessionImpl method newResponse.

protected EzyResponse newResponse(EzyConstant reason) {
    EzyDisconnectParams params = new EzyDisconnectParams();
    params.setReason(reason);
    return new EzyDisconnectResponse(params);
}
Also used : EzyDisconnectParams(com.tvd12.ezyfoxserver.response.EzyDisconnectParams) EzyDisconnectResponse(com.tvd12.ezyfoxserver.response.EzyDisconnectResponse)

Example 7 with EzyConstant

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

the class EzyAbstractResponseApi method normalResponse.

protected final void normalResponse(EzyPackage pack, boolean immediate) throws Exception {
    EzyConstant connectionType = getConnectionType();
    Collection<EzySession> recipients = pack.getRecipients(connectionType);
    if (recipients.isEmpty()) {
        return;
    }
    Object bytes = encodeData(pack.getData());
    if (immediate) {
        for (EzySession session : recipients) {
            session.sendNow(createPacket(bytes, pack));
        }
    } else {
        for (EzySession session : recipients) {
            session.send(createPacket(bytes, pack));
        }
    }
}
Also used : EzyConstant(com.tvd12.ezyfox.constant.EzyConstant) EzySession(com.tvd12.ezyfoxserver.entity.EzySession)

Example 8 with EzyConstant

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

the class EzySimpleSessionManager method provideSession.

@SuppressWarnings("unchecked")
protected S provideSession(EzyConstant connectionType) {
    checkMaxSessions();
    EzyAbstractSession session = (EzyAbstractSession) provideObject();
    session.setLoggedIn(false);
    session.setName("Session#" + COUNTER.incrementAndGet());
    session.setConnectionType(connectionType);
    session.setToken(newSessionToken());
    session.setCreationTime(System.currentTimeMillis());
    session.setCreationTime(System.currentTimeMillis());
    session.setLastActivityTime(System.currentTimeMillis());
    session.setLastReadTime(System.currentTimeMillis());
    session.setLastWriteTime(System.currentTimeMillis());
    S complete = (S) session;
    sessionsById.put(complete.getId(), complete);
    return complete;
}
Also used : EzyAbstractSession(com.tvd12.ezyfoxserver.entity.EzyAbstractSession)

Example 9 with EzyConstant

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

the class EzySocketDisconnectionHandler method processDisconnection.

private void processDisconnection(EzySocketDisconnection disconnection) {
    try {
        EzySession session = disconnection.getSession();
        EzyConstant disconnectReason = disconnection.getDisconnectReason();
        EzySocketDataHandlerGroup handlerGroup = removeDataHandlerGroup(session);
        if (handlerGroup != null) {
            handlerGroup.fireChannelInactive(disconnectReason);
        } else {
            logger.warn("has no handler group with session: {}, ignore disconnection: {}", session, disconnection);
        }
    } finally {
        disconnection.release();
    }
}
Also used : EzyConstant(com.tvd12.ezyfox.constant.EzyConstant) EzySession(com.tvd12.ezyfoxserver.entity.EzySession)

Example 10 with EzyConstant

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

the class EzyBroadcastPluginsEventImpl method fire.

@Override
public void fire(EzyConstant type, EzyEvent event, boolean catchException) {
    logger.debug("zone: {} broadcast to plugins event: {}", getZoneName(), type);
    Set<EzyPluginContext> pluginContexts = pluginContextMaps.get(type);
    if (pluginContexts != null) {
        for (EzyPluginContext pluginContext : pluginContexts) {
            firePluginEvent(pluginContext, type, event, catchException);
        }
    }
}
Also used : EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext)

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