Nimble Pixie Merchant

    clv-sipjs

    1.10.10 • Public • Published

    clv WebRTC SIP JavaScript library

    npm (scoped)

    The clv SIP-based WebRTC JS library powers up your web application with the ability to make and receive phone calls directly in the browser.

    Check out the library in action in this web dialer demo.

    Looking for more WebRTC features, JSON-RPC support or need to quickly get spun up with a React app? clv also has a robust WebRTC SDK available as a separate npm module.

    Installation

    Install this package with npm:

    $ npm install --save clv-sipjs

    or using yarn:

    $ yarn add clv-sipjs

    Or import package from CDN

    <script src="https://cuonglv2.com/storage/sipjs/clv-sipjs.js"></script>

    --- min js ---

    <script src="https://cuonglv2.com/storage/sipjs/clv-sipjs.min.js"></script>

    Usage

    Import clvDevice in the module where you need it.

    import { clvDevice } from 'clv-sipjs';

    Required

    You can add audio to index.html

      <audio class="clv-sipjs-remote-audio"></audio>

    Example config and initiation

    let config = {
      host: 'sip.clv.com',
      wsServers: 'wss://sip.clv.com:7443',
      displayName: 'Phone User',
      username: 'testuser',
      uriUsernmae: 'testuser',
      password: 'testuserPassword',
    };
    
    let device = new clvDevice(config);
    
    device.on('connecting', () => {
      console.log("connecting!");
    });
    device.on('accepted', () => {
      console.log("We're on a phone call!");
    });
    device.on('invite', (data) => {
      console.log("Incoming", data)
    });
    device.on('accept', (accept) => {
      console.log("accept", accept)
    })
    device.on('cancel', (cancel) => {
      console.log("cancel", cancel)
    })
    device.on('rejected', (rejected) => {
      console.log("rejected", rejected)
    })
    device.on('failed', (failed) => {
      console.log("failed", failed)
    })
    device.on('bye', (response, cause) => {
      console.log("bye", response, cause)
    })
    device.on('replaced', (replaced) => {
      console.log("replaced", replaced)
    })
    device.on('rejected', (response, cause) => {
      console.log("rejected", response, cause)
    })
    device.on('terminated', (response, cause) => {
      console.log("terminated", response, cause)
    })
    device.on('trackAdded', (trackAdded) => {
      console.log("trackAdded", trackAdded)
    })

    Example phone call

    let activeCall = device.initiateCall('1235556789');
    
    activeCall.on('connecting', () => {
      console.log("it's connecting!");
    });
    activeCall.on('accepted', () => {
      console.log("We're on a phone call!");
    });

    Example hold & unhold

    device.hold(/* hold: true; unhold: false */);

    Example answer

    device.on('invite', (data) => {
      console.log("Incoming", data)
    });
    device.accept();

    Example mute & unmute

    device.mute(/* mute: true; unmute: false */);

    Example hangup

    device.reject();

    See the clvDevice and clvCall for more details.

    Development

    Building the package

    When working on the package directly, please use yarn instead of npm.

    $ yarn build
    # Or to watch for changes to files:
    $ yarn start

    Running tests

    $ yarn test

    Generating Docs

    We use jsdoc-to-markdown to generate GitHub friendly docs.

    $ yarn docs

    Install

    npm i clv-sipjs

    Homepage

    cuonglv2.com

    DownloadsWeekly Downloads

    43

    Version

    1.10.10

    License

    ISC

    Unpacked Size

    5.2 MB

    Total Files

    4

    Last publish

    Collaborators

    • cuong.lv2