Messages
Sending text message to device address
Params:
device_address - {string} - Device address
text - {string} - Message text
core.sendTextMessageToDevice('0PZT5VOY5AINZKW2SJ3Z7O4IDQNKPV364', 'Hello!')
Sending tech message to device address
Params:
device_address - {string} - Device address
object - {object} - Message object
core.sendTechMessageToDevice('0PZT5VOY5AINZKW2SJ3Z7O4IDQNKPV364', {test: 'Hello!'})
How to use?
const eventBus = require('byteballcore/event_bus');
eventBus.on('text', (from_address, text) => {
let objMessage;
try {
objMessage = JSON.parse(text);
if (objMessage.id || objMessage.version) objMessage = null;
} catch (e) {
}
if (objMessage) {
// this is tech
} else {
// this is text
}
});
In the near future, "tech" will have a separate handler
Last updated