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

wdjsdk

v1.2.16

Published

## 安装

Readme

WEB-SDK-js

安装

npm 安装

npm i wdjsdk

API

constructor 实例化

let signal = new signalling(userId)

  • userId:调度员ID。
  • <返回>:signalling 实例

new 的时候自动调用

duplex 语音通话

signal.duplex(calleed)

  • calleed:被叫用户的userId
  • <返回>:当前的语音通话 duplex

返回的 duplex 有挂断方法 hangUp

groupCall 组呼

signal.groupCall(groupId)

  • groupId:被叫群组
  • <返回>:当前的组呼 groupCall

返回的 groupCall 有挂断方法 hangUp、话权申请、话权释放

videoPull 视频上拉

signal.videoPull(calleed,videoElement)

  • calleed:被叫用户的userId
  • videoElement:html的video标签,视频将在这个标签中播放
  • <返回>:当前的视频上拉 videoPull

返回的 videoPull 有挂断方法 hangUp

videoCall 视频通话

signal.videoCall(calleed,videoElement)

  • calleed:被叫用户的userId
  • videoElement:html的video标签,视频将在这个标签中播放
  • <返回>:当前的视频通话 videoCall

返回的 videoCall 有挂断方法 hangUp

voiceAskFor 话权申请

groupCall.voiceAskFor() or signal.voiceAskFor(groupNo)

voiceRelease 话权释放

groupCall.voiceRelease() or signal.voiceRelease(groupNo)

hangUp 主动挂断

通过被叫id挂断

signal.hangUp(userId|groupId)

giveUp 主动取消

用法和hangUp一致,发起呼叫后在对面未接听前可以调用此方法取消呼叫。

signal.giveUp(userId|groupId)

videoHandle 对端挂断时的video标签的处理

signal.videoHandle

  • video 需要被处理的video标签

signal.videoHandle = (video)=>{....}

audioHandle 对端音频挂断时的回调

signal.audioHandle

  • calleed 被叫用户的userId

signal.audioHandle = (calleed)=>{....}

onConnect

  • 被叫用户的userId 接通时的监听。

signal.onConnect = (calleed)=>{console.log('接通')}

onCalled

当有普通用户(终端)向调度员(web端)发起呼叫时,的监听

  • called 终端发起呼叫时带1的一些信息

signal.onCalled = (called)=>{.....}

called 包含reqtype属性和一些方法

  • id 表示发起呼叫的用户的id
  • reqType 表示发起呼叫的类型,用数字表示
    • 6:视频上拉
    • 4:视频通话
    • 1:全双工语音通话
  • reject() 调用此方法表示拒绝接听
  • accpet(video) 调用此方法表示接听,如果是视频通话和视频上拉类型,需要传一个video标签作为参数

onGiveUp

(终端)取消呼叫时的监听事件

  • calledId 终端的用户id

signal.onGiveUp = (calledId)=>{......}

message 即时消息处理

signal.message(functionList)

functionList 是一个包含多个function的对象,具体属性如下

functionList = {
  online:function(params){

  }
  switchGroup:function(params){

  }
  refresh:function(params){

  }
  groupChange:function(params){

  }
  SOS:function(params){

  }
}

接下来对每个函数的参数进行详解

online 上下线通知

  • online:一个包含所有上线人员的数组
  • offline:一个包含所有下线人员的数组 online 和 offline 属性只会出现一个

functionList = {
  online:function(params){
    console.log(params.online)
    //改变上下线状态
    if(params.online){
     changeOnlineStatus(params.online)
    }else{
     changeOfflineStatus(params.offline)
    }
  }
   ......
}

switchGroup 终端切组通知

  • termId:用户id
  • jion:附着的组
  • deJoin:去附着的组 termId 属性必然存在,jionGroup 和 deJoin 至少存在其中一个

functionList = {
  switchGroup:function(params){
    let { termId , jion , deJoin } = params
    if(!(jion || deJoin))throw new Error('消息异常')
    if(deJoin){
     deJoinGroup(termId , deJoin)
    }
    if(jion){
     jionGroup(termId , jion)
    }
  }
   ......
}

refresh 签约数据变更

functionList = {
  refresh:function(params){
    location.replace(location.href+'?t='+new Date().getTime())
  }
   ......
}

groupChange 群组变化通知

  • operId:
  • groupId:

functionList = {
  groupChange:function(params){
    let { operId , groupId } = params
    switch(operId){
        case 'Mod':
           getGroupApi(groupId);
           break;
        case 'Del':
           delGroup(groupId);
           break;
         default:
           break;
    }
  }
   ......
}

SOS 紧急告警

  • termId:紧急告警用户的Id
  • latitude:纬度
  • longitude:经度
  • id:告警唯一性Id

functionList = {
  SOS:function(params){
    alert(JSON.stringify(param))
  }
   ......
}