Usage example
Quick view of how it goes...
const wampy = new Wampy('ws://server/ws/', { realm: 'AppRealm' });
try {
await wampy.connect();
} catch (e) {
console.log('connection failed', e);
}
try {
await wampy.subscribe('system.monitor.update', function (eventData) { console.log('Received system.monitor.update event!', eventData); });
} catch (e) {
console.log('subscription failed', e);
}
try {
let res = await wampy.call('get.server.time');
console.log('RPC successfully called');
console.log('Server time is ' + res.argsDict.serverTime);
} catch (e) {
console.log('RPC call failed', e);
}
// Somewhere else for example
await wampy.publish('system.monitor.update');
// or just ignore promise (if you don't need it)
wampy.publish('client.message', 'Hi guys!');
Last updated