@parlour/parlour-client

0.1.1 • Public • Published

parlour-client

The parlour client

NPM JavaScript Style Guide

Support the project

Donate Donate

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

Package Sidebar

Install

npm i @parlour/parlour-client

Weekly Downloads

2

Version

0.1.1

License

MIT

Unpacked Size

55.1 kB

Total Files

21

Last publish

Collaborators

  • samick
  • anguslu
  • yx5919345
  • schnapp