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 boolean
protected com.hivemq.client.mqtt.mqtt3.Mqtt3AsyncClient
protected String
protected final AtomicBoolean
protected boolean
protected ScheduledExecutorService
protected String
static final Logger
protected int
protected boolean
protected final ConcurrentMap<String,
Set<Consumer<MQTTMessage<S>>>> protected org.openremote.model.auth.UsernamePassword
protected URI
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractMQTT_IOClient
(String host, int port, boolean secure, boolean cleanSession, org.openremote.model.auth.UsernamePassword usernamePassword, URI websocketURI, MQTTLastWill lastWill, KeyManagerFactory keyManagerFactory, TrustManagerFactory trustManagerFactory) protected
AbstractMQTT_IOClient
(String clientId, String host, int port, boolean secure, boolean cleanSession, org.openremote.model.auth.UsernamePassword usernamePassword, URI websocketURI, MQTTLastWill lastWill, KeyManagerFactory keyManagerFactory, TrustManagerFactory trustManagerFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConnectionStatusConsumer
(Consumer<org.openremote.model.asset.agent.ConnectionStatus> connectionStatusConsumer) Add a consumer of connection statusboolean
addMessageConsumer
(String topic, Consumer<MQTTMessage<S>> messageConsumer) void
addMessageConsumer
(Consumer<MQTTMessage<S>> messageConsumer) Add a consumer of received messagesvoid
connect()
Connect to the devicevoid
Disconnect from the deviceprotected boolean
doClientSubscription
(String topic, Set<Consumer<MQTTMessage<S>>> consumers) Should return a URI that uniquely identifies this client instanceorg.openremote.model.asset.agent.ConnectionStatus
Get current connection statusabstract S
messageFromBytes
(byte[] bytes) abstract byte[]
messageToBytes
(S message) protected void
protected void
onSubscribeFailed
(String topic) void
Remove every consumer of connection statusvoid
Remove every consumer of received messagesvoid
removeConnectionStatusConsumer
(Consumer<org.openremote.model.asset.agent.ConnectionStatus> connectionStatusConsumer) Remove a consumer of connection statusvoid
removeMessageConsumer
(String topic, Consumer<MQTTMessage<S>> messageConsumer) void
removeMessageConsumer
(Consumer<MQTTMessage<S>> messageConsumer) Remove a consumer of received messagesprotected void
removeSubscription
(String topic) void
sendMessage
(MQTTMessage<S> message) Send a message over the wirevoid
setTopicSubscribeFailureConsumer
(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
-
disconnected
protected boolean disconnected -
connected
-
topicSubscribeFailureConsumer
-
-
Constructor Details
-
AbstractMQTT_IOClient
protected AbstractMQTT_IOClient(String host, int port, boolean secure, boolean cleanSession, org.openremote.model.auth.UsernamePassword usernamePassword, URI websocketURI, MQTTLastWill lastWill, KeyManagerFactory keyManagerFactory, TrustManagerFactory trustManagerFactory) -
AbstractMQTT_IOClient
protected AbstractMQTT_IOClient(String clientId, String host, int port, boolean secure, boolean cleanSession, org.openremote.model.auth.UsernamePassword usernamePassword, URI websocketURI, MQTTLastWill lastWill, KeyManagerFactory keyManagerFactory, TrustManagerFactory trustManagerFactory)
-
-
Method Details
-
sendMessage
Description copied from interface:IOClient
Send a message over the wire- Specified by:
sendMessage
in interfaceIOClient<S>
-
addMessageConsumer
Description copied from interface:IOClient
Add a consumer of received messages- Specified by:
addMessageConsumer
in interfaceIOClient<S>
-
addMessageConsumer
-
setTopicSubscribeFailureConsumer
-
onSubscribeFailed
-
doClientSubscription
-
removeMessageConsumer
Description copied from interface:IOClient
Remove a consumer of received messages- Specified by:
removeMessageConsumer
in interfaceIOClient<S>
-
removeMessageConsumer
-
removeAllMessageConsumers
public void removeAllMessageConsumers()Description copied from interface:IOClient
Remove every consumer of received messages- Specified by:
removeAllMessageConsumers
in interfaceIOClient<S>
-
removeSubscription
-
addConnectionStatusConsumer
public void addConnectionStatusConsumer(Consumer<org.openremote.model.asset.agent.ConnectionStatus> connectionStatusConsumer) Description copied from interface:IOClient
Add a consumer of connection status- Specified by:
addConnectionStatusConsumer
in interfaceIOClient<S>
-
removeConnectionStatusConsumer
public void removeConnectionStatusConsumer(Consumer<org.openremote.model.asset.agent.ConnectionStatus> connectionStatusConsumer) Description copied from interface:IOClient
Remove a consumer of connection status- Specified by:
removeConnectionStatusConsumer
in interfaceIOClient<S>
-
removeAllConnectionStatusConsumers
public void removeAllConnectionStatusConsumers()Description copied from interface:IOClient
Remove every consumer of connection status- Specified by:
removeAllConnectionStatusConsumers
in interfaceIOClient<S>
-
getConnectionStatus
public org.openremote.model.asset.agent.ConnectionStatus getConnectionStatus()Description copied from interface:IOClient
Get current connection status- Specified by:
getConnectionStatus
in interfaceIOClient<S>
-
connect
public void connect()Description copied from interface:IOClient
Connect to the device -
onConnectionStatusChanged
protected void onConnectionStatusChanged() -
disconnect
public void disconnect()Description copied from interface:IOClient
Disconnect from the device- Specified by:
disconnect
in interfaceIOClient<S>
-
getClientUri
Description copied from interface:IOClient
Should return a URI that uniquely identifies this client instance- Specified by:
getClientUri
in interfaceIOClient<S>
-
messageToBytes
-
messageFromBytes
-