Class AbstractMQTT_IOClient<S>
java.lang.Object
org.openremote.agent.protocol.mqtt.AbstractMQTT_IOClient<S>
- All Implemented Interfaces:
IOClient<MQTTMessage<S>>
- Direct Known Subclasses:
MQTT_IOClient
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected com.hivemq.client.mqtt.mqtt3.Mqtt3AsyncClientprotected Stringprotected org.openremote.model.asset.agent.ConnectionStatusprotected booleanprotected ScheduledExecutorServiceprotected Stringstatic final Loggerprotected intprotected booleanprotected org.openremote.model.auth.UsernamePasswordprotected URI -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractMQTT_IOClient(String host, int port, boolean secure, boolean cleanSession, org.openremote.model.auth.UsernamePassword usernamePassword, URI websocketURI) protectedAbstractMQTT_IOClient(String clientId, String host, int port, boolean secure, boolean cleanSession, org.openremote.model.auth.UsernamePassword usernamePassword, URI websocketURI) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConnectionStatusConsumer(Consumer<org.openremote.model.asset.agent.ConnectionStatus> connectionStatusConsumer) Add a consumer of connection statusbooleanaddMessageConsumer(String topic, Consumer<MQTTMessage<S>> messageConsumer) voidaddMessageConsumer(Consumer<MQTTMessage<S>> messageConsumer) Add a consumer of received messagesvoidconnect()Connect to the devicevoidDisconnect from the deviceprotected booleandoClientSubscription(String topic, Set<Consumer<MQTTMessage<S>>> consumers) Should return a URI that uniquely identifies this client instanceorg.openremote.model.asset.agent.ConnectionStatusGet current connection statusabstract SmessageFromBytes(byte[] bytes) abstract byte[]messageToBytes(S message) protected voidonConnectionStatusChanged(org.openremote.model.asset.agent.ConnectionStatus connectionStatus) protected voidonSubscribeFailed(String topic) voidRemove every consumer of connection statusvoidRemove every consumer of received messagesvoidremoveConnectionStatusConsumer(Consumer<org.openremote.model.asset.agent.ConnectionStatus> connectionStatusConsumer) Remove a consumer of connection statusvoidremoveMessageConsumer(String topic, Consumer<MQTTMessage<S>> messageConsumer) voidremoveMessageConsumer(Consumer<MQTTMessage<S>> messageConsumer) Remove a consumer of received messagesprotected voidremoveSubscription(String topic) voidsendMessage(MQTTMessage<S> message) Send a message over the wirevoidsetTopicSubscribeFailureConsumer(Consumer<String> topicSubscribeFailureConsumer)
-
Field Details
-
LOG
-
clientId
-
host
-
port
protected int port -
secure
protected boolean secure -
cleanSession
protected boolean cleanSession -
usernamePassword
protected org.openremote.model.auth.UsernamePassword usernamePassword -
websocketURI
-
client
protected com.hivemq.client.mqtt.mqtt3.Mqtt3AsyncClient client -
connectionStatusConsumers
-
topicConsumerMap
-
executorService
-
connectionStatus
protected org.openremote.model.asset.agent.ConnectionStatus connectionStatus -
disconnected
protected boolean disconnected -
topicSubscribeFailureConsumer
-
-
Constructor Details
-
AbstractMQTT_IOClient
-
AbstractMQTT_IOClient
-
-
Method Details
-
sendMessage
Description copied from interface:IOClientSend a message over the wire- Specified by:
sendMessagein interfaceIOClient<S>
-
addMessageConsumer
Description copied from interface:IOClientAdd a consumer of received messages- Specified by:
addMessageConsumerin interfaceIOClient<S>
-
addMessageConsumer
-
setTopicSubscribeFailureConsumer
-
onSubscribeFailed
-
doClientSubscription
-
removeMessageConsumer
Description copied from interface:IOClientRemove a consumer of received messages- Specified by:
removeMessageConsumerin interfaceIOClient<S>
-
removeMessageConsumer
-
removeAllMessageConsumers
public void removeAllMessageConsumers()Description copied from interface:IOClientRemove every consumer of received messages- Specified by:
removeAllMessageConsumersin interfaceIOClient<S>
-
removeSubscription
-
addConnectionStatusConsumer
public void addConnectionStatusConsumer(Consumer<org.openremote.model.asset.agent.ConnectionStatus> connectionStatusConsumer) Description copied from interface:IOClientAdd a consumer of connection status- Specified by:
addConnectionStatusConsumerin interfaceIOClient<S>
-
removeConnectionStatusConsumer
public void removeConnectionStatusConsumer(Consumer<org.openremote.model.asset.agent.ConnectionStatus> connectionStatusConsumer) Description copied from interface:IOClientRemove a consumer of connection status- Specified by:
removeConnectionStatusConsumerin interfaceIOClient<S>
-
removeAllConnectionStatusConsumers
public void removeAllConnectionStatusConsumers()Description copied from interface:IOClientRemove every consumer of connection status- Specified by:
removeAllConnectionStatusConsumersin interfaceIOClient<S>
-
getConnectionStatus
public org.openremote.model.asset.agent.ConnectionStatus getConnectionStatus()Description copied from interface:IOClientGet current connection status- Specified by:
getConnectionStatusin interfaceIOClient<S>
-
connect
public void connect()Description copied from interface:IOClientConnect to the device -
onConnectionStatusChanged
protected void onConnectionStatusChanged(org.openremote.model.asset.agent.ConnectionStatus connectionStatus) -
disconnect
public void disconnect()Description copied from interface:IOClientDisconnect from the device- Specified by:
disconnectin interfaceIOClient<S>
-
getClientUri
Description copied from interface:IOClientShould return a URI that uniquely identifies this client instance- Specified by:
getClientUriin interfaceIOClient<S>
-
messageToBytes
-
messageFromBytes
-