Events
Real time transaction notification
Step 1: User Authentication
Step 2: Event Listening
const { io } = require('socket.io-client')
const relysiaEndpoint = 'https://api.enterprise.relysia.com/';
(async () => {
// Connect websocket for this account
const socket = io(relysiaEndpoint, {
auth: {
serviceid: serviceid
authToken: token
}
});
socket.on('error', function(error) {
console.log("Connection Error: " + error.toString());
});
// Listen for message and log them as notification arrive
socket.on('notification', function (message) {
console.log('Notification received:', message);
})
// Listen for balance and log them on balance arrive
socket.on('balance', function (balance) {
console.log('Balance update received:', balance);
})
// Listen for history and log them on history arrive
socket.on('history', function (history) {
console.log('History update received:', history);
})
socket.on('connect', function(connection) {
console.log('WebSocket Client Connected');
socket.on('close', function() {
console.log('Connection Closed');
});
});
})()Last updated