@realsee/live 0.5.0-alpha.4 → 0.5.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -51196,6 +51196,9 @@
51196
51196
  this._handleOpenEvent = (event) => {
51197
51197
  logger$1.info('live room open', event.detail);
51198
51198
  this.state = exports.LiveState.OPEN;
51199
+ if (event.detail.reconnects > 0) {
51200
+ this.emit('reconnected', event.detail);
51201
+ }
51199
51202
  };
51200
51203
  /**
51201
51204
  * 处理超时
@@ -51322,6 +51325,7 @@
51322
51325
  this._addLiveControllerEventListeners = () => {
51323
51326
  this._controller.on('stateChange', this._handleStateChange);
51324
51327
  this._controller.on('message', this._handleMessage);
51328
+ this._controller.on('reconnected', this._handleReconnected);
51325
51329
  };
51326
51330
  /**
51327
51331
  * 移除带看控制的事件监听
@@ -51329,6 +51333,7 @@
51329
51333
  this._removeLiveControllerEventListeners = () => {
51330
51334
  this._controller.off('stateChange', this._handleStateChange);
51331
51335
  this._controller.off('message', this._handleMessage);
51336
+ this._controller.off('reconnected', this._handleReconnected);
51332
51337
  };
51333
51338
  /**
51334
51339
  * 带看状态变化
@@ -51336,6 +51341,10 @@
51336
51341
  * @returns
51337
51342
  */
51338
51343
  this._handleStateChange = (state, prevState) => this.emit('stateChange', state, prevState);
51344
+ /**
51345
+ * 消息接收
51346
+ * @param liveMsg
51347
+ */
51339
51348
  this._handleMessage = (liveMsg) => __awaiter$$(this, void 0, void 0, function* () {
51340
51349
  var _b, _c, _d, _e, _f, _g;
51341
51350
  if (typeof liveMsg === 'object') {
@@ -51367,6 +51376,7 @@
51367
51376
  */
51368
51377
  case exports.Command.RTCInfo: {
51369
51378
  const { voice_id: voiceId, type } = data;
51379
+ this._buildInData.rtcInfo = { voiceId, type };
51370
51380
  if (!((_b = this.$RTC) === null || _b === void 0 ? void 0 : _b.joined)) {
51371
51381
  const result = yield ((_c = this.$RTC) === null || _c === void 0 ? void 0 : _c.join({
51372
51382
  voiceId,
@@ -51478,6 +51488,32 @@
51478
51488
  }
51479
51489
  }
51480
51490
  });
51491
+ /**
51492
+ * 处理重连
51493
+ * @param detail
51494
+ */
51495
+ this._handleReconnected = (detail) => __awaiter$$(this, void 0, void 0, function* () {
51496
+ var _h, _j, _k, _l, _m, _o, _p;
51497
+ // 已经重连上ws,尝试重连语音
51498
+ this.$RTC.joined = false;
51499
+ const { rtcInfo } = this._buildInData;
51500
+ if (rtcInfo) {
51501
+ const { voiceId, type } = rtcInfo;
51502
+ const result = yield ((_h = this.$RTC) === null || _h === void 0 ? void 0 : _h.join({
51503
+ voiceId,
51504
+ userId: ((_j = this.selfInfo) === null || _j === void 0 ? void 0 : _j.id) || '',
51505
+ roomId: (_k = this.roomInfo) === null || _k === void 0 ? void 0 : _k.info.room_code,
51506
+ type,
51507
+ }));
51508
+ if (result) {
51509
+ const status = (_o = (_m = (_l = this.selfInfo) === null || _l === void 0 ? void 0 : _l.micro_status) !== null && _m !== void 0 ? _m : this._options.initialMicroStatus) !== null && _o !== void 0 ? _o : exports.MicroStatus.OPEN;
51510
+ yield ((_p = this.$RTC) === null || _p === void 0 ? void 0 : _p.toggleMicro(status === exports.MicroStatus.OPEN));
51511
+ }
51512
+ else {
51513
+ logger$1.error('加入语音房间失败');
51514
+ }
51515
+ }
51516
+ });
51481
51517
  /**
51482
51518
  * 清理带看缓存的数据
51483
51519
  */
@@ -51490,12 +51526,12 @@
51490
51526
  * @returns
51491
51527
  */
51492
51528
  this.connect = (options = {}) => __awaiter$$(this, void 0, void 0, function* () {
51493
- var _h, _j, _k, _l;
51529
+ var _q, _r, _s, _t;
51494
51530
  // 检查 url 和 票据获取接口实现
51495
- this._options.url = (_j = (_h = options.url) !== null && _h !== void 0 ? _h : this._options.url) !== null && _j !== void 0 ? _j : '';
51496
- this._options.getTicket = (_k = options.getTicket) !== null && _k !== void 0 ? _k : this._options.getTicket;
51531
+ this._options.url = (_r = (_q = options.url) !== null && _q !== void 0 ? _q : this._options.url) !== null && _r !== void 0 ? _r : '';
51532
+ this._options.getTicket = (_s = options.getTicket) !== null && _s !== void 0 ? _s : this._options.getTicket;
51497
51533
  this._options.initialMicroStatus =
51498
- (_l = options.rtcMicStatus) !== null && _l !== void 0 ? _l : this._options.initialMicroStatus;
51534
+ (_t = options.rtcMicStatus) !== null && _t !== void 0 ? _t : this._options.initialMicroStatus;
51499
51535
  if (!/^ws(s):\/\//.test(this._options.url) ||
51500
51536
  typeof this._options.getTicket !== 'function') {
51501
51537
  if (!/^ws(s):\/\//.test(this._options.url)) {
@@ -51537,11 +51573,11 @@
51537
51573
  * @returns
51538
51574
  */
51539
51575
  this.exit = () => __awaiter$$(this, void 0, void 0, function* () {
51540
- var _m;
51576
+ var _u;
51541
51577
  this._clearLiveData();
51542
51578
  try {
51543
51579
  /** 退出强制关闭语音 */
51544
- (_m = this.$RTC) === null || _m === void 0 ? void 0 : _m.quit();
51580
+ (_u = this.$RTC) === null || _u === void 0 ? void 0 : _u.quit();
51545
51581
  yield this.updateStatus(exports.BuiltinEventType.RoomChange, exports.BuiltinActionType.RoomClose, {});
51546
51582
  }
51547
51583
  catch (e) {
@@ -51568,10 +51604,10 @@
51568
51604
  });
51569
51605
  // 仅用于用户自己的麦克风控制
51570
51606
  this.toggleMicro = (microStatus) => __awaiter$$(this, void 0, void 0, function* () {
51571
- var _o, _p, _q;
51572
- if (!((_p = (_o = this.selfInfo) === null || _o === void 0 ? void 0 : _o.permission) === null || _p === void 0 ? void 0 : _p.control_own_micro))
51607
+ var _v, _w, _x;
51608
+ if (!((_w = (_v = this.selfInfo) === null || _v === void 0 ? void 0 : _v.permission) === null || _w === void 0 ? void 0 : _w.control_own_micro))
51573
51609
  return false;
51574
- const result = yield ((_q = this.$RTC) === null || _q === void 0 ? void 0 : _q.toggleMicro(microStatus));
51610
+ const result = yield ((_x = this.$RTC) === null || _x === void 0 ? void 0 : _x.toggleMicro(microStatus));
51575
51611
  if (result) {
51576
51612
  yield this.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserMicroStatus, {
51577
51613
  status: microStatus ? exports.MicroStatus.OPEN : exports.MicroStatus.CLOSE,
@@ -51586,12 +51622,12 @@
51586
51622
  * @returns
51587
51623
  */
51588
51624
  this.forbidMicro = (microStatus, toUserIds) => __awaiter$$(this, void 0, void 0, function* () {
51589
- var _r, _s;
51625
+ var _y, _z;
51590
51626
  if (typeof this._options.canForbidUserMicro === 'function' &&
51591
51627
  !this._options.canForbidUserMicro(toUserIds)) {
51592
51628
  return false;
51593
51629
  }
51594
- if (!((_s = (_r = this.selfInfo) === null || _r === void 0 ? void 0 : _r.permission) === null || _s === void 0 ? void 0 : _s.control_other_micro)) {
51630
+ if (!((_z = (_y = this.selfInfo) === null || _y === void 0 ? void 0 : _y.permission) === null || _z === void 0 ? void 0 : _z.control_other_micro)) {
51595
51631
  return false;
51596
51632
  }
51597
51633
  return yield this.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserMicroStatus, {
@@ -51605,12 +51641,12 @@
51605
51641
  * @returns
51606
51642
  */
51607
51643
  this.forbidSync = (sync, toUserIds) => __awaiter$$(this, void 0, void 0, function* () {
51608
- var _t, _u;
51644
+ var _0, _1;
51609
51645
  if (typeof this._options.canForbidUserSync === 'function' &&
51610
51646
  !this._options.canForbidUserSync(toUserIds)) {
51611
51647
  return false;
51612
51648
  }
51613
- if (!((_u = (_t = this.selfInfo) === null || _t === void 0 ? void 0 : _t.permission) === null || _u === void 0 ? void 0 : _u.control_other_sync)) {
51649
+ if (!((_1 = (_0 = this.selfInfo) === null || _0 === void 0 ? void 0 : _0.permission) === null || _1 === void 0 ? void 0 : _1.control_other_sync)) {
51614
51650
  return false;
51615
51651
  }
51616
51652
  return yield this.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserPermission, { sync_frame: sync }, toUserIds);
@@ -51621,12 +51657,12 @@
51621
51657
  * @returns
51622
51658
  */
51623
51659
  this.kick = (toUserIds) => __awaiter$$(this, void 0, void 0, function* () {
51624
- var _v, _w;
51660
+ var _2, _3;
51625
51661
  if (typeof this._options.canForbidUserKick === 'function' &&
51626
51662
  !this._options.canForbidUserKick(toUserIds)) {
51627
51663
  return false;
51628
51664
  }
51629
- if (!((_w = (_v = this.selfInfo) === null || _v === void 0 ? void 0 : _v.permission) === null || _w === void 0 ? void 0 : _w.change_other_status)) {
51665
+ if (!((_3 = (_2 = this.selfInfo) === null || _2 === void 0 ? void 0 : _2.permission) === null || _3 === void 0 ? void 0 : _3.change_other_status)) {
51630
51666
  return false;
51631
51667
  }
51632
51668
  return yield this.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserStatus, {