Ninja Programmers Mindmeld

    @rongcloud/plugin-call-engine
    TypeScript icon, indicating that this package has built-in type declarations

    5.0.6 • Public • Published

    初始化

    // CallLib 内部代码
    import { RCCallEngine } from '@rongcloud/call-engine'
    
    const callInstaller = {
      tag: 'RCCALL',
      verify () {
        //...
      },
      setup(context: PluginContext,) {
        const callEngine = new RCCallEngine(
          context, 
          logger, // engine 日志模块
          // 收到邀请
          onInvite (callId, crtList, inviteList) {
    
          }
        )
      }
    }

    CallSession 获取

    // rtc 房间 ID
    const callId = ''
    const { code, session: callSession } = callEngine.createSession(callId, {
      onSessionStateChange(state, summary?: any) {
        // 
      },
      onUserStateChange(info: {id: string, state: number}[]) {
        // 用户不存在于通话中 | 等待接听 | 通话中
      },
      onRinging(sender) {
        // 收到被叫 响铃
      },
      onMediaModify (sender) {
        // 收到媒体类型更改
      }
    })

    CallSession 实例方法

    // 单呼
    const { code } = await callSession.call(channelId, targetId, mediaType)
    
    // 群呼
    const { code } = await callSession.callInGroup(channelId, targetId, mediaType)
    
    // 群呼叫中继续邀请
    const { code } = await callSession.invite(['user1', 'user2'])
    
    // 接听
    const { code } = await callSession.accept()
    
    // 挂断
    const { code } = await callSession.hungup()
    
    // 通话媒体类型修改 (callEngine 层支持 音频转视频 视频转音频 消息,calllib 内部做业务限制)
    const { code } = await callSession.changeMediaType(type)
    
    /**
     * rtc userJoin 事件触发时调用 
     * (用于未收到被叫发送的 accept 消息情况下 补偿处理 callSession 内部人员列表及状态)
     */
    callSession.userJoin([''])
    
    /**
     *  rtc userLeft、userKickOff 事件触发时调用
     *  (用于为收到主叫或被叫发送的 hungup 消息情况下 补偿不理 callSession 内部人员列表及状态)
     */
    callSession.userLeave([''])
    
    // session 相关信息获取
    callSession.getSessionId()
    
    callSession.getChannelId()
    
    callSession.getTargetId()
    
    callSession.getConversationType()
    
    callSession.getRemoteUsers()
    
    callSession.getSessionState()
    
    callSession.getCallerId()
    
    callSession.getSummary()

    Install

    npm i @rongcloud/plugin-call-engine

    DownloadsWeekly Downloads

    13

    Version

    5.0.6

    License

    LGPL 2.1

    Unpacked Size

    138 kB

    Total Files

    7

    Last publish

    Collaborators

    • libin_npm
    • cloudregister
    • knight1cy
    • congk