public class MqttSimulatorTransport extends Object implements AutoCloseable, Transport
| Constructor and Description |
|---|
MqttSimulatorTransport(GatewayConfiguration configuration) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
connect()
Connect
|
void |
disconnect()
Disconnect gracefully
A later call to Transport.connect() must be possible. |
protected void |
handleConnected() |
protected void |
handleDisconnected() |
void |
sendMessage(Topic topic,
byte[] payload)
Send a message to a topic
|
void |
subscribe(Topic topic,
java.util.function.Consumer<Message> consumer)
Subscribe to a topic or topic pattern
|
void |
unsubscribe(Topic topic)
Unsubscribe from a topic or topic pattern
|
void |
whenConnected(Runnable runnable)
Set the runnable which will be called when a connection was established
|
void |
whenDisconnected(Runnable runnable)
Set the runnable which will be called when a connection was lost
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsendMessagepublic MqttSimulatorTransport(GatewayConfiguration configuration) throws org.eclipse.paho.client.mqttv3.MqttException
org.eclipse.paho.client.mqttv3.MqttExceptionpublic void connect()
Transportpublic void disconnect()
TransportTransport.connect() must be possible.disconnect in interface Transportpublic void close()
throws org.eclipse.paho.client.mqttv3.MqttException
close in interface AutoCloseableorg.eclipse.paho.client.mqttv3.MqttExceptionpublic void subscribe(Topic topic, java.util.function.Consumer<Message> consumer)
Transportpublic void unsubscribe(Topic topic)
Transportunsubscribe in interface Transporttopic - to unsubscribe frompublic void whenConnected(Runnable runnable)
TransportNote: When the connection is already established then this method won't be called again.
whenConnected in interface Transportpublic void whenDisconnected(Runnable runnable)
TransportwhenDisconnected in interface Transportprotected void handleConnected()
protected void handleDisconnected()
public void sendMessage(Topic topic, byte[] payload)
TransportsendMessage in interface Transporttopic - the topic to send the message topayload - the payload to sendCopyright © 2017. All rights reserved.