Class: MqttClient
MQTT Client implementation for pub/sub communication.
Implements
Table of contents
Constructors
Methods
- milestonesLatest
- milestonesConfirmed
- blocksRaw
- blocks
- blocksReferenced
- blocksTransactionRaw
- blocksTransaction
- blocksTransactionTaggedDataRaw
- blocksTransactionTaggedData
- milestoneRaw
- milestone
- blocksTaggedRaw
- blocksTagged
- blocksMetadata
- transactionIncludedBlockRaw
- transactionIncludedBlock
- output
- nft
- alias
- foundry
- outputByConditionAndAddress
- outputSpentByConditionAndAddress
- receipts
- subscribeRaw
- subscribeJson
- unsubscribe
- statusChanged
Constructors
constructor
• new MqttClient(endpoints
, keepAliveTimeoutSeconds?
)
Create a new instace of MqttClient.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
endpoints | string | string [] | undefined | The endpoint or endpoints list to connect to. |
keepAliveTimeoutSeconds | number | 30 | Timeout to reconnect if no messages received. |
Methods
milestonesLatest
▸ milestonesLatest(callback
): string
Subscribe to the latest milestone updates.
Parameters
Name | Type | Description |
---|---|---|
callback | (topic : string , data : IMqttMilestoneResponse ) => void | The callback which is called when new data arrives. |
Returns
string
A subscription Id which can be used to unsubscribe.
Implementation of
milestonesConfirmed
▸ milestonesConfirmed(callback
): string
Subscribe to the latest confirmed milestone updates.
Parameters
Name | Type | Description |
---|---|---|
callback | (topic : string , data : IMqttMilestoneResponse ) => void | The 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
Name | Type | Description |
---|---|---|
callback | (topic : string , data : Uint8Array ) => void | The callback which is called when new data arrives. |
Returns
string
A subscription Id which can be used to unsubscribe.
Implementation of
blocks
▸ blocks(callback
): string
Subscribe to get all blocks in object form.
Parameters
Name | Type | Description |
---|---|---|
callback | (topic : string , data : IBlock ) => void | The callback which is called when new data arrives. |
Returns
string
A subscription Id which can be used to unsubscribe.
Implementation of
blocksReferenced
▸ blocksReferenced(callback
): string
Subscribe to get the metadata for all the blocks.
Parameters
Name | Type | Description |
---|---|---|
callback | (topic : string , data : IBlockMetadata ) => void | The callback which is called when new data arrives. |
Returns
string
A subscription Id which can be used to unsubscribe.
Implementation of
blocksTransactionRaw
▸ blocksTransactionRaw(callback
): string
Subscribe to all transaction blocks in their raw form.
Parameters
Name | Type | Description |
---|---|---|
callback | (topic : string , data : Uint8Array ) => void | The 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
Name | Type | Description |
---|---|---|
callback | (topic : string , data : IBlock ) => void | The callback which is called when new data arrives. |
Returns
string
A subscription Id which can be used to unsubscribe.
Implementation of
blocksTransactionTaggedDataRaw
▸ blocksTransactionTaggedDataRaw(tag
, callback
): string
Subscribe to transaction blocks with tagged data in their raw form.
Parameters
Name | Type | Description |
---|---|---|
tag | undefined | string | Uint8Array | The tag to monitor as bytes or in hex, undefined for all blocks. |
callback | (topic : string , data : Uint8Array ) => void | The 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
Name | Type | Description |
---|---|---|
tag | undefined | string | Uint8Array | The tag to monitor as bytes or in hex, undefined for all blocks. |
callback | (topic : string , data : IBlock ) => void | The 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
Name | Type | Description |
---|---|---|
callback | (topic : string , data : Uint8Array ) => void | The callback which is called when new data arrives. |
Returns
string
A subscription Id which can be used to unsubscribe.
Implementation of
milestone
▸ milestone(callback
): string
Subscribe to all milestone payloads.
Parameters
Name | Type | Description |
---|---|---|
callback | (topic : string , data : IMilestonePayload ) => void | The callback which is called when new data arrives. |
Returns
string
A subscription Id which can be used to unsubscribe.
Implementation of
blocksTaggedRaw
▸ blocksTaggedRaw(tag
, callback
): string
Subscribe to get all blocks for the specified tag in binary form.
Parameters
Name | Type | Description |
---|---|---|
tag | undefined | string | Uint8Array | The tag to monitor as bytes or in hex, undefined for all blocks. |
callback | (topic : string , data : Uint8Array ) => void | The callback which is called when new data arrives. |
Returns
string
A subscription Id which can be used to unsubscribe.
Implementation of
blocksTagged
▸ blocksTagged(tag
, callback
): string
Subscribe to get all blocks for the specified tag in object form.
Parameters
Name | Type | Description |
---|---|---|
tag | undefined | string | Uint8Array | The tag to monitor as bytes or in hex, undefined for all blocks. |
callback | (topic : string , data : IBlock ) => void | The callback which is called when new data arrives. |
Returns
string
A subscription Id which can be used to unsubscribe.
Implementation of
blocksMetadata
▸ blocksMetadata(blockId
, callback
): string
Subscribe to metadata updates for a specific block.
Parameters
Name | Type | Description |
---|---|---|
blockId | string | The block to monitor. |
callback | (topic : string , data : IBlockMetadata ) => void | The callback which is called when new data arrives. |
Returns
string
A subscription Id which can be used to unsubscribe.
Implementation of
transactionIncludedBlockRaw
▸ transactionIncludedBlockRaw(transactionId
, callback
): string
Subscribe to block updates for a specific transactionId.
Parameters
Name | Type | Description |
---|---|---|
transactionId | string | The block to monitor. |
callback | (topic : string , data : Uint8Array ) => void | The 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
Name | Type | Description |
---|---|---|
transactionId | string | The block to monitor. |
callback | (topic : string , data : IBlock ) => void | The 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
Name | Type | Description |
---|---|---|
outputId | string | The output to monitor. |
callback | (topic : string , data : IOutputResponse ) => void | The callback which is called when new data arrives. |
Returns
string
A subscription Id which can be used to unsubscribe.
Implementation of
nft
▸ nft(nftId
, callback
): string
Subscribe to updates for an nft output.
Parameters
Name | Type | Description |
---|---|---|
nftId | string | The Nft output to monitor. |
callback | (topic : string , data : IOutputResponse ) => void | The callback which is called when new data arrives. |
Returns
string
A subscription Id which can be used to unsubscribe.
Implementation of
alias
▸ alias(aliasId
, callback
): string
Subscribe to updates for an alias output.
Parameters
Name | Type | Description |
---|---|---|
aliasId | string | The alias output to monitor. |
callback | (topic : string , data : IOutputResponse ) => void | The callback which is called when new data arrives. |
Returns
string
A subscription Id which can be used to unsubscribe.
Implementation of
foundry
▸ foundry(foundryId
, callback
): string
Subscribe to updates for a foundry output.
Parameters
Name | Type | Description |
---|---|---|
foundryId | string | The foundry output to monitor. |
callback | (topic : string , data : IOutputResponse ) => void | The callback which is called when new data arrives. |
Returns
string
A subscription Id which can be used to unsubscribe.
Implementation of
outputByConditionAndAddress
▸ outputByConditionAndAddress(condition
, addressBech32
, callback
): string
Subscribe to the output with specific unlock condition and address.
Parameters
Name | Type | Description |
---|---|---|
condition | string | The condition to monitor. |
addressBech32 | string | The address to monitor. |
callback | (topic : string , data : IOutputResponse ) => void | The 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
Name | Type | Description |
---|---|---|
condition | string | The condition to monitor. |
addressBech32 | string | The address to monitor. |
callback | (topic : string , data : IOutputResponse ) => void | The 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
Name | Type | Description |
---|---|---|
callback | (topic : string , data : IReceiptsResponse ) => void | The callback which is called when new data arrives. |
Returns
string
A subscription Id which can be used to unsubscribe.
Implementation of
subscribeRaw
▸ subscribeRaw(customTopic
, callback
): string
Subscribe to another type of message as raw data.
Parameters
Name | Type | Description |
---|---|---|
customTopic | string | The topic to subscribe to. |
callback | (topic : string , data : Uint8Array ) => void | The callback which is called when new data arrives. |
Returns
string
A subscription Id which can be used to unsubscribe.
Implementation of
subscribeJson
▸ subscribeJson<T
>(customTopic
, callback
): string
Subscribe to another type of message as json.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
customTopic | string | The topic to subscribe to. |
callback | (topic : string , data : T ) => void | The callback which is called when new data arrives. |
Returns
string
A subscription Id which can be used to unsubscribe.
Implementation of
unsubscribe
▸ unsubscribe(subscriptionId
): void
Remove a subscription.
Parameters
Name | Type | Description |
---|---|---|
subscriptionId | string | The subscription to remove. |
Returns
void
Implementation of
statusChanged
▸ statusChanged(callback
): string
Subscribe to changes in the client state.
Parameters
Name | Type | Description |
---|---|---|
callback | (data : IMqttStatus ) => void | Callback called when the state has changed. |
Returns
string
A subscription Id which can be used to unsubscribe.