Search in sources :

Example 1 with EzyLostPingEvent

use of com.tvd12.ezyfoxserver.client.event.EzyLostPingEvent 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