private void onFailure(final Throwable error) { if(!transport.isClosed()) { transport.stop(new Task() { @Override public void run() { onConnect.onFailure(error); } }); } } });
public void run() { if(!executed) { executed = true; requests.remove(requestId); if(heartBeatMonitor!=null) { heartBeatMonitor.stop(); heartBeatMonitor = null; } transport.stop(new Task() { @Override public void run() { listener.onDisconnected(); if (onComplete != null) { onComplete.onSuccess(null); } } }); } } };
@Override public void onTransportFailure(IOException error) { mqtt.tracer.debug("Transport failure: %s", error); transport.stop(NOOP); onFailure(error); }
/** * Kills the connection without a graceful disconnect. * @param onComplete */ public void kill(final Callback<Void> onComplete) { if( disconnected ) { if(onComplete!=null){ onComplete.onSuccess(null); } return; } disconnected = true; if(heartBeatMonitor!=null) { heartBeatMonitor.stop(); heartBeatMonitor = null; } transport.stop(new Task() { @Override public void run() { listener.onDisconnected(); if (onComplete != null) { onComplete.onSuccess(null); } } }); }
void handleSessionFailure(Throwable error) { // Socket failure, should we try to reconnect? if( !disconnected && (mqtt.reconnectAttemptsMax<0 || reconnects < mqtt.reconnectAttemptsMax ) ) { mqtt.tracer.debug("Reconnecting transport"); // Cleanup the previous transport. if(heartBeatMonitor!=null) { heartBeatMonitor.stop(); heartBeatMonitor = null; } final Transport t = transport; transport = null; if(t!=null) { t.stop(new Task() { @Override public void run() { listener.onDisconnected(); reconnect(); } }); } else { reconnect(); } } else { // nope. handleFatalFailure(error); } }
mqtt.tracer.debug("MQTT login rejected"); transport.stop(NOOP); cb.onFailure(new MQTTException("Could not connect: " + connack.code(), connack)); mqtt.tracer.debug("Received unexpected MQTT frame: %d", response.messageType()); transport.stop(NOOP); cb.onFailure(new IOException("Could not connect. Received unexpected command: " + response.messageType())); transport.stop(NOOP); cb.onFailure(e);
public void onTransportFailure(final IOException error) { transport.stop(new Task() { public void run() { cb.onFailure(error); } }); } };
public void onTransportFailure(final IOException error) { transport.stop(new Task() { public void run() { cb.onFailure(error); } }); } };
public void stop(Runnable onComplete) { next.stop(onComplete); }
public void stop(Task onComplete) { next.stop(onComplete); }
private void onFailure(final Throwable error) { if(!transport.isClosed()) { transport.stop(new Task() { @Override public void run() { onConnect.onFailure(error); } }); } } });
public void close(final Runnable onComplete) { failRequests(new ClosedChannelException()); this.transport.stop(new Task() { public void run() { if( onComplete!=null ) { onComplete.run(); } } }); }
public void close(final Runnable onComplete) { failRequests(new ClosedChannelException()); this.transport.stop(new Task() { public void run() { if( onComplete!=null ) { onComplete.run(); } } }); }
public void disconnect() { assertExecuting(); if( state == CONNECTING || state==CONNECTED) { state = DISCONNECTING; if( hawtdispatchTransport!=null ) { hawtdispatchTransport.stop(new Task(){ public void run() { state = DISCONNECTED; hawtdispatchTransport = null; protonTransport = null; fireWatches(); } }); } } }
public void run() { if(!executed) { executed = true; requests.remove(requestId); if(heartBeatMonitor!=null) { heartBeatMonitor.stop(); heartBeatMonitor = null; } transport.stop(new Task() { @Override public void run() { listener.onDisconnected(); if (onComplete != null) { onComplete.onSuccess(null); } } }); } } };
@Override public void onTransportFailure(IOException error) { mqtt.tracer.debug("Transport failure: %s", error); transport.stop(NOOP); onFailure(error); }
@Override public void stop(ILifecycleProgressMonitor monitor) throws SiteWhereException { if (connection != null) { try { connection.disconnect(new Callback<Void>() { @Override public void onFailure(Throwable e) { LOGGER.info("MQTT disconnect failed."); } @Override public void onSuccess(Void arg0) { } }); connection.transport().stop(new Runnable() { @Override public void run() { LOGGER.info("MQTT connection transport stopped."); } }); } catch (Exception e) { LOGGER.error("Error shutting down MQTT device event receiver.", e); } } }
/** * Kills the connection without a graceful disconnect. * @param onComplete */ public void kill(final Callback<Void> onComplete) { if( disconnected ) { if(onComplete!=null){ onComplete.onSuccess(null); } return; } disconnected = true; if(heartBeatMonitor!=null) { heartBeatMonitor.stop(); heartBeatMonitor = null; } transport.stop(new Task() { @Override public void run() { listener.onDisconnected(); if (onComplete != null) { onComplete.onSuccess(null); } } }); }
@Override public void stop(ILifecycleProgressMonitor monitor) throws SiteWhereException { if (connection != null) { try { connection.disconnect(new Callback<Void>() { @Override public void onFailure(Throwable e) { getLogger().info("MQTT disconnect failed."); } @Override public void onSuccess(Void arg0) { } }); connection.transport().stop(new Runnable() { @Override public void run() { getLogger().info("MQTT connection transport stopped."); } }); } catch (Exception e) { getLogger().error("Error shutting down MQTT device event receiver.", e); } } }
void handleSessionFailure(Throwable error) { // Socket failure, should we try to reconnect? if( !disconnected && (mqtt.reconnectAttemptsMax<0 || reconnects < mqtt.reconnectAttemptsMax ) ) { mqtt.tracer.debug("Reconnecting transport"); // Cleanup the previous transport. if(heartBeatMonitor!=null) { heartBeatMonitor.stop(); heartBeatMonitor = null; } final Transport t = transport; transport = null; if(t!=null) { t.stop(new Task() { @Override public void run() { listener.onDisconnected(); reconnect(); } }); } else { reconnect(); } } else { // nope. handleFatalFailure(error); } }