Class: MqttEndpoint

vertx-mqtt-server-js/mqtt_endpoint~ MqttEndpoint

new MqttEndpoint()

Represents an MQTT endpoint for point-to-point communication with the remote MQTT client
Source:

Methods

accept(sessionPresent) → {MqttEndpoint}

Sends the CONNACK message to the remote MQTT client with "connection accepted" return code. See MqttEndpoint#reject for refusing connection
Parameters:
Name Type Description
sessionPresent boolean if a previous session is present
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

auth() → {MqttAuth}

Source:
Returns:
the Authentication information as provided by the remote MQTT client
Type
MqttAuth

autoKeepAlive(isAutoKeepAlive) → {MqttEndpoint}

Enable/disable auto keep alive (sending ping response)
Parameters:
Name Type Description
isAutoKeepAlive boolean auto keep alive
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

clientIdentifier() → {string}

Source:
Returns:
the client identifier as provided by the remote MQTT client
Type
string

close()

Close the endpoint, so the connection with remote MQTT client
Source:

closeHandler(handler) → {MqttEndpoint}

Set a close handler. This will be called when the MQTT endpoint is closed
Parameters:
Name Type Description
handler function the handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

disconnectHandler(handler) → {MqttEndpoint}

Set a disconnect handler on the MQTT endpoint. This handler is called when a DISCONNECT message is received by the remote MQTT client
Parameters:
Name Type Description
handler function the handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

exceptionHandler(handler) → {MqttEndpoint}

Set an exception handler. This will be called when an error at protocol level happens
Parameters:
Name Type Description
handler function the handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

isAutoKeepAlive() → {boolean}

Source:
Returns:
the auto keep alive status (sending ping response)
Type
boolean

isCleanSession() → {boolean}

Source:
Returns:
true when clean session is requested by the remote MQTT client
Type
boolean

isConnected() → {boolean}

Source:
Returns:
if the connection between remote client and local endpoint is established/open
Type
boolean

isPublishAutoAck() → {boolean}

Source:
Returns:
auto acknowledge status for publishing (in/out)
Type
boolean

isSubscriptionAutoAck() → {boolean}

Source:
Returns:
true when auto acknowledge status for subscription/unsubscription requests
Type
boolean

keepAliveTimeSeconds() → {number}

Source:
Returns:
the keep alive timeout (in seconds) specified by the remote MQTT client
Type
number

lastMessageId() → {number}

Source:
Returns:
the message identifier used for last published message
Type
number

pingHandler(handler) → {MqttEndpoint}

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:
Name Type Description
handler function the handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

pong() → {MqttEndpoint}

Sends the PINGRESP message to the remote MQTT client
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

protocolName() → {string}

Source:
Returns:
the protocol name provided by the remote MQTT client
Type
string

protocolVersion() → {number}

Source:
Returns:
the protocol version required by the remote MQTT client
Type
number

publish(topic, payload, qosLevel, isDup, isRetain) → {MqttEndpoint}

Sends the PUBLISH message to the remote MQTT client
Parameters:
Name Type Description
topic string topic on which the message is published
payload Buffer message payload
qosLevel Object quality of service level
isDup boolean if the message is a duplicate
isRetain boolean if the message needs to be retained
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

publishAcknowledge(publishMessageId) → {MqttEndpoint}

Sends the PUBACK message to the remote MQTT client
Parameters:
Name Type Description
publishMessageId number identifier of the PUBLISH message to acknowledge
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

publishAcknowledgeHandler(handler) → {MqttEndpoint}

Set the puback handler on the MQTT endpoint. This handler is called when a PUBACK message is received by the remote MQTT client
Parameters:
Name Type Description
handler function the handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

publishAutoAck(isPublishAutoAck) → {MqttEndpoint}

Enable/disable publishing (in/out) auto acknowledge
Parameters:
Name Type Description
isPublishAutoAck boolean auto acknowledge status
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

publishComplete(publishMessageId) → {MqttEndpoint}

Sends the PUBCOMP message to the remote MQTT client
Parameters:
Name Type Description
publishMessageId number identifier of the PUBLISH message to acknowledge
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

publishCompleteHandler(handler) → {MqttEndpoint}

Set the pubcomp handler on the MQTT endpoint. This handler is called when a PUBCOMP message is received by the remote MQTT client
Parameters:
Name Type Description
handler function the handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

publishHandler(handler) → {MqttEndpoint}

Set the publish handler on the MQTT endpoint. This handler is called when a PUBLISH message is received by the remote MQTT client
Parameters:
Name Type Description
handler function the handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

publishReceived(publishMessageId) → {MqttEndpoint}

Sends the PUBREC message to the remote MQTT client
Parameters:
Name Type Description
publishMessageId number identifier of the PUBLISH message to acknowledge
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

publishReceivedHandler(handler) → {MqttEndpoint}

Set the pubrec handler on the MQTT endpoint. This handler is called when a PUBREC message is received by the remote MQTT client
Parameters:
Name Type Description
handler function the handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

publishRelease(publishMessageId) → {MqttEndpoint}

Sends the PUBREL message to the remote MQTT client
Parameters:
Name Type Description
publishMessageId number identifier of the PUBLISH message to acknowledge
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

publishReleaseHandler(handler) → {MqttEndpoint}

Set the pubrel handler on the MQTT endpoint. This handler is called when a PUBREL message is received by the remote MQTT client
Parameters:
Name Type Description
handler function the handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

reject(returnCode) → {MqttEndpoint}

Sends the CONNACK message to the remote MQTT client rejecting the connection request with specified return code. See MqttEndpoint#accept for accepting connection
Parameters:
Name Type Description
returnCode Object the connect return code
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

setClientIdentifier(clientIdentifier) → {MqttEndpoint}

Set client identifier if not provided by the remote MQTT client (zero-bytes)
Parameters:
Name Type Description
clientIdentifier string the client identifier
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

subscribeAcknowledge(subscribeMessageId, grantedQoSLevels) → {MqttEndpoint}

Sends the SUBACK message to the remote MQTT client
Parameters:
Name Type Description
subscribeMessageId number identifier of the SUBSCRIBE message to acknowledge
grantedQoSLevels Array.<Object> granted QoS levels for the requested topics
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

subscribeHandler(handler) → {MqttEndpoint}

Set a subscribe handler on the MQTT endpoint. This handler is called when a SUBSCRIBE message is received by the remote MQTT client
Parameters:
Name Type Description
handler function the handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

subscriptionAutoAck(isSubscriptionAutoAck)

Enable/disable subscription/unsubscription requests auto acknowledge
Parameters:
Name Type Description
isSubscriptionAutoAck boolean auto acknowledge status
Source:

unsubscribeAcknowledge(unsubscribeMessageId) → {MqttEndpoint}

Sends the UNSUBACK message to the remote MQTT client
Parameters:
Name Type Description
unsubscribeMessageId number identifier of the UNSUBSCRIBE message to acknowledge
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

unsubscribeHandler(handler) → {MqttEndpoint}

Set a unsubscribe handler on the MQTT endpoint. This handler is called when a UNSUBSCRIBE message is received by the remote MQTT client
Parameters:
Name Type Description
handler function the handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
MqttEndpoint

will() → {MqttWill}

Source:
Returns:
the Will information as provided by the remote MQTT client
Type
MqttWill