-
Install.
npm i relay-js -
Establish a connection. Use
Relayclass and a link from backend:const Relay = require('relay-js'); const relay = new Relay('http://example.com/?id=259360a3-0082-4503-94bf-9385a5df42');
-
Subscribe to channels. Ask backend about available channels and join them if you need to. Example:
relay.connect().then(() => { relay.subscribe(['notifications'], {token: 'secret'}, (channel, data) => { if(channel === 'notifications') { Notification.show(data.message); } }); });
-
Make a request to the server. With Relay you can respond to channels messages or make independent requests. Relay will transmit the server's response.
let data = await relay.request({action: "notification_read", id: 795});
-
Notifications
You must be signed in to change notification settings - Fork 0
POST messages through websockets
License
ivanrussu/relay-js
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
About
POST messages through websockets
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published