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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-jssip-ui

v1.0.19

Published

Vite + Antd + React + TypeScript + Tailwind Css Sip

Downloads

862

Readme

项目基于 sip-call(对jssip的二次封装,感谢原作者的贡献)。

安装

npm install react-jssip-ui
yarn add react-jssip-ui

示例

import { SipContactCenter } from 'react-jssip-ui';
import 'react-jssip-ui/dist/style.css';

let sipCall;
export default () => {
  // 拨打电话
  function call(phone) {
    // 其中:
    // 入参,第一个参数为必填,第二个参数为可选的扩展参数
    // 出参,callUUID表示通话的唯一标识,与话单中的uuid一致
    sipCall.call(phone,{"businessId":"自定义参数(最多100个字符)"});
  }
  
  // 检查麦克风
  function micCheck() {
    sipCall.micCheck();
  }
  
  return (
      <SipContactCenter 
        options={{
          host: 'sip.example.com',
          port: '5066',
          proto: false,
          extNo: '8889',
          extPwd: '8889'
      }} 
        onRegister={(sip) => (sipCall = sip)}
      ></SipContactCenter>
    )
}

文档说明

提供如下方法:

| 函数 | 调用方式 | 说明 | |-------|--------------------------|------------| | 销毁SDK | cleanSDK() | | | 检查麦克风 | micCheck() | 异步接口,若麦克风异常会回调MIC_ERROR事件 | | 注册 | register() | | | 取消注册 | unregister() | | | 呼叫请求 | call(phone,extraParam={}) | phone为外呼号码,extraParam为可选的扩展参数(可以不传) | | 挂断电话 | hangup() | | | 应答接听 | answer() | | | 保持 | hold() | | | 取消保持 | unhold() | | | 转接通话 | transfer(phone) | | | 按键 | sendDtmf(tone) | 按键或二次拨号 |

以下对几个特殊的方法进行说明:

初始化options参数

| 参数 | 说明 | 是否必填 | |--------------------|----------------------------------------|------------| | host | 服务器地址 | 必填项 | | port | 服务器端口 | 必填项 | | proto | bool类型 true/false,使用wss或者ws协议 | 不填,默认为ws协议 | | extNo | 分机账号 | 必填项 | | extPwd | 分机密码 | 必填项 | | stateEventListener | 状态回调函数方法 参照文档最下方stateEventListener详细说明 | 需注入状态回调 | | autoRegister | bool类型 true/false,initSDK调用后是否自动注册 | 不填默认为false |

状态回调(stateEventListener)

前端注入状态回调函数,通过状态回调 控制页面按钮显示

stateEventListener回调参数为 event, data

| Event事件列表 | 返回值 | 状态说明 | |-----------------------------|------------------------------------------------------------------------------------------------------------------------------------------|---------------| | MIC_ERROR | {msg: xxxx} | 麦克风检测异常 | | ERROR | {msg: xxxx} | 错误异常 | | CONNECTED | {localAgent: '1001'} | 连接成功 | | DISCONNECTED | 无返回值 | websocket连接失败 | | REGISTERED | 无返回值 | 注册成功 | | UNREGISTERED | 无返回值 | 取消注册 | | REGISTER_FAILED | {msg: xxxx} | 注册失败 | | INCOMING_CALL/OUTGOING_CALL | {direction: 'inbound', otherLegNumber: '138xxxxxxxx', 'callId': 'xxxxxxx'} 说明:direction为呼叫方向:inbound呼入,outbound呼出;otherLegNumber:第三方呼叫记录 | 呼入振铃/外呼响铃 | | IN_CALL | 无返回值 | 通话中 | | HOLD | 无返回值 | 保持中 | | CALL_END | CallEndEvent | 通话结束 |

CallEndEvent

| 属性 | 必须 | 类型 | 说明 | |------------|----|----|-----------------------------------| | answered | 是 | boolean | 是否接通(以后端为准) | | originator | 是 | string | 发起方(挂断方):local本地(自己),remote远程(对方) | | cause | 是 | string | 挂断原因 | | code | 否 | number | 当originator=remote,且answered=false时存在 |