Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dr-liveroom

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dr-liveroom

Zego double record service with liveroom.

  • 1.4.9
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

快速入门

安装

使用 npm 安装 sdk: npm i dr-liveroom

初始化实例

import QueueService from "dl-liveroom";

// userType: staff 为坐席,customer 为用户
const queueService = new QueueService({ userType: "customer" });

// 初始化登录信息
await queueService.loginAsync({
  appId: "<appId>",
  server: "<server>",
  dispatchServer: "<dispatchServer>",
  tokenUrl: "<tokenUrl>",
  idName: "<idName>"
});

获取排队服务列表

// 获取正在所有排队队列的信息
const queueList = await queueService.getQueueList();
const firstQueue = queueList[0];

进入排队服务

// 客户vip信息,0为普通客户,1~9为vip等级客户
const vipInfo = 0;

// 第一个排队队列的数据信息
const { 
  queueId,
  queueName
} = firstQueue;

// 客户进入排队服务队列
const enterRes = await queue.customerEnterQueue({
  queueId,
  extraInfo: "",
  vipInfo: this.state.isVip ? 1 : 0
});

// 坐席进入队列
const enterRes = await queue.staffEnterQueue({
  queueId,
  queueName,
  roomId
});

服务回调通知及回复服务

// 坐席接人
const catchRes = await queue.staffCatch();

// 客户排队服务到达回调
queueService.onCustomerServiceStart(async (para) => {
  const { roomId } = para.body;
  const reject = false;

  // 客户回复排队服务
  await queueService.customerReply({
      /** 协商id */
      consultId,
      /** 服务选项 1 同意服务 2 拒绝服务 */
      operation: reject ? 2 : 1
  });
});

// 坐席收到客户回复
queue.onStaffServiceStart((para) => {
  window._openDialog({
    content: ["", "Customer is accept service", "Customer is reject service", "Service is timeout", "The customer is quitted queue"][para.body.customerOperation]
  });
});

进入音视频房间

// 进入音视频房间逻辑

// 发布的流视频 id
const publishStreamId = "<publishStreamId>";
// 本地预览 HTMLVideoElement
const localViewEl = "<HTMLVideoElement>";
// 远程流播放 HTMLVideoElement
const remoteViewEl = "<HTMLVideoElement>";


// 进入音视频房间
const streamList = await queueService.enterRoomAsync(roomId);
// 开始预览
await queueService.startPreviewAsync(localViewEl);
// 开始发布视频流
await queueService.startPublish(publishStreamId);
// 开始播放第一个远程视频流
await queueService.playStream({ viewEl: remoteViewEl, streamId: streamList[0].streamId });

退出排队服务队列

// 客户退出排队服务队列
await queueService.customerQuitQueue();
// 组拍戏退出排队服务队列
await queueService.staffQuitQueue();

离开音视频房间

// 离开音视频房间逻辑

// 离开音视频房间
await queueService.leaveRoom();
// 停止本地预览
await queueService.stopPreview();
// 停止发布视频流
await queueService.stopPublish();
// 停止播放所有远程视频流
await queueService.stopPlayStreams();

相关事件回调注册

// 注册部分事件回调

queueService.onCustomerServiceTimeout = () => {
    console.log("is service timeout.");
};

queueService.onUserStateUpdate = (roomId, userList) => {
    console.log(roomId, userList);
};

queueService.onRecvCustomCommand = (userId, userName, content) => {
  console.log(userId, userName, content);
};

queueService.onStreamUpdated = (type, newStreamList) => {
  console.log(type, newStreamList);
};

queueService.onPlayQualityUpdate = (streamId, quality) => {
  console.log(streamId, quality);
};

queueService.onTempBroken = () => {
  console.log("临时掉线");
};

queueService.onReconnect = () => {
  console.log("重连成功");
};

queueService.onKickOut = (err) => {
  console.log("被踢下线通知");
};

queueService.onDisconnect = (err) => {
  console.log("服务掉线通知");
};

FAQs

Package last updated on 26 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc