Javascript library to communicate with Centrifugo HTTP API.
$ npm i cent.jsFirst see available API methods in documentation.
This library contains CentClient class to send messages to Centrifugo from your node-powered backend:
const{CentClient}=require('cent.js');// Initialize client instance.constclient=newCentClient({url: 'http://localhost:8000/api',apiKey: 'XXX'});// Publish data into channelconstpublishRes=awaitclient.publish({channel: 'public:chat',data: {input: "test"}}).catch(err=>handleError());// We throw error in case of unsuccessful// response from Centrifugo or some other // internal errors.// Other available methodsawaitclient.unsubscribe({user: 'user_id',channel: 'channel'});awaitclient.disconnect({user: 'user_id'})awaitclient.getHistory({channel: 'channel'})awaitclient.getPresence({channel: 'channel'})awaitclient.getChannels()awaitclient.getInfo()awaitclient.removeHistory({channel: 'channel'})- Author - Alexey Filippov
- Twitter - @SocketSomeone