@parlour/parlour-client
v0.1.1
Published
The parlour websocket client
Downloads
3
Readme
parlour-client
The parlour client
Support the project
Install
npm install --save parlour-client
Usage
import { SocketClient } from 'parlour-client';
const client = SocketClient.create({
url: 'ws://localhost:8000/socket/websocket',
userId: 'samick17',
userName: 'samick',
token: '',// optional for signin as user
rooms: ['room:lobby'],
reconnectPeriod: 0,
});
const unbindClientEvents = client.on({
connect: () => {
console.log('[Client] Connect');
},
'reply': (topic, event, payload) => {
console.log('[Client] Reply', topic, event, payload);
},
'presence_diff': (topic, event, payload) => {
console.log('[Client] PresenceDiff', topic, event, payload);
},
'presence_state': (topic, event, payload) => {
console.log('[Client] PresenceState', topic, event, payload);
},
message: (topic, event, payload) => {
console.log('[Client] Message', topic, event, payload);
},
error: (event) => {
console.log('[Client] Error', event);
},
close: (event) => {
console.log('[Client] Close', event);
console.log('Reason: ', event.reason);
},
ping: (ping) => {
console.log('[Client] Ping');
console.log('Ping: ', ping);
},
});
client.connect();
License
MIT © samick17