nerio-io-client
v1.1.4
Published
Web socket-io client
Downloads
6
Readme
Io-client
A websocket client base on socket.io-client, working with io-server
install
npm i nerio-io-client -S
CDN
<script src="https://cdn.jsdelivr.net/npm/nerio-io-client/dist/messenger.js"></script>
Usage
initialize instance
import Client from 'nerio-io-client'
const client = new Client(url, [socketIoOptions, autoCreate])
// const client = new Messenger(url, [socketIoOptions, autoCreate]) // using cdn
subscribe channel
client.subscribe('message')
client.subscribe(['message', 'client-1'])
select channel and broadcast
let channel = client.select('message')
// let channel = client.select(['message', 'client-1'])
channel.broadcast('event-1', {
payload: 'foo'
})
channel.broadcast({ // default event is: message
payload: 'foo'
})