Created
January 20, 2018 03:38
-
-
Save beersheba/56678e4b978711b2789186b86468424f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void connect() { | |
MqttConnectOptions connectOptions = new MqttConnectOptions(); | |
connectOptions.setAutomaticReconnect(true); | |
client = new MqttAndroidClient(this, serverURI, clientId); | |
try { | |
client.connect(connectOptions, new IMqttActionListener() { | |
@Override | |
public void onSuccess(IMqttToken asyncActionToken) { | |
subscribe(); | |
} | |
@Override | |
public void onFailure(IMqttToken asyncActionToken, Throwable e) { | |
e.printStackTrace(); | |
} | |
}); | |
} catch (MqttException e) { | |
e.printStackTrace(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment