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

@xkit-yx/call-kit

v3.0.1

Published

## 安装

Downloads

210

Readme

网易云信 呼叫组件 API

安装

1.6.0 版本开始,呼叫组件将通过 npm 进行版本发包管理

npm install @xkit-yx/call-kit
// or
yarn add @xkit-yx/call-kit

单呼

详细请参照 ts 接口定义

使用示例

初始化

// 结合im的初始化
import NIM from 'xxxx' // im sdk path
import { NECall } from '@xkit-yx/call-kit'

let neCall: NECall
const im = NIM.getInstance({
  appKey: 'xxxx', // im appkey
  token: 'xxxx', // im token
  account: 'xxxx', // im account
  debugLevel: 'debug',
  lbsUrls: ['xxxx'],
  linkUrl: 'xxxx',
  onconnect: () => {
    neCall = new NECall({
      nim, // im 实例用户需要先初始化
      appKey, // 应用的 appKey,G2 平台的 appKey
      currentUserInfo: { accId: 'xxx', uid: 'xxx' }, // 当前用户的信息,accId 为 im 的 id,uid 为加入RTC的 id。accId 必填; uid 可选:不填系统将自动生成
      debug: true, // 是否需要开启日志,默认开启
      rtcConfig: {
        videoResolution: VIDEO_QUALITY.VIDEO_QUALITY_720p,
        videoFrameRate: VIDEO_FRAME_RATE.CHAT_VIDEO_FRAME_RATE_NORMAL,
        audioQuality: 'speech_low_quality',
      }, // rtcConfig 用来设置 RTC 可选。相关参数参照 可以参考[G2官方文档](https://doc.yunxin.163.com/docs/jcyOTA0ODM/zUxMDQzOTM?platformId=50082)
    })
  },
  ondisconnect: () => {
    neCall?.destroy()
  },
})

主叫

// 发起呼叫
const calleeId = 'xxx' // 被叫的im id
neCall.call({
  accId: calleeId, // 被叫 im 的 id
  callType: '1', //
})
// 设置视图
const localView = document.getElementById('localView')
const remoteView = document.getElementById('remoteView')
neCall.setLocalView(localView)
neCall.setRemoteView(remoteView, calleeId)
// 取消呼叫
neCall.hangup()

被叫

// 订阅邀请事件
neCall.on('onReceiveInvited', (value) => {
  // 用户可以触发视图,比如弹起邀请页面
})
// 设置视图
const localView = document.getElementById('localView')
const remoteView = document.getElementById('remoteView')
neCall.setLocalView(localView)
neCall.setRemoteView(remoteView, calleeId)
// 接受邀请,需要先设置视图
neCall.accept()
// 取消呼叫
neCall.hangup()

通话中,主叫与被叫

// 订阅会话建立事件
neCall.on('onCallConnected', (value) => {
  // 用户可以触发视图,比如弹起邀请页面
})
// 切换会话类型
neCall.switchCallType('2') // 入参为 callType
// 监听会话切换
neCall.on('onSwitchCallType', (value) => {})
// 开关本地视频
neCall.enableLocalVideo(true)
// 开关本地音频
neCall.enableLocalAudio(false)
// 挂断当前通话
neCall.hangup()

其他

// 订阅会话结束事件
neCall.on('onCallEnd', (value) => {
  // 用户可以触发视图,比如弹起邀请页面
  const reason = value.reason
  // 0:正常流程 | 1:token请求失败 | 2:呼叫超时 | 3:用户占线 | 4:nertc 初始化失败 | 5:加入 rtc 房间失败 | 6:cancel 取消参数错误 | 7:发起呼叫失败 | 8:对方rtc失败 | 9:其他端接受邀请 | 10:其他端拒绝邀请 | 11:通话中rtc 异常
})
//本端发送话事件
neCall.on('onMessageSent', (value) => {
  //当通话因为 取消、拒绝、超时或占线 结束时,组件会主动发送一条话单消息给对端,可以在此事件中更新本端的UI
})

群呼

详细请参照 ts 接口定义

使用示例

初始化

// 结合im的初始化
import NIM from 'xxxx' // im sdk path
import { NEGroupCall } from '@xkit-yx/call-kit'

let neGroupCall: NEGroupCall
const im = NIM.getInstance({
  appKey: 'xxxx', // im appkey
  token: 'xxxx', // im token
  account: 'xxxx', // im account
  debugLevel: 'debug',
  lbsUrls: ['xxxx'],
  linkUrl: 'xxxx',
  onconnect: () => {
    neGroupCall = new NEGroupCall({
      im: im,
      rtcConfig: {
        videoResolution: VIDEO_QUALITY.VIDEO_QUALITY_720p,
        videoFrameRate: VIDEO_FRAME_RATE.CHAT_VIDEO_FRAME_RATE_NORMAL,
        audioQuality: 'speech_low_quality',
      },
    })
  },
  shouldIgnoreMsg: (msg) => {
    if (msg.type === 'custom') {
      return neGroupCall?.receiveNimMsg(msg.content)
    }
    return false
  },
  ondisconnect: () => {
    neGroupCall?.destroy()
  },
})

主叫

// 发起呼叫
const members = ['accId1', 'accId2'] // 被叫的im id数组
neGroupCall.groupCall({ calleeList: members })
// 设置自己摄图
const myAccId = 'xxx' // 自己的im id
neGroupCall.setRtcView(dom, myAccId) // dom: 视图的dom
// 设置被邀请人的视图
members.forEach((accId) => {
  neGroupCall.setRtcView(dom, accId) // dom: 视图的dom
})
neGroupCall.jionRtc({ video: false }) // 参数为false时,只加入音频
// 挂断
neGroupCall.groupHangup()

被叫

// 订阅邀请事件
neGroupCall.on('onReceiveInvited', (value) => {
  // 用户可以触发视图,比如弹起邀请页面
})
// 接受邀请
neGroupCall.groupAccept()
// 设置视图
const myAccId = 'xxx' // 自己的im id
neGroupCall.setRtcView(dom, myAccId) // dom: 视图的dom
// 设置被邀请人的视图
members.forEach((accId) => {
  neGroupCall.setRtcView(dom, accId) // dom: 视图的dom
})
neGroupCall.jionRtc({ video: false }) // 参数为false时,只加入音频
// 拒绝
neGroupCall.groupHangup()

通话中,主叫与被叫

// 订阅用户变化通知
neGroupCall.on('onMembersChange', (value) => {
  // 用户变更
})
// 开关本地视频
neGroupCall.enableLocalVideo(true)
// 开关本地音频
neGroupCall.enableLocalAudio(false)
// 挂断当前通话
neGroupCall.groupHangup()

其他

// 订阅会话结束事件
neCall.on('onCallEnd', (value) => {
  // 通话结束
})
neGroupCall.groupInvite({ calleeList: ['accId1', 'accId2'] }) // 通话中邀请
neGroupCall.groupJoin({ callId: 'xxx' }) // 加入某个通话
neGroupCall.groupQueryCallInfo({ callId: 'xxx' }) // 查询某个通话的信息,参数不传就查询当前通话