public void onSuccess(T value) { if( next!=null ) { next.onSuccess(value); } }
public void onFailure(Throwable value) { if( next!=null ) { next.onFailure(value); } } }
public void onSuccess(Callback<Void> value) { if (value != null) { value.onSuccess(null); } }
public void onFailure(Throwable value) { if( next!=null ) { next.onFailure(value); } } }
public void onSuccess(T value) { if( next!=null ) { next.onSuccess(value); } }
private void send(Request request) { if( failure !=null ) { if( request.cb!=null ) { request.cb.onFailure(failure); } } else { // Put the request in the map before sending it over the wire. if(request.id!=0) { this.requests.put(request.id, request); } if( overflow.isEmpty() && transport!=null && transport.offer(request.frame) ) { mqtt.tracer.onSend(request.frame); if(request.id==0) { if( request.cb!=null ) { ((Callback<Void>)request.cb).onSuccess(null); } } } else { // Remove it from the request. this.requests.remove(request.id); overflow.addLast(request); } } }
public void onFailure(Throwable value) { Callback<T> callback = null; synchronized(this) { error = value; latch.countDown(); callback = next; } if( callback!=null ) { callback.onFailure(value); } }
@Override public void run() { onCompleteCopy.onSuccess(onAcked); } });
mqtt.tracer.debug("MQTT login accepted"); onSessionEstablished(transport); cb.onSuccess(null); listener.onConnected(); queue.execute(new Task() { cb.onFailure(new MQTTException("Could not connect: " + connack.code(), connack)); cb.onFailure(new IOException("Could not connect. Received unexpected command: " + response.messageType())); mqtt.tracer.debug("Protocol error: %s", e); transport.stop(NOOP); cb.onFailure(e);
public void onSuccess(T value) { Callback<T> callback = null; synchronized(this) { this.value = value; latch.countDown(); callback = next; } if( callback!=null ) { callback.onSuccess(value); } }
public void connect(final Callback<Void> cb) { assert cb !=null : "Callback should not be null."; if( transport!=null ) { cb.onFailure(new IllegalStateException("Already connected")); return; } try { createTransport(new LoginHandler(cb, true)); } catch (Throwable e) { // This error happens when the MQTT config is invalid, reattempting // wont fix this case. cb.onFailure(e); } }
@Override public void onSuccess(Object value) { for (UTF8Buffer topic : topics) { activeSubs.remove(topic); } if(next!=null) { next.onSuccess(value); } } });
protected void handleMessageArrived(final String topic, final Buffer payload, final Callback<Callback<Void>> ack) { final MqttMessageHandler handler; synchronized (this) { handler = subscriptions.get(topic); } if (handler != null) { try { handler.handleMessage(topic, payload.toByteBuffer()); ack.onSuccess(null); } catch (Exception e) { ack.onFailure(e); } } }
public void onFailure(Throwable value) { // Socket failure, should we try to reconnect? if( !disconnected && tryReconnect() ) { reconnect(this); } else { // nope. cb.onFailure(value); } } }
@Override public void run() { listener.onDisconnected(); if (onComplete != null) { onComplete.onSuccess(null); } } });
protected void handleMessageArrived(final String topic, final Buffer payload, final Callback<Callback<Void>> ack) { final MqttMessageHandler handler; synchronized (this) { handler = subscriptions.get(topic); } if (handler != null) { try { handler.handleMessage(topic, payload.toByteBuffer()); ack.onSuccess(null); } catch (Exception e) { ack.onFailure(e); } } }
private void handleFatalFailure(Throwable error) { if( failure == null ) { failure = error; mqtt.tracer.debug("Fatal connection failure: %s", error); // Fail incomplete requests. ArrayList<Request> values = new ArrayList(requests.values()); requests.clear(); for (Request value : values) { if( value.cb!= null ) { value.cb.onFailure(failure); } } ArrayList<Request> overflowEntries = new ArrayList<Request>(overflow); overflow.clear(); for (Request entry : overflowEntries) { if( entry.cb !=null ) { entry.cb.onFailure(failure); } } if( listener !=null && !disconnected ) { try { listener.onFailure(failure); } catch (Exception e) { Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e); } } } }