Package io.vertx.mqtt
Interface MqttEndpoint
-
public interface MqttEndpointRepresents an MQTT endpoint for point-to-point communication with the remote MQTT client
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description MqttEndpointaccept()Likeaccept(boolean)with no session is present.MqttEndpointaccept(boolean sessionPresent)Sends the CONNACK message to the remote MQTT client with "connection accepted" return code.MqttEndpointaccept(boolean sessionPresent, MqttProperties properties)Sends the CONNACK message to the remote MQTT client with "connection accepted" return code.MqttAuthauth()MqttEndpointauthenticationExchange(MqttAuthenticationExchangeMessage message)Sends the AUTH message to the remote MQTT clientMqttEndpointauthenticationExchangeHandler(Handler<MqttAuthenticationExchangeMessage> handler)Set the auth handler on the MQTT endpoint.MqttEndpointautoKeepAlive(boolean isAutoKeepAlive)Enable/disable auto keep alive (sending ping response)StringclientIdentifier()voidclose()Close the endpoint, so the connection with remote MQTT clientMqttEndpointcloseHandler(Handler<Void> handler)Set a close handler.MqttPropertiesconnectProperties()MqttEndpointdisconnect(MqttDisconnectReasonCode code, MqttProperties properties)Sends the DISCONNECT message to the remote MQTT clientMqttEndpointdisconnectHandler(Handler<Void> handler)Set a disconnect handler on the MQTT endpoint.MqttEndpointdisconnectMessageHandler(Handler<MqttDisconnectMessage> handler)Set a disconnect handler on the MQTT endpoint.MqttEndpointexceptionHandler(Handler<Throwable> handler)Set an exception handler.MultiMaphttpHeaders()Returns the HTTP headers sent by the client when a WebSocket transport is used otherwisenullStringhttpRequestURI()Returns the HTTP request URI sent by the client when a WebSocket transport is used otherwisenullbooleanisAutoKeepAlive()booleanisCleanSession()booleanisConnected()booleanisPublishAutoAck()booleanisSsl()booleanisSubscriptionAutoAck()intkeepAliveTimeSeconds()intlastMessageId()SocketAddresslocalAddress()MqttEndpointpingHandler(Handler<Void> handler)Set the pingreq handler on the MQTT endpoint.MqttEndpointpong()Sends the PINGRESP message to the remote MQTT clientStringprotocolName()intprotocolVersion()Future<Integer>publish(String topic, Buffer payload, MqttQoS qosLevel, boolean isDup, boolean isRetain)Sends the PUBLISH message to the remote MQTT clientFuture<Integer>publish(String topic, Buffer payload, MqttQoS qosLevel, boolean isDup, boolean isRetain, int messageId)Sends the PUBLISH message to the remote MQTT server explicitly specifying the messageIdFuture<Integer>publish(String topic, Buffer payload, MqttQoS qosLevel, boolean isDup, boolean isRetain, int messageId, MqttProperties properties)Sends the PUBLISH message to the remote MQTT server explicitly specifying the messageIdMqttEndpointpublishAcknowledge(int publishMessageId)Sends the PUBACK message to the remote MQTT clientMqttEndpointpublishAcknowledge(int publishMessageId, MqttPubAckReasonCode reasonCode, MqttProperties properties)MqttEndpointpublishAcknowledgeHandler(Handler<Integer> handler)Set the puback handler on the MQTT endpoint.MqttEndpointpublishAcknowledgeMessageHandler(Handler<MqttPubAckMessage> handler)Set the puback handler on the MQTT endpoint.MqttEndpointpublishAutoAck(boolean isPublishAutoAck)Enable/disable publishing (in/out) auto acknowledgeMqttEndpointpublishComplete(int publishMessageId)Sends the PUBCOMP message to the remote MQTT clientMqttEndpointpublishComplete(int publishMessageId, MqttPubCompReasonCode reasonCode, MqttProperties properties)Sends the PUBCOMP message to the remote MQTT clientMqttEndpointpublishCompletionHandler(Handler<Integer> handler)Set the pubcomp handler on the MQTT endpoint.MqttEndpointpublishCompletionMessageHandler(Handler<MqttPubCompMessage> handler)Set the pubcomp handler on the MQTT endpoint.MqttEndpointpublishHandler(Handler<MqttPublishMessage> handler)Set the publish handler on the MQTT endpoint.MqttEndpointpublishReceived(int publishMessageId)Sends the PUBREC message to the remote MQTT clientMqttEndpointpublishReceived(int publishMessageId, MqttPubRecReasonCode reasonCode, MqttProperties properties)Sends the PUBREC message to the remote MQTT clientMqttEndpointpublishReceivedHandler(Handler<Integer> handler)Set the pubrec handler on the MQTT endpoint.MqttEndpointpublishReceivedMessageHandler(Handler<MqttPubRecMessage> handler)Set the pubrec handler on the MQTT endpoint.MqttEndpointpublishRelease(int publishMessageId)Sends the PUBREL message to the remote MQTT clientMqttEndpointpublishRelease(int publishMessageId, MqttPubRelReasonCode reasonCode, MqttProperties properties)Sends the PUBREL message to the remote MQTT clientMqttEndpointpublishReleaseHandler(Handler<Integer> handler)Set the pubrel handler on the MQTT endpoint.MqttEndpointpublishReleaseMessageHandler(Handler<MqttPubRelMessage> handler)Set the pubrel handler on the MQTT endpoint.MqttEndpointreject(MqttConnectReturnCode returnCode)Sends the CONNACK message to the remote MQTT client rejecting the connection request with specified return code.MqttEndpointreject(MqttConnectReturnCode returnCode, MqttProperties properties)Sends the CONNACK message to the remote MQTT client rejecting the connection request with specified return code.SocketAddressremoteAddress()MqttEndpointsetClientIdentifier(String clientIdentifier)Set client identifier if not provided by the remote MQTT client (zero-bytes)SSLSessionsslSession()MqttEndpointsubscribeAcknowledge(int subscribeMessageId, List<MqttQoS> grantedQoSLevels)Sends the SUBACK message to the remote MQTT clientMqttEndpointsubscribeAcknowledge(int subscribeMessageId, List<MqttSubAckReasonCode> reasonCodes, MqttProperties properties)Sends the SUBACK message to the remote MQTT clientMqttEndpointsubscribeHandler(Handler<MqttSubscribeMessage> handler)Set a subscribe handler on the MQTT endpoint.voidsubscriptionAutoAck(boolean isSubscriptionAutoAck)Enable/disable subscription/unsubscription requests auto acknowledgeMqttEndpointunsubscribeAcknowledge(int unsubscribeMessageId)Sends the UNSUBACK message to the remote MQTT clientMqttEndpointunsubscribeAcknowledge(int unsubscribeMessageId, List<MqttUnsubAckReasonCode> reasonCodes, MqttProperties properties)Sends the UNSUBACK message to the remote MQTT clientMqttEndpointunsubscribeHandler(Handler<MqttUnsubscribeMessage> handler)Set a unsubscribe handler on the MQTT endpoint.MqttWillwill()
-
-
-
Method Detail
-
close
void close()
Close the endpoint, so the connection with remote MQTT client
-
remoteAddress
SocketAddress remoteAddress()
- Returns:
- the remote address for this socket
-
localAddress
SocketAddress localAddress()
- Returns:
- the local address for this socket
-
isSsl
boolean isSsl()
- Returns:
- true if this
MqttEndpointis encrypted via SSL/TLS.
-
httpHeaders
MultiMap httpHeaders()
Returns the HTTP headers sent by the client when a WebSocket transport is used otherwisenull- Returns:
- the HTTP headers
-
httpRequestURI
String httpRequestURI()
Returns the HTTP request URI sent by the client when a WebSocket transport is used otherwisenull- Returns:
- the HTTP request uri
-
sslSession
SSLSession sslSession()
- Returns:
- SSLSession associated with the underlying socket. Returns null if connection is not SSL.
- See Also:
SSLSession
-
clientIdentifier
String clientIdentifier()
- Returns:
- the client identifier as provided by the remote MQTT client
-
auth
MqttAuth auth()
- Returns:
- the Authentication information as provided by the remote MQTT client
-
will
MqttWill will()
- Returns:
- the Will information as provided by the remote MQTT client
-
protocolVersion
int protocolVersion()
- Returns:
- the protocol version required by the remote MQTT client
-
protocolName
String protocolName()
- Returns:
- the protocol name provided by the remote MQTT client
-
isCleanSession
boolean isCleanSession()
- Returns:
- true when clean session is requested by the remote MQTT client
-
keepAliveTimeSeconds
int keepAliveTimeSeconds()
- Returns:
- the keep alive timeout (in seconds) specified by the remote MQTT client
-
lastMessageId
int lastMessageId()
- Returns:
- the message identifier used for last published message
-
subscriptionAutoAck
void subscriptionAutoAck(boolean isSubscriptionAutoAck)
Enable/disable subscription/unsubscription requests auto acknowledge- Parameters:
isSubscriptionAutoAck- auto acknowledge status
-
isSubscriptionAutoAck
boolean isSubscriptionAutoAck()
- Returns:
- true when auto acknowledge status for subscription/unsubscription requests
-
publishAutoAck
MqttEndpoint publishAutoAck(boolean isPublishAutoAck)
Enable/disable publishing (in/out) auto acknowledge- Parameters:
isPublishAutoAck- auto acknowledge status- Returns:
- a reference to this, so the API can be used fluently
-
isPublishAutoAck
boolean isPublishAutoAck()
- Returns:
- auto acknowledge status for publishing (in/out)
-
autoKeepAlive
MqttEndpoint autoKeepAlive(boolean isAutoKeepAlive)
Enable/disable auto keep alive (sending ping response)- Parameters:
isAutoKeepAlive- auto keep alive- Returns:
- a reference to this, so the API can be used fluently
-
isAutoKeepAlive
boolean isAutoKeepAlive()
- Returns:
- the auto keep alive status (sending ping response)
-
isConnected
boolean isConnected()
- Returns:
- if the connection between remote client and local endpoint is established/open
-
connectProperties
MqttProperties connectProperties()
- Returns:
- MQTT properties of the CONNECT message
-
setClientIdentifier
MqttEndpoint setClientIdentifier(String clientIdentifier)
Set client identifier if not provided by the remote MQTT client (zero-bytes)- Parameters:
clientIdentifier- the client identifier- Returns:
- a reference to this, so the API can be used fluently
-
disconnectHandler
MqttEndpoint disconnectHandler(Handler<Void> handler)
Set a disconnect handler on the MQTT endpoint. This handler is called when a DISCONNECT message is received by the remote MQTT client- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
disconnectMessageHandler
MqttEndpoint disconnectMessageHandler(Handler<MqttDisconnectMessage> handler)
Set a disconnect handler on the MQTT endpoint. This handler is called when a DISCONNECT message is received by the remote MQTT client- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
subscribeHandler
MqttEndpoint subscribeHandler(Handler<MqttSubscribeMessage> handler)
Set a subscribe handler on the MQTT endpoint. This handler is called when a SUBSCRIBE message is received by the remote MQTT client- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
unsubscribeHandler
MqttEndpoint unsubscribeHandler(Handler<MqttUnsubscribeMessage> handler)
Set a unsubscribe handler on the MQTT endpoint. This handler is called when a UNSUBSCRIBE message is received by the remote MQTT client- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
publishHandler
MqttEndpoint publishHandler(Handler<MqttPublishMessage> handler)
Set the publish handler on the MQTT endpoint. This handler is called when a PUBLISH message is received by the remote MQTT client- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
publishAcknowledgeHandler
MqttEndpoint publishAcknowledgeHandler(Handler<Integer> handler)
Set the puback handler on the MQTT endpoint. This handler is called when a PUBACK message is received by the remote MQTT client- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
publishAcknowledgeMessageHandler
MqttEndpoint publishAcknowledgeMessageHandler(Handler<MqttPubAckMessage> handler)
Set the puback handler on the MQTT endpoint. This handler is called when a PUBACK message is received by the remote MQTT client- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
publishReceivedHandler
MqttEndpoint publishReceivedHandler(Handler<Integer> handler)
Set the pubrec handler on the MQTT endpoint. This handler is called when a PUBREC message is received by the remote MQTT client- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
publishReceivedMessageHandler
MqttEndpoint publishReceivedMessageHandler(Handler<MqttPubRecMessage> handler)
Set the pubrec handler on the MQTT endpoint. This handler is called when a PUBREC message is received by the remote MQTT client- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
publishReleaseHandler
MqttEndpoint publishReleaseHandler(Handler<Integer> handler)
Set the pubrel handler on the MQTT endpoint. This handler is called when a PUBREL message is received by the remote MQTT client- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
publishReleaseMessageHandler
MqttEndpoint publishReleaseMessageHandler(Handler<MqttPubRelMessage> handler)
Set the pubrel handler on the MQTT endpoint. This handler is called when a PUBREL message is received by the remote MQTT client- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
publishCompletionHandler
MqttEndpoint publishCompletionHandler(Handler<Integer> handler)
Set the pubcomp handler on the MQTT endpoint. This handler is called when a PUBCOMP message is received by the remote MQTT client- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
publishCompletionMessageHandler
MqttEndpoint publishCompletionMessageHandler(Handler<MqttPubCompMessage> handler)
Set the pubcomp handler on the MQTT endpoint. This handler is called when a PUBCOMP message is received by the remote MQTT client- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
authenticationExchangeHandler
MqttEndpoint authenticationExchangeHandler(Handler<MqttAuthenticationExchangeMessage> handler)
Set the auth handler on the MQTT endpoint. This handler is called when a AUTH message is received by the remote MQTT client- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
pingHandler
MqttEndpoint pingHandler(Handler<Void> handler)
Set the pingreq handler on the MQTT endpoint. This handler is called when a PINGREQ message is received by the remote MQTT client. In any case the endpoint sends the PINGRESP internally after executing this handler.- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
closeHandler
MqttEndpoint closeHandler(Handler<Void> handler)
Set a close handler. This will be called when the MQTT endpoint is closed- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
exceptionHandler
MqttEndpoint exceptionHandler(Handler<Throwable> handler)
Set an exception handler. This will be called when an error at protocol level happens- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
accept
MqttEndpoint accept()
Likeaccept(boolean)with no session is present.
-
accept
MqttEndpoint accept(boolean sessionPresent)
Sends the CONNACK message to the remote MQTT client with "connection accepted" return code. Seereject(MqttConnectReturnCode)for refusing connection- Parameters:
sessionPresent- if a previous session is present- Returns:
- a reference to this, so the API can be used fluently
-
accept
MqttEndpoint accept(boolean sessionPresent, MqttProperties properties)
Sends the CONNACK message to the remote MQTT client with "connection accepted" return code. Seereject(MqttConnectReturnCode)for refusing connection- Parameters:
sessionPresent- if a previous session is presentproperties- CONNACK message properties (MQTT5)- Returns:
- a reference to this, so the API can be used fluently
-
reject
MqttEndpoint reject(MqttConnectReturnCode returnCode)
Sends the CONNACK message to the remote MQTT client rejecting the connection request with specified return code. Seeaccept(boolean)for accepting connection- Parameters:
returnCode- the connect return code- Returns:
- a reference to this, so the API can be used fluently
-
reject
MqttEndpoint reject(MqttConnectReturnCode returnCode, MqttProperties properties)
Sends the CONNACK message to the remote MQTT client rejecting the connection request with specified return code. Seeaccept(boolean)for accepting connection- Parameters:
returnCode- the connect return codeproperties- CONNACK message properties- Returns:
- a reference to this, so the API can be used fluently
-
subscribeAcknowledge
MqttEndpoint subscribeAcknowledge(int subscribeMessageId, List<MqttQoS> grantedQoSLevels)
Sends the SUBACK message to the remote MQTT client- Parameters:
subscribeMessageId- identifier of the SUBSCRIBE message to acknowledgegrantedQoSLevels- granted QoS levels for the requested topics- Returns:
- a reference to this, so the API can be used fluently
-
subscribeAcknowledge
MqttEndpoint subscribeAcknowledge(int subscribeMessageId, List<MqttSubAckReasonCode> reasonCodes, MqttProperties properties)
Sends the SUBACK message to the remote MQTT client- Parameters:
subscribeMessageId- identifier of the SUBSCRIBE message to acknowledgereasonCodes- reason codesproperties- MQTT message properties- Returns:
- a reference to this, so the API can be used fluently
-
unsubscribeAcknowledge
MqttEndpoint unsubscribeAcknowledge(int unsubscribeMessageId)
Sends the UNSUBACK message to the remote MQTT client- Parameters:
unsubscribeMessageId- identifier of the UNSUBSCRIBE message to acknowledge- Returns:
- a reference to this, so the API can be used fluently
-
unsubscribeAcknowledge
MqttEndpoint unsubscribeAcknowledge(int unsubscribeMessageId, List<MqttUnsubAckReasonCode> reasonCodes, MqttProperties properties)
Sends the UNSUBACK message to the remote MQTT client- Parameters:
unsubscribeMessageId- identifier of the UNSUBSCRIBE message to acknowledgereasonCodes- reason codesproperties- MQTT message properties- Returns:
- a reference to this, so the API can be used fluently
-
publishAcknowledge
MqttEndpoint publishAcknowledge(int publishMessageId)
Sends the PUBACK message to the remote MQTT client- Parameters:
publishMessageId- identifier of the PUBLISH message to acknowledge- Returns:
- a reference to this, so the API can be used fluently
-
publishAcknowledge
MqttEndpoint publishAcknowledge(int publishMessageId, MqttPubAckReasonCode reasonCode, MqttProperties properties)
-
publishReceived
MqttEndpoint publishReceived(int publishMessageId)
Sends the PUBREC message to the remote MQTT client- Parameters:
publishMessageId- identifier of the PUBLISH message to acknowledge- Returns:
- a reference to this, so the API can be used fluently
-
publishReceived
MqttEndpoint publishReceived(int publishMessageId, MqttPubRecReasonCode reasonCode, MqttProperties properties)
Sends the PUBREC message to the remote MQTT client- Parameters:
publishMessageId- identifier of the PUBLISH message to acknowledgereasonCode- code of the outcomeproperties- MQTT properties- Returns:
- a reference to this, so the API can be used fluently
-
publishRelease
MqttEndpoint publishRelease(int publishMessageId)
Sends the PUBREL message to the remote MQTT client- Parameters:
publishMessageId- identifier of the PUBLISH message to acknowledge- Returns:
- a reference to this, so the API can be used fluently
-
publishRelease
MqttEndpoint publishRelease(int publishMessageId, MqttPubRelReasonCode reasonCode, MqttProperties properties)
Sends the PUBREL message to the remote MQTT client- Parameters:
publishMessageId- identifier of the PUBLISH message to acknowledgereasonCode- reason codeproperties- MQTT message properties- Returns:
- a reference to this, so the API can be used fluently
-
publishComplete
MqttEndpoint publishComplete(int publishMessageId)
Sends the PUBCOMP message to the remote MQTT client- Parameters:
publishMessageId- identifier of the PUBLISH message to acknowledge- Returns:
- a reference to this, so the API can be used fluently
-
publishComplete
MqttEndpoint publishComplete(int publishMessageId, MqttPubCompReasonCode reasonCode, MqttProperties properties)
Sends the PUBCOMP message to the remote MQTT client- Parameters:
publishMessageId- identifier of the PUBLISH message to acknowledgereasonCode- reason codeproperties- MQTT message properties- Returns:
- a reference to this, so the API can be used fluently
-
publish
Future<Integer> publish(String topic, Buffer payload, MqttQoS qosLevel, boolean isDup, boolean isRetain)
Sends the PUBLISH message to the remote MQTT client- Parameters:
topic- topic on which the message is publishedpayload- message payloadqosLevel- quality of service levelisDup- if the message is a duplicateisRetain- if the message needs to be retained- Returns:
- a
Futurecompleted after PUBLISH packet sent with a packetId
-
publish
Future<Integer> publish(String topic, Buffer payload, MqttQoS qosLevel, boolean isDup, boolean isRetain, int messageId)
Sends the PUBLISH message to the remote MQTT server explicitly specifying the messageId- Parameters:
topic- topic on which the message is publishedpayload- message payloadqosLevel- QoS levelisDup- if the message is a duplicateisRetain- if the message needs to be retainedmessageId- message ID- Returns:
- a future notified after PUBLISH packet sent with a packetId
-
publish
Future<Integer> publish(String topic, Buffer payload, MqttQoS qosLevel, boolean isDup, boolean isRetain, int messageId, MqttProperties properties)
Sends the PUBLISH message to the remote MQTT server explicitly specifying the messageId- Parameters:
topic- topic on which the message is publishedpayload- message payloadqosLevel- QoS levelisDup- if the message is a duplicateisRetain- if the message needs to be retainedmessageId- message IDproperties- PUBLISH message properties- Returns:
- a future notified after PUBLISH packet sent with a packetId
-
authenticationExchange
MqttEndpoint authenticationExchange(MqttAuthenticationExchangeMessage message)
Sends the AUTH message to the remote MQTT client- Parameters:
message-- Returns:
- a reference to this, so the API can be used fluently
-
pong
MqttEndpoint pong()
Sends the PINGRESP message to the remote MQTT client- Returns:
- a reference to this, so the API can be used fluently
-
disconnect
MqttEndpoint disconnect(MqttDisconnectReasonCode code, MqttProperties properties)
Sends the DISCONNECT message to the remote MQTT client- Parameters:
code- reason codeproperties- MQTT message properties- Returns:
- a reference to this, so the API can be used fluently
-
-