protected override void process(EzyDisconnectionEvent evt) { String reasonName = EzyDisconnectReasons.getDisconnectReasonName(evt.getReason()); logger.info("handle disconnection, reason = " + reasonName); preHandle(evt); EzyClientConfig config = client.getConfig(); EzyReconnectConfig reconnectConfig = config.getReconnect(); bool should = shouldReconnect(evt); bool mustReconnect = reconnectConfig.isEnable() && evt.getReason() != (int)EzyDisconnectReason.UNAUTHORIZED && evt.getReason() != (int)EzyDisconnectReason.CLOSE && should; bool reconnecting = false; client.setStatus(EzyConnectionStatus.DISCONNECTED); client.setUdpStatus(EzyConnectionStatus.DISCONNECTED); if (mustReconnect) { reconnecting = client.reconnect(); } if (reconnecting) { onReconnecting(evt); } else { onDisconnected(evt); } postHandle(evt); }
protected override sealed void process(EzyConnectionFailureEvent evt) { logger.info("connection failure, reason = " + evt.getReason()); EzyClientConfig config = client.getConfig(); EzyReconnectConfig reconnectConfig = config.getReconnect(); bool should = shouldReconnect(evt); bool mustReconnect = reconnectConfig.isEnable() && should; bool reconnecting = false; client.setStatus(EzyConnectionStatus.FAILURE); if (mustReconnect) { reconnecting = client.reconnect(); } if (reconnecting) { onReconnecting(evt); } else { onConnectionFailed(evt); } postHandle(evt); }
public void setReconnectConfig(EzyReconnectConfig reconnectConfig) { this.reconnectConfig = reconnectConfig; }