/** * An action has completed - if a completion listener has been set on the * token then invoke it with the outcome of the action. * * @param token The {@link MqttToken} that has completed */ public void fireActionEvent(MqttToken token) { final String methodName = "fireActionEvent"; if (token != null) { IMqttActionListener asyncCB = token.getActionCallback(); if (asyncCB != null) { if (token.getException() == null) { // @TRACE 716=call onSuccess key={0} log.fine(CLASS_NAME, methodName, "716", new Object[] { token.internalTok.getKey() }); asyncCB.onSuccess(token); } else { // @TRACE 717=call onFailure key {0} log.fine(CLASS_NAME, methodName, "716", new Object[] { token.internalTok.getKey() }); asyncCB.onFailure(token, token.getException()); } } } }
/** * notify unsuccessful completion of the operation */ void notifyFailure(Throwable exception) { synchronized (waitObject) { isComplete = true; if (exception instanceof MqttException) { pendingException = (MqttException) exception; } else { pendingException = new MqttException(exception); } waitObject.notifyAll(); if (exception instanceof MqttException) { lastException = (MqttException) exception; } if (listener != null) { listener.onFailure(this, exception); } } }
/** * notify successful completion of the operation */ void notifyComplete() { synchronized (waitObject) { isComplete = true; waitObject.notifyAll(); if (listener != null) { listener.onSuccess(this); } } }
/** * this method will be used to notify user that we have started connecting */ void notifyIntermediate() { listener.onIntermediate(this); }
public void mockConnectFail() { mockConnectionStatusCallback.onFailure(testToken, new Exception("fail")); isConnected = false; }
public void mockConnectSuccess() { mockConnectionStatusCallback.onSuccess(testToken); isConnected = true; }
@Override public void onIntermediate(IMqttToken asyncActionToken) { if(userCallback!=null) userCallback.onIntermediate(asyncActionToken); if(mqttCallbackExtended!=null)mqttCallbackExtended.startingConnect(reconnect); }
/** * An action has completed - if a completion listener has been set on the * token then invoke it with the outcome of the action. * * @param token The {@link MqttToken} that has completed */ public void fireActionEvent(MqttToken token) { final String methodName = "fireActionEvent"; if (token != null) { IMqttActionListener asyncCB = token.getActionCallback(); if (asyncCB != null) { if (token.getException() == null) { // @TRACE 716=call onSuccess key={0} log.fine(CLASS_NAME, methodName, "716", new Object[] { token.internalTok.getKey() }); asyncCB.onSuccess(token); } else { // @TRACE 717=call onFailure key {0} log.fine(CLASS_NAME, methodName, "716", new Object[] { token.internalTok.getKey() }); asyncCB.onFailure(token, token.getException()); } } } }
IMqttActionListener listener = token.getActionCallback(); if (listener != null) { listener.onFailure(token, new RuntimeException( "cannot start service " + SERVICE_NAME));
/** * notify successful completion of the operation */ void notifyComplete() { synchronized (waitObject) { isComplete = true; waitObject.notifyAll(); if (listener != null) { listener.onSuccess(this); } } }
/** * An action has completed - if a completion listener has been set on the * token then invoke it with the outcome of the action. * * @param token The {@link MqttToken} that has completed */ public void fireActionEvent(MqttToken token) { final String methodName = "fireActionEvent"; if (token != null) { IMqttActionListener asyncCB = token.getActionCallback(); if (asyncCB != null) { if (token.getException() == null) { // @TRACE 716=call onSuccess key={0} log.fine(CLASS_NAME, methodName, "716", new Object[] { token.internalTok.getKey() }); asyncCB.onSuccess(token); } else { // @TRACE 717=call onFailure key {0} log.fine(CLASS_NAME, methodName, "716", new Object[] { token.internalTok.getKey() }); asyncCB.onFailure(token, token.getException()); } } } }
/** * Actually do the mqtt connect operation */ private void doConnect() { if (clientHandle == null) { clientHandle = mqttService.getClient(serverURI, clientId,myContext.getApplicationInfo().packageName, persistence); } mqttService.setTraceEnabled(traceEnabled); mqttService.setTraceCallbackId(clientHandle); String activityToken = storeToken(connectToken); try { mqttService.connect(clientHandle, connectOptions, null, activityToken); } catch (MqttException e) { IMqttActionListener listener = connectToken.getActionCallback(); if (listener != null) { listener.onFailure(connectToken, e); } } }
/** * notify successful completion of the operation */ void notifyComplete() { synchronized (waitObject) { isComplete = true; waitObject.notifyAll(); if (listener != null) { listener.onSuccess(this); } } }
/** * An action has completed - if a completion listener has been set on the * token then invoke it with the outcome of the action. * * @param token */ public void fireActionEvent(MqttToken token) { final String methodName = "fireActionEvent"; if (token != null) { IMqttActionListener asyncCB = token.getActionCallback(); if (asyncCB != null) { if (token.getException() == null) { // @TRACE 716=call onSuccess key={0} log.fine(className, methodName, "716", new Object[] { token.internalTok.getKey() }); asyncCB.onSuccess(token); } else { // @TRACE 717=call onFailure key {0} log.fine(className, methodName, "716", new Object[] { token.internalTok.getKey() }); asyncCB.onFailure(token, token.getException()); } } } }
/** * notify unsuccessful completion of the operation */ void notifyFailure(Throwable exception) { synchronized (waitObject) { isComplete = true; if (exception instanceof MqttException) { pendingException = (MqttException) exception; } else { pendingException = new MqttException(exception); } waitObject.notifyAll(); if (exception instanceof MqttException) { lastException = (MqttException) exception; } if (listener != null) { listener.onFailure(this, exception); } } }
/** * If the connect succeeded then call the users onSuccess callback * * @param token the {@link IMqttToken} from the successful connection */ public void onSuccess(IMqttToken token) { if (originalMqttVersion == MqttConnectOptions.MQTT_VERSION_DEFAULT) { options.setMqttVersion(MqttConnectOptions.MQTT_VERSION_DEFAULT); } userToken.internalTok.markComplete(token.getResponse(), null); userToken.internalTok.notifyComplete(); userToken.internalTok.setClient(this.client); // fix bug 469527 - maybe should be set elsewhere? comms.notifyConnect(); if (userCallback != null) { userToken.setUserContext(userContext); userCallback.onSuccess(userToken); } if(mqttCallbackExtended != null){ String serverURI = comms.getNetworkModules()[comms.getNetworkModuleIndex()].getServerURI(); mqttCallbackExtended.connectComplete(reconnect, serverURI); } }
userCallback.onFailure(userToken, exception);
/** * If the connect succeeded then call the users onSuccess callback * * @param token */ public void onSuccess(IMqttToken token) { userToken.internalTok.markComplete(null, null); userToken.internalTok.notifyComplete(); if (userCallback != null) { userToken.setUserContext(userContext); userCallback.onSuccess(userToken); } }
/** * notify unsuccessful completion of the operation */ void notifyFailure(Throwable exception) { synchronized (waitObject) { isComplete = true; if (exception instanceof MqttException) { pendingException = (MqttException) exception; } else { pendingException = new MqttException(exception); } waitObject.notifyAll(); if (exception instanceof MqttException) { lastException = (MqttException) exception; } if (listener != null) { listener.onFailure(this, exception); } } }
/** * If the connect succeeded then call the users onSuccess callback * * @param token the {@link IMqttToken} from the successful connection */ public void onSuccess(IMqttToken token) { if (originalMqttVersion == MqttConnectOptions.MQTT_VERSION_DEFAULT) { options.setMqttVersion(MqttConnectOptions.MQTT_VERSION_DEFAULT); } userToken.internalTok.markComplete(token.getResponse(), null); userToken.internalTok.notifyComplete(); userToken.internalTok.setClient(this.client); // fix bug 469527 - maybe should be set elsewhere? comms.notifyConnect(); if (userCallback != null) { userToken.setUserContext(userContext); userCallback.onSuccess(userToken); } if(mqttCallbackExtended != null){ String serverURI = comms.getNetworkModules()[comms.getNetworkModuleIndex()].getServerURI(); mqttCallbackExtended.connectComplete(reconnect, serverURI); } }