private void doAfterConnectFail(final Bundle resultBundle){ // acquireWakeLock(); disconnected = true; setConnectingState(false); service.callbackToActivity(clientHandle, Status.ERROR, resultBundle); releaseWakeLock(); }
/** * Get the status of a specific client * * @param clientHandle * identifies the MqttConnection to use * @return true if the specified client is connected to an MQTT server */ public boolean isConnected(String clientHandle) { MqttConnection client = getConnection(clientHandle); return client.isConnected(); }
/** * Get tokens for all outstanding deliveries for a client * * @param clientHandle * identifies the MqttConnection * @return an array (possibly empty) of tokens */ public IMqttDeliveryToken[] getPendingDeliveryTokens(String clientHandle) { MqttConnection client = getConnection(clientHandle); return client.getPendingDeliveryTokens(); }
/** * Process the results of a connection * * @param data */ private void connectAction(Bundle data) { IMqttToken token = connectToken; removeMqttToken(data); simpleAction(token, data); }
/** * Close connection from a particular client * * @param clientHandle * identifies the MqttConnection to use */ public void close(String clientHandle) { MqttConnection client = getConnection(clientHandle); client.close(); }
/** * Sets the DisconnectedBufferOptions for this client * @param clientHandle identifier for the client * @param bufferOpts the DisconnectedBufferOptions for this client */ public void setBufferOpts(String clientHandle, DisconnectedBufferOptions bufferOpts) { MqttConnection client = getConnection(clientHandle); client.setBufferOpts(bufferOpts); }
public int getBufferedMessageCount(String clientHandle){ MqttConnection client = getConnection(clientHandle); return client.getBufferedMessageCount(); }
public void deleteBufferedMessage(String clientHandle, int bufferIndex){ MqttConnection client = getConnection(clientHandle); client.deleteBufferedMessage(bufferIndex); }
public MqttMessage getBufferedMessage(String clientHandle, int bufferIndex){ MqttConnection client = getConnection(clientHandle); return client.getBufferedMessage(bufferIndex); }
/** * Process notification of a publish(send) operation * * @param data */ private void sendAction(Bundle data) { IMqttToken token = getMqttToken(data); // get, don't remove - will // remove on delivery simpleAction(token, data); }
/** * Trace debugging information * * @param tag * identifier for the source of the trace * @param message * the text to be traced */ @Override public void traceDebug(String tag, String message) { traceCallback(MqttServiceConstants.TRACE_DEBUG, tag, message); }
@Override public void onSuccess(IMqttToken asyncActionToken) { // since the device's cpu can go to sleep, acquire a // wakelock and drop it later. service.traceDebug(TAG,"Reconnect Success!"); service.traceDebug(TAG,"DeliverBacklog when reconnect."); doAfterConnectSuccess(resultBundle); }
@Override public void onServiceConnected(ComponentName name, IBinder binder) { mqttService = ((MqttServiceBinder) binder).getService(); bindedService = true; // now that we have the service available, we can actually // connect... doConnect(); }
/** * Sets the DisconnectedBufferOptions for this client * @param bufferOpts the DisconnectedBufferOptions */ public void setBufferOpts(DisconnectedBufferOptions bufferOpts) { mqttService.setBufferOpts(clientHandle, bufferOpts); }
/** * Determines if this client is currently connected to the server. * * @return <code>true</code> if connected, <code>false</code> otherwise. */ @Override public boolean isConnected() { return clientHandle != null && mqttService != null && mqttService.isConnected(clientHandle); }
private void doAfterConnectSuccess(final Bundle resultBundle) { //since the device's cpu can go to sleep, acquire a wakelock and drop it later. acquireWakeLock(); service.callbackToActivity(clientHandle, Status.OK, resultBundle); deliverBacklog(); setConnectingState(false); disconnected = false; releaseWakeLock(); }
/** * Process notification of a subscribe operation * * @param data */ private void subscribeAction(Bundle data) { IMqttToken token = removeMqttToken(data); simpleAction(token, data); }
/** * Trace error information * * @param tag * identifier for the source of the trace * @param message * the text to be traced */ @Override public void traceError(String tag, String message) { traceCallback(MqttServiceConstants.TRACE_ERROR, tag, message); }
@Override public void onSuccess(IMqttToken asyncActionToken) { doAfterConnectSuccess(resultBundle); service.traceDebug(TAG, "connect success!"); }
/** * Process notification of an unsubscribe operation * * @param data */ private void unSubscribeAction(Bundle data) { IMqttToken token = removeMqttToken(data); simpleAction(token, data); }