Search in sources :

Example 1 with EzyPingRequest

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

the class EzyPingController method handle.

@Override
public void handle(EzyServerContext ctx, EzyPingRequest request) {
    EzyResponse response = EzyPongResponse.getInstance();
    EzySession session = request.getSession();
    ctx.send(response, session, false);
}
Also used : EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse) EzySession(com.tvd12.ezyfoxserver.entity.EzySession)

Example 2 with EzyPingRequest

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

Aggregations

EzyLostPingEvent (com.tvd12.ezyfoxserver.client.event.EzyLostPingEvent)1 EzyPingRequest (com.tvd12.ezyfoxserver.client.request.EzyPingRequest)1 EzyRequest (com.tvd12.ezyfoxserver.client.request.EzyRequest)1 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)1 EzyResponse (com.tvd12.ezyfoxserver.response.EzyResponse)1