npm.io
0.0.7 • Published 6 years ago

@sirusdev/p2pchat-browser-sdk

Licence
GPL-3.0
Version
0.0.7
Deps
9
Size
527 kB
Vulns
1
Weekly
0

P2PChat Browser SDK

libarry to develop peer-to-peer chat cliet on browser

Quick Start

you should have signalling service installed on your system before use this library, signalling service is necessary to create rooms and manage access to those rooms.

  1. install this library via NPM repositry

    npm install p2pchat-browser-sdk
  2. simple client usage

    import {} from 'p2pchat-browser-sdk'
    
    const client = createNewClient({
      signalingUrl: 'https://my-signalling-service.com',
      logLevel: 'info',
    });
    
    // get token from signaling service. then you can connect as user
    await client.login('token-from-signalling');
    await client.connect();
    
    // send message to a rooms
    await client.sendMessage('room-id', {
      type: MessageType.MESSAGE,
      content: 'hello!'
    });
    

Keywords