1.2.0 • Published 6 months ago

@vbet/webjs-sdk v1.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
6 months ago

Installation

Include the package locally in your repository.

npm install @vbet/webjs-sdk

Examples

Demo

Usage

Init the librarby

import {init} from "@vbet/webjs-sdk";
const api = await init()

Acquire permisson to device

Note: Due to security policy of WebHID, you have to grant permisson before the device can be used

import {webhidConsent} from "@vbet/webjs-sdk";
const HIDConsent = async () => {
   await webhidConsent();
};

Getting a list of available devices by subscribing to events

import {init} from "@vbet/webjs-sdk";
const api = await init()
api.deviceList.subscribe((devices) => {
    console.log("changed", devices);
});

Subscribing to events showing individually added or removed devices

import {init} from "@vbet/webjs-sdk";
const api = await init()
api.deviceAdded.subscribe((device) => {
   console.log("added", device);
});

api.deviceRemoved.subscribe((device) => {
   console.log("removed", device);
});

Subscribing to connection event (Dongle only)

Subscribe to this event to receive wireless headset connection

import {DeviceType, IDongle} from "@vbet/webjs-sdk";
api.deviceAdded.subscribe((device) => {
    console.log("added", device);
    if (device.type === DeviceType.DONGLE) {
        (device as IDongle).connection.subscribe((connection) => {
            console.log(connection);
        });
    }
});

Subscribing to device signal

Subscribe to this event to monitor user interaction with device

import {init, DeviceSignalType} from "@vbet/webjs-sdk";
api.deviceAdded.subscribe((device) => {
    console.log("added", device);
    device.deviceSignal.subscribe((signal) => {
       console.log("received device signal", signal);
       if(signal === DeviceSignalType.ACCEPT_CALL){
          //softphone accpet incomming call
       }
    });
});

Synchronize device state

It's important to synchronize the device state to the state of the softphone, so that the device can behave as expected on each phone call cycle

import {init, DeviceSignalType} from "@vbet/webjs-sdk";
api.deviceAdded.subscribe((device) => {
    console.log("added", device);
    //.....
    //received an incomming call
    try{
       await device.ring()
    }catech(error){
    }
    //call accepted
    try{
       await device.offHook()
    }catech(error){
    }
    //call ended
    try{
       await device.onHook()
    }catech(error){
    }
});
1.2.0

6 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago