npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@webtrit/webtrit-signaling

v0.5.3

Published

WebTrit Signaling Client on TypeScript

Downloads

38

Readme

WebTrit Signaling Client

WebTrit Signaling Client is basic implementation of WebTrit Signaling Protocol on TypeScript.

Installing

Using npm:

npm install @webtrit/webtrit-signaling

Using jsDelivr CDN:

<script src="https://cdn.jsdelivr.net/npm/@webtrit/webtrit-signaling@latest/dist/webtrit-signaling.js"></script>

Using unpkg CDN:

<script src="https://unpkg.com/@webtrit/webtrit-signaling@latest/dist/webtrit-signaling.js"></script>

Example

import WebtritSignaling from '@webtrit/webtrit-signaling'

// Websocket URL of WebTrit Core (the URL must use the scheme `ws` or `wss`)
const url = '<WebTrit Core url>'
// Token to identify user's session on WebTrit Core
const token = '<token>'

const webtritSignalingClient = new WebtritSignaling({
  eventCallback: (signalingEvent) => {
      console.log('>> eventCallback: ${signalingEvent}')
  },
  errorCallback: (error) => {
    console.log('>> errorCallback: ${error}')
  },
  disconnectedCallback: (reason, code) => {
    console.log('>> disconnectedCallback: with code: ${code} and reason: ${reason}')
  },
  connectedCallback: (event) => {
    console.log('>> connectedCallback: ${event}')
  }
})

webtritSignalingClient.connect({
  url,
  token,
})

await new Promise(r => setTimeout(r, 2000))

console.log('Wait StateEvent')

await new Promise(r => setTimeout(r, 5000))

console.log('Disconnecting')

webtritSignalingClient.disconnect();

await new Promise(r => setTimeout(r, 3000))

Send outgoing call request

await webtritSignalingClient.execute('outgoing_call', {
  line: 0,
  call_id: 'qwertyuiop',
  number: '1234567890',
  jsep: sdp,
})

To generate call_id for outgoing call request could be used next method:

call_id = webtritSignalingClient.generateCallId()

Source code examples

In examples folder containing 2 scripts that used webtrit_signaling_ts to communicate with webtrit_core.

  • demo - simple script this initializes callback and alert if the connection is established or failed;
  • test - the script receives a call and depending on configuration decline or answer, or make a call to a specific called number.

Retrieve token from webtrit_core

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"identifier":"web-12345", "login":"<login>", "password":"<password>", "type":"web"}' \
  http://<webtrit_core server>/api/v1/session

Environment variables for demo example

  • TOKEN - access token
  • URL - webtrit signaling server URL in format: http://<webtrit_core server>/api/v1/session

test example

For this script are two options for transferring configuration parameters. Through environment variables or through URL parameters

Environment variables for test example

  • ID - unique identificator of script in status data, required
  • TOKEN - access token
  • URL - webtrit signaling server URL in format: ws://<webtrit_core server>/api/v1/session, default: ws://localhost:4000/signaling/v1
  • CALLED_NUMBER - the number to called
  • VIDEO_CALL - make a video call true or without video false, default: false
  • INCOMING_CALL_DURATION - the middle value of incoming call duration in seconds, for details see section: call duration possible values, default: -2
  • OUTGOING_CALL_DURATION - the middle value of outgoing call duration in seconds, for details see section: call duration possible values, default: -2
  • INCOMING_CALL_DEVIATION - deviation from middle value real call duration randomized in range from (INCOMING_CALL_DURATION - INCOMING_CALL_DEVIATION) to (INCOMING_CALL_DURATION + INCOMING_CALL_DEVIATION), default: 0
  • OUTGOING_CALL_DEVIATION - deviation from middle value real call duration randomized in range from (OUTGOING_CALL_DURATION - OUTGOING_CALL_DEVIATION) to (OUTGOING_CALL_DURATION + OUTGOING_CALL_DEVIATION), default: 0
  • PAUSE_BETWEEN_CALL - pause between outgoing call, 0 - no pause, >0 - pause in seconds, default: 1s
  • INTERVAL - the interval of peerConnection statistic retrieve in seconds, default: 1s

URL parameters for test example

  • id - unique identificator of script in status data, require
  • token - access token
  • url - webtrit signaling server URL in format: ws://<webtrit_core server>/api/v1/session, default: ws://localhost:4000/signaling/v1
  • called - the number to called
  • video - make a video call true or without video false, default: false
  • in_duration - the middle value of incoming call duration in seconds, for details see section: call duration possible values, default: -2
  • out_duration - the middle value of outgoing call duration in seconds, for details see section: call duration possible values, default: -2
  • in_deviation - deviation from middle value real call duration randomized in range from (INCOMING_CALL_DURATION - INCOMING_CALL_DEVIATION) to (INCOMING_CALL_DURATION + INCOMING_CALL_DEVIATION), default: 0
  • out_deviation - deviation from middle value real call duration randomized in range from (OUTGOING_CALL_DURATION - OUTGOING_CALL_DEVIATION) to (OUTGOING_CALL_DURATION + OUTGOING_CALL_DEVIATION), default: 0
  • pause - pause between outgoing call, 0 - no pause, >0 - pause in seconds, default: 1s
  • stats_interval - the interval of peerConnection statistic retrieve in seconds, default: 1s

Call duration possible values

  • -2 - outgoing do not make/incoming drop
  • -1 - infinity outgoing or incoming call
  • 0 - outgoing call with 0 duration
  • >0 - call duration in seconds

License

MIT