Search in sources :

Example 1 with EzyRequest

use of com.tvd12.ezyfoxserver.client.request.EzyRequest 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 EzyRequest

use of com.tvd12.ezyfoxserver.client.request.EzyRequest in project ezyfox-server-android-client by youngmonkeys.

the class EzyTcpClient method send.

@Override
public void send(EzyRequest request, boolean encrypted) {
    Object cmd = request.getCommand();
    EzyData data = request.serialize();
    send((EzyCommand) cmd, (EzyArray) data, encrypted);
}
Also used : EzyData(com.tvd12.ezyfoxserver.client.entity.EzyData)

Example 3 with EzyRequest

use of com.tvd12.ezyfoxserver.client.request.EzyRequest in project ezyfox-server-android-client by youngmonkeys.

the class EzyPingSchedule method sendPingRequest.

private void sendPingRequest() {
    int lostPingCount = pingManager.increaseLostPingCount();
    int maxLostPingCount = pingManager.getMaxLostPingCount();
    if (lostPingCount >= maxLostPingCount) {
        client.getSocket().disconnect(EzyDisconnectReason.SERVER_NOT_RESPONDING.getId());
    } else {
        EzyRequest request = new EzyPingRequest();
        client.send(request);
    }
    if (lostPingCount > 1) {
        EzyLogger.info("lost ping count: " + lostPingCount);
        EzyLostPingEvent event = new EzyLostPingEvent(lostPingCount);
        socketEventQueue.addEvent(event);
    }
}
Also used : EzyRequest(com.tvd12.ezyfoxserver.client.request.EzyRequest) EzyPingRequest(com.tvd12.ezyfoxserver.client.request.EzyPingRequest) EzyLostPingEvent(com.tvd12.ezyfoxserver.client.event.EzyLostPingEvent)

Example 4 with EzyRequest

use of com.tvd12.ezyfoxserver.client.request.EzyRequest 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;
}
Also used : EzySimpleRequest(com.tvd12.ezyfoxserver.request.EzySimpleRequest)

Example 5 with EzyRequest

use of com.tvd12.ezyfoxserver.client.request.EzyRequest in project ezyfox-server-android-client by youngmonkeys.

the class EzyConnectionSuccessHandler method sendHandshakeRequest.

protected void sendHandshakeRequest() {
    EzyRequest request = newHandshakeRequest();
    client.send(request);
}
Also used : EzyRequest(com.tvd12.ezyfoxserver.client.request.EzyRequest)

Aggregations

EzyRequest (com.tvd12.ezyfoxserver.client.request.EzyRequest)3 EzyData (com.tvd12.ezyfoxserver.client.entity.EzyData)1 EzyLostPingEvent (com.tvd12.ezyfoxserver.client.event.EzyLostPingEvent)1 EzyPingRequest (com.tvd12.ezyfoxserver.client.request.EzyPingRequest)1 EzyController (com.tvd12.ezyfoxserver.controller.EzyController)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