Skip to main content

Class: MqttClient

MQTT Client implementation for pub/sub communication.

Implements

Table of contents

Constructors

Methods

Constructors

constructor

new MqttClient(endpoints, keepAliveTimeoutSeconds?)

Create a new instace of MqttClient.

Parameters

NameTypeDefault valueDescription
endpointsstring | string[]undefinedThe endpoint or endpoints list to connect to.
keepAliveTimeoutSecondsnumber30Timeout to reconnect if no messages received.

Methods

milestonesLatest

milestonesLatest(callback): string

Subscribe to the latest milestone updates.

Parameters

NameTypeDescription
callback(topic: string, data: IMqttMilestoneResponse) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.milestonesLatest


milestonesConfirmed

milestonesConfirmed(callback): string

Subscribe to the latest confirmed milestone updates.

Parameters

NameTypeDescription
callback(topic: string, data: IMqttMilestoneResponse) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.milestonesConfirmed


blocksRaw

blocksRaw(callback): string

Subscribe to get all blocks in binary form.

Parameters

NameTypeDescription
callback(topic: string, data: Uint8Array) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.blocksRaw


blocks

blocks(callback): string

Subscribe to get all blocks in object form.

Parameters

NameTypeDescription
callback(topic: string, data: IBlock) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.blocks


blocksReferenced

blocksReferenced(callback): string

Subscribe to get the metadata for all the blocks.

Parameters

NameTypeDescription
callback(topic: string, data: IBlockMetadata) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.blocksReferenced


blocksTransactionRaw

blocksTransactionRaw(callback): string

Subscribe to all transaction blocks in their raw form.

Parameters

NameTypeDescription
callback(topic: string, data: Uint8Array) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.blocksTransactionRaw


blocksTransaction

blocksTransaction(callback): string

Subscribe to all transaction blocks.

Parameters

NameTypeDescription
callback(topic: string, data: IBlock) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.blocksTransaction


blocksTransactionTaggedDataRaw

blocksTransactionTaggedDataRaw(tag, callback): string

Subscribe to transaction blocks with tagged data in their raw form.

Parameters

NameTypeDescription
tagundefined | string | Uint8ArrayThe tag to monitor as bytes or in hex, undefined for all blocks.
callback(topic: string, data: Uint8Array) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.blocksTransactionTaggedDataRaw


blocksTransactionTaggedData

blocksTransactionTaggedData(tag, callback): string

Subscribe to all transaction blocks with tagged data.

Parameters

NameTypeDescription
tagundefined | string | Uint8ArrayThe tag to monitor as bytes or in hex, undefined for all blocks.
callback(topic: string, data: IBlock) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.blocksTransactionTaggedData


milestoneRaw

milestoneRaw(callback): string

Subscribe to all milestone payloads in their raw form.

Parameters

NameTypeDescription
callback(topic: string, data: Uint8Array) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.milestoneRaw


milestone

milestone(callback): string

Subscribe to all milestone payloads.

Parameters

NameTypeDescription
callback(topic: string, data: IMilestonePayload) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.milestone


blocksTaggedRaw

blocksTaggedRaw(tag, callback): string

Subscribe to get all blocks for the specified tag in binary form.

Parameters

NameTypeDescription
tagundefined | string | Uint8ArrayThe tag to monitor as bytes or in hex, undefined for all blocks.
callback(topic: string, data: Uint8Array) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.blocksTaggedRaw


blocksTagged

blocksTagged(tag, callback): string

Subscribe to get all blocks for the specified tag in object form.

Parameters

NameTypeDescription
tagundefined | string | Uint8ArrayThe tag to monitor as bytes or in hex, undefined for all blocks.
callback(topic: string, data: IBlock) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.blocksTagged


blocksMetadata

blocksMetadata(blockId, callback): string

Subscribe to metadata updates for a specific block.

Parameters

NameTypeDescription
blockIdstringThe block to monitor.
callback(topic: string, data: IBlockMetadata) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.blocksMetadata


transactionIncludedBlockRaw

transactionIncludedBlockRaw(transactionId, callback): string

Subscribe to block updates for a specific transactionId.

Parameters

NameTypeDescription
transactionIdstringThe block to monitor.
callback(topic: string, data: Uint8Array) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.transactionIncludedBlockRaw


transactionIncludedBlock

transactionIncludedBlock(transactionId, callback): string

Subscribe to block updates for a specific transactionId.

Parameters

NameTypeDescription
transactionIdstringThe block to monitor.
callback(topic: string, data: IBlock) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.transactionIncludedBlock


output

output(outputId, callback): string

Subscribe to updates for a specific output.

Parameters

NameTypeDescription
outputIdstringThe output to monitor.
callback(topic: string, data: IOutputResponse) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.output


nft

nft(nftId, callback): string

Subscribe to updates for an nft output.

Parameters

NameTypeDescription
nftIdstringThe Nft output to monitor.
callback(topic: string, data: IOutputResponse) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.nft


alias

alias(aliasId, callback): string

Subscribe to updates for an alias output.

Parameters

NameTypeDescription
aliasIdstringThe alias output to monitor.
callback(topic: string, data: IOutputResponse) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.alias


foundry

foundry(foundryId, callback): string

Subscribe to updates for a foundry output.

Parameters

NameTypeDescription
foundryIdstringThe foundry output to monitor.
callback(topic: string, data: IOutputResponse) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.foundry


outputByConditionAndAddress

outputByConditionAndAddress(condition, addressBech32, callback): string

Subscribe to the output with specific unlock condition and address.

Parameters

NameTypeDescription
conditionstringThe condition to monitor.
addressBech32stringThe address to monitor.
callback(topic: string, data: IOutputResponse) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.outputByConditionAndAddress


outputSpentByConditionAndAddress

outputSpentByConditionAndAddress(condition, addressBech32, callback): string

Subscribe to the spent outputs with specific unlock condition and address.

Parameters

NameTypeDescription
conditionstringThe condition to monitor.
addressBech32stringThe address to monitor.
callback(topic: string, data: IOutputResponse) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.outputSpentByConditionAndAddress


receipts

receipts(callback): string

Subscribe to the receive all receipts.

Parameters

NameTypeDescription
callback(topic: string, data: IReceiptsResponse) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.receipts


subscribeRaw

subscribeRaw(customTopic, callback): string

Subscribe to another type of message as raw data.

Parameters

NameTypeDescription
customTopicstringThe topic to subscribe to.
callback(topic: string, data: Uint8Array) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.subscribeRaw


subscribeJson

subscribeJson<T>(customTopic, callback): string

Subscribe to another type of message as json.

Type parameters

Name
T

Parameters

NameTypeDescription
customTopicstringThe topic to subscribe to.
callback(topic: string, data: T) => voidThe callback which is called when new data arrives.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.subscribeJson


unsubscribe

unsubscribe(subscriptionId): void

Remove a subscription.

Parameters

NameTypeDescription
subscriptionIdstringThe subscription to remove.

Returns

void

Implementation of

IMqttClient.unsubscribe


statusChanged

statusChanged(callback): string

Subscribe to changes in the client state.

Parameters

NameTypeDescription
callback(data: IMqttStatus) => voidCallback called when the state has changed.

Returns

string

A subscription Id which can be used to unsubscribe.

Implementation of

IMqttClient.statusChanged