17 lines
419 B
JavaScript
17 lines
419 B
JavaScript
const mqtt = require('mqtt')
|
|
const client = mqtt.connect('mqtt://mqtt.srv.jnf.me', {
|
|
clientId: 'pictureframe_' + Math.random().toString(16).substr(2, 8),
|
|
username: 'pictureframe',
|
|
password: 'pictureframe'
|
|
})
|
|
|
|
client.on('connect', () => {
|
|
client.subscribe('pictureframe/#', (err) => {
|
|
if (err) console.log(err)
|
|
})
|
|
})
|
|
|
|
client.on('message', (topic, message) => {
|
|
console.log(topic + ' : ' + message.toString())
|
|
})
|