Untitled
unknown
plain_text
2 years ago
681 B
25
Indexable
String brokerUrl = "tcp://192.168.1.22:1883"; String clientId = "myClientId"; MqttClient mqttClient = new MqttClient(brokerUrl, clientId); mqttClient.connect(); String topic = "my/topic"; mqttClient.subscribe(topic); mqttClient.setCallback(new MqttCallback() { public void messageArrived(String topic, MqttMessage message) { String payload = new String(message.getPayload()); // vale to payload sth vash dedomenwn public void connectionLost(Throwable cause) { System.out.println("Connection lost: " + cause.getMessage()); } public void deliveryComplete(IMqttDeliveryToken token) { // Not used in this example } });
Editor is loading...