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 🙏

© 2026 – Pkg Stats / Ryan Hefner

xm-softphone-client

v1.1.0

Published

软电话 Client

Readme

软电话 SDK

一个基于 TypeScript 的软电话 SDK,提供 WebRTC/SIP 电话功能。支持 CommonJS、ES Module 和 UMD 格式。

安装

npm install xm-softphone-client

使用方式

ES Module 导入 (现代浏览器/框架)

import XmSoftPhoneClient from 'xm-softphone-client';

// 初始化SDK
const softphone = new XmSoftPhoneClient({
  // ...配置
});

CommonJS 导入 (Node.js)

const XmSoftPhoneClient = require('xm-softphone-client');

// 初始化SDK
const softphone = new XmSoftPhoneClient({
  // ...配置
});

UMD 格式 (直接在浏览器中使用)

<!-- 通过 CDN 或本地文件加载 -->
<script src="https://path/to/xm-softphone-client"></script>
<!-- 或 -->
<script src="./node_modules/xm-softphone-client/dist/index.umd.js"></script>

<script>
  // 全局变量 XmSoftPhoneClient
  const softphone = new XmSoftPhoneClient({
    // ...配置
  });
</script>

基本用法示例

// 初始化SDK
const softphone = new XmSoftPhoneClient({
  logLevel: 'warn',
  loginName: '2000@abcd',
  password: '',
  answerType: 'WEBRTC',
  isPasswordMd5: false,
});

// 监听事件
softphone.on('ready', () => {
  console.log('sdk准备就绪');
});

softphone.on('stop', () => {
  console.log('sdk已停止');
});

softphone.on('error', (error) => {
  console.error('发生错误', error);
});

softphone.on('kickOff', () => {
  console.log('座席被踢下线');
});

// 座席状态变化
softphone.on('agentStatus', (agentStatus) => {
  console.log('座席状态', agentStatus);
});

// 通话事件
softphone.on('callStatus', (callStatus) => {
  console.log('通话事件', callStatus);
});

// 呼入事件
softphone.on('incomingCall', (callStatus) => {
  console.log('收到来电', callStatus);
});

// 发起呼叫
const makeCall = async () => {
  const call = await softphone.dialOut('13800138000');
  
  console.log('呼叫已发起', call);
};

API 参考

初始化选项

  • serverUrl: 服务器地址(默认公有云地址)
  • logLevel: 日志级别 ('debug', 'info', 'warn', 'error')
  • loginName: 登录账号,格式为"座席工号@账号名"
  • password: 登录密码
  • answerType: 接听类型,例如 'WEBRTC'
  • isPasswordMd5: 密码是否已经过MD5加密 (默认: false)

主要方法

  • start(): 启动SDK并连接软电话服务
  • stop(): 停止SDK并断开连接
  • getAvailableStatus(): 获取座席可用状态
  • getAgentDisplayNumbers(): 获取座席可用外显号码
  • changeAnswerType(answerType): 切换座席接听方式
  • changeStatus(statusNumber): 切换座席状态
  • dialOut(phoneNumber): 发起呼叫到指定电话号码
  • hangup(): 挂断
  • answer(): 接听来电(仅限软电话接听方式)
  • holdOrUnHold(type): 保持/取消保持通话
  • muteOrUnMute(type):静音/取消静音
  • transfer(type, number): 转接通话
  • transferToSatisfaction(): 转接到满意度调查

事件

  • ready: SDK准备就绪
  • stop: SDK已停止
  • error: 发生错误,返回错误信息
  • kickOff: 座席被踢下线
  • agentStatus: 座席状态变化,返回最新状态
  • callStatus: 通话状态变化,返回通话相关信息
  • incomingCall: 收到来电,返回来电信息,需要调用answer()方法接听

许可证

Apache-2.0