Events
text
const eventBus = require('byteballcore/event_bus');
eventBus.on('text', (from_address, text) => {
console.log('from:', from_address, ' || text:', text);
});
socket.send(JSON.stringify({
id: i++,
name: 'subscribe',
args: ['text']
}));
socket.onmessage = function (event) {
let data = JSON.parse(event.data);
if (data.id === -2 && data.name === 'text') {
let result = data.result;
console.log('from:', result.from_address, ' || text:', result.text);
return;
}
}
paired
const eventBus = require('byteballcore/event_bus');
eventBus.on('paired', (from_address, pairing_secret) => {
console.log('address:', from_address, ' || pairing_secret:', text);
});
socket.send(JSON.stringify({
id: i++,
name: 'subscribe',
args: ['paired']
}));
socket.onmessage = function (event) {
let data = JSON.parse(event.data);
if (data.id === -2 && data.name === 'paired') {
let result = data.result;
console.log('address:', result.from_address, ' || pairing_secret:', result.text);
return;
}
}
new_my_transactions
const eventBus = require('byteballcore/event_bus');
eventBus.on('new_my_transactions', (arrUnits) => {
console.log('new_my_transactions:', arrUnits);
});
socket.send(JSON.stringify({
id: i++,
name: 'subscribe',
args: ['new_my_transactions']
}));
socket.onmessage = function (event) {
let data = JSON.parse(event.data);
if (data.id === -2 && data.name === 'new_my_transactions') {
let result = data.result;
console.log('new_my_transactions:', result.arrUnits);
return;
}
}
new_joint
const eventBus = require('byteballcore/event_bus');
eventBus.on('new_joint', (objJoint) => {
console.log('new_joint:', objJoint);
});
socket.send(JSON.stringify({
id: i++,
name: 'subscribe',
args: ['new_joint']
}));
socket.onmessage = function (event) {
let data = JSON.parse(event.data);
if (data.id === -2 && data.name === 'new_joint') {
let result = data.result;
console.log('new_joint:', result.objJoint);
return;
}
}
my_transactions_became_stable
const eventBus = require('byteballcore/event_bus');
eventBus.on('my_transactions_became_stable', (arrUnits) => {
console.log('my_transactions_became_stable:', arrUnits);
});
socket.send(JSON.stringify({
id: i++,
name: 'subscribe',
args: ['my_transactions_became_stable']
}));
socket.onmessage = function (event) {
let data = JSON.parse(event.data);
if (data.id === -2 && data.name === 'my_transactions_became_stable') {
let result = data.result;
console.log('my_transactions_became_stable:', result.arrUnits);
return;
}
}
Last updated