use of com.tvd12.ezyfoxserver.client.event.EzyConnectionFailureEvent in project ezyfox-server-android-client by youngmonkeys.
the class EzyConnectionFailureHandler method handle.
@Override
public final void handle(EzyConnectionFailureEvent event) {
EzyLogger.info("connection failure, reason = " + event.getReason());
EzyClientConfig config = client.getConfig();
EzyReconnectConfig reconnectConfig = config.getReconnect();
boolean shouldReconnect = shouldReconnect(event);
boolean mustReconnect = reconnectConfig.isEnable() && shouldReconnect;
boolean reconnecting = false;
client.setStatus(EzyConnectionStatus.FAILURE);
if (mustReconnect)
reconnecting = client.reconnect();
if (reconnecting) {
onReconnecting(event);
} else {
onConnectionFailed(event);
}
postHandle(event);
}
use of com.tvd12.ezyfoxserver.client.event.EzyConnectionFailureEvent in project ezyfox-server-android-client by youngmonkeys.
the class EzySocketClient method processStatuses.
protected void processStatuses() {
socketStatuses.popAll(localSocketStatuses);
for (int i = 0; i < localSocketStatuses.size(); ++i) {
EzySocketStatus status = localSocketStatuses.get(i);
if (status == EzySocketStatus.CONNECTED) {
EzyEvent evt = new EzyConnectionSuccessEvent();
socketEventQueue.addEvent(evt);
} else if (status == EzySocketStatus.CONNECT_FAILED) {
EzyEvent evt = new EzyConnectionFailureEvent(connectionFailedReason);
socketEventQueue.addEvent(evt);
break;
} else if (status == EzySocketStatus.DISCONNECTED) {
EzyEvent evt = new EzyDisconnectionEvent(disconnectReason);
socketEventQueue.addEvent(evt);
break;
}
}
localSocketStatuses.clear();
}
Aggregations