aws-mqtt-client-utils
Quick start
Install the package
$ npm i @soluzioni-futura/aws-mqtt-client-utils
Usage
import getAwsMqttClient from "@soluzioni-futura/aws-mqtt-client-utils"
const mqttClient = getAwsMqttClient({
awsAccessKeyId: <your-access-key>,
awsSecretAccessKey: <your-secret-key>,
awsSessionToken: <your-session-token>,
iotEndpoint: <your-iot-endpoint>,
region: <your-region>
})
mqttClient.onMessageArrived = (message) => {
console.log("New message arrived on", message.topic)
console.log(JSON.parse(message.payloadString))
}
mqttClient.connect({
onSuccess: () => {
console.log("Connected!")
mqttClient.subscribe("$aws/things/+/shadow/update/accepted")
}
})