@realsee/live 0.5.0-alpha.6 → 0.5.0-alpha.9

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.
@@ -619,7 +619,7 @@ class VRWebViewRTC extends CoreRTC {
619
619
  this.voiceId = '';
620
620
  this.options = { jsBridge, getVoiceSign };
621
621
  // TO-DO: 在微信小程序下有个音量上报的BUG会导致消息体过大从而jsbridge异常断开
622
- if (this.jsBridge.webViewType !== "WxMiniProgramWebView") {
622
+ if (this.jsBridge.webViewType !== 'WxMiniProgramWebView') {
623
623
  this.jsBridge.callAndListen('live/userVolumes', (userVolumes) => {
624
624
  this.emit('userVolumes', userVolumes);
625
625
  });
@@ -634,25 +634,37 @@ class VRWebViewRTC extends CoreRTC {
634
634
  }
635
635
  join(options) {
636
636
  return __awaiter(this, void 0, void 0, function* () {
637
- this.emit('joinWillStart');
638
- const { sdkAppId, userId, userSig } = yield this.options.getVoiceSign(options);
639
- this.type = options.type;
640
- const [res, error] = yield this.jsBridge.callAndBackfeed(`live/join?sdkAppID=${sdkAppId}&userID=${userId}&roomID=${Number(options.voiceId)}&userSig=${userSig}`);
641
- if (!res) {
642
- this.emit('error', error ? error : new Error('加入房间失败:未知异常。'));
643
- this.joined = false;
644
- }
645
- else {
646
- if (res.code === exports.RTCJoinedInfoCodeEnum.Success) {
647
- this.emit('joined');
648
- this.joined = true;
637
+ try {
638
+ this.emit('joinWillStart');
639
+ const { sdkAppId, userId, userSig } = yield this.options.getVoiceSign(options);
640
+ if (!(Boolean(sdkAppId) && Boolean(userId) && Boolean(userSig))) {
641
+ this.emit('error', new Error('加入房间失败:rtc 签名请求异常'));
642
+ this.joined = false;
643
+ return this.joined;
649
644
  }
650
- else {
651
- this.emit('error', res);
645
+ this.type = options.type;
646
+ const [res, error] = yield this.jsBridge.callAndBackfeed(`live/join?sdkAppID=${sdkAppId}&userID=${userId}&roomID=${Number(options.voiceId)}&userSig=${userSig}`);
647
+ if (!res) {
648
+ this.emit('error', error ? error : new Error('加入房间失败:未知异常。'));
652
649
  this.joined = false;
653
650
  }
651
+ else {
652
+ if (res.code === exports.RTCJoinedInfoCodeEnum.Success) {
653
+ this.emit('joined');
654
+ this.joined = true;
655
+ }
656
+ else {
657
+ this.emit('error', res);
658
+ this.joined = false;
659
+ }
660
+ }
661
+ return this.joined;
662
+ }
663
+ catch (e) {
664
+ this.emit('error', new Error('加入房间失败:' + e.message));
665
+ this.joined = false;
666
+ return this.joined;
654
667
  }
655
- return this.joined;
656
668
  });
657
669
  }
658
670
  quit() {
@@ -1466,7 +1478,10 @@ class LiveController extends Subscribe {
1466
1478
  /**
1467
1479
  * ws代理器
1468
1480
  */
1469
- this._ws = new RobustWebSocket();
1481
+ this._ws = new RobustWebSocket({
1482
+ url: '',
1483
+ robustOptions: { timeout: 180000 },
1484
+ });
1470
1485
  /**
1471
1486
  * 带看连接状态
1472
1487
  */
@@ -1869,6 +1884,13 @@ class Live extends Subscribe {
1869
1884
  return false;
1870
1885
  }
1871
1886
  const { force = false } = options;
1887
+ // 检测一下麦克风权限,hack
1888
+ if (this._options.rtc && this._options.jsBridge) {
1889
+ const res = yield this._options.jsBridge.detectMicro();
1890
+ if (!res) {
1891
+ return new Error('Failed to obtain microphone authorization');
1892
+ }
1893
+ }
1872
1894
  // 检查是否已有实例在使用
1873
1895
  const currentState = this.state;
1874
1896
  if (currentState === exports.LiveState.CONNECTING ||