Controls VBet devices from WebHID
npm install @vbet/webhid-sdkInclude the package locally in your repository.
npm install @vbet/webhid-sdk
``js`
import { webhidConsent, IDevice, DeviceSignalType, findDevice } from '@vbet/webhid-sdk';
- Triggers WebHID consent dialogue in compatible browsers to grant device access
- Gets a granted device by name
- Starts "ringing" effect on the device
- Makes device to offhook, used to answer incomming call or start outgoing call
- Makes device to onhook, used to terminate current call or reject incomming call
- Mutes device's microphone
- Unmutes device's microphone
- Subscribes to device event
- Unsubscribes to device event
`
const device = await webhidConsent({productId:0x0014});
//listen to device's event
device.subscribe((signal) => {
switch (signal) {
case DeviceSignalType.ACCEPT_CALL:
//call was accepted by the device, softphone should answer the call
//Remark: must call this function to sync device state either at here or somewhere at softphone state change confirmation callback
device.offHook()
break;
case DeviceSignalType.END_CALL:
//call was ended by the device, softphone should end the call
//Remark: must call this function to sync device state either at here or somewhere at softphone state change confirmation callback
device.onHook()
break;
case DeviceSignalType.REJECT_CALL:
//call was ended by the device, softphone should end the call
//Remark: must call this function to sync device state either at here or somewhere at softphone state change confirmation callback
device.onHook()
break;
case DeviceSignalType.MUTE_CALL:
//call was muted by the device, softphone should mute the call
//Remark: must call this function to sync device state either at here or somewhere at softphone state change confirmation callback
device.muteOn()
break;
case DeviceSignalType.UNMUTE_CALL:
//call was unmuted by the device, softphone should unmute the call
//Remark: must call this function to sync device state either at here or somewhere at softphone state change confirmation callback
device.muteOff()
break;
}
});
device.ring()
``