@rongcloud/plugin-rtc 5.3.0-rtc-roompk.1 → 5.3.2-alpha.1

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.
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * RCRTC - v5.3.0-rtc-roompk.1
3
- * CommitId - 381b45b74bd1cee88cf1e6e79108809734bb17ea
4
- * Sat Dec 25 2021 01:21:26 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.3.2-alpha.1
3
+ * CommitId - db999e233480c8537357ef17495b0bbb67c692fe
4
+ * Mon Feb 14 2022 20:24:02 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
7
  import { Logger, EventEmitter, isNumber, ErrorCode, ConnectionStatus, assert, ConversationType, RTCApiType, validate, isArray, RTCMode, isHttpUrl, notEmptyString, isBoolean, isUndefined, HttpMethod, isString, RTCJoinType, RTCIdentityChangeType, VersionManage } from '@rongcloud/engine';
@@ -6429,12 +6429,21 @@ const calcTracksNum = (tracks) => {
6429
6429
  /**
6430
6430
  * 解析房间数据
6431
6431
  */
6432
- const parseRoomData = (data) => {
6432
+ const parseRoomData = (data, mainRoomId) => {
6433
6433
  const result = {};
6434
6434
  const userIds = Object.keys(data.users);
6435
6435
  userIds.length && userIds.forEach(userId => {
6436
6436
  const tmp = [];
6437
6437
  const userData = data.users[userId];
6438
+ /**
6439
+ * 过滤掉副房间身份的人员
6440
+ */
6441
+ if (userData.extra) {
6442
+ const roomId = JSON.parse(userData.extra).roomId;
6443
+ if (mainRoomId !== roomId) {
6444
+ return;
6445
+ }
6446
+ }
6438
6447
  if (userData.uris) {
6439
6448
  try {
6440
6449
  tmp.push(...JSON.parse(userData.uris));
@@ -6447,16 +6456,31 @@ const parseRoomData = (data) => {
6447
6456
  });
6448
6457
  return result;
6449
6458
  };
6459
+ /**
6460
+ * 从加房间返回的数据中获取加入的副房间
6461
+ */
6462
+ const getPKInfoByRoomData = (mainRoomId, roomInfo) => {
6463
+ const pkInfo = {};
6464
+ roomInfo.forEach((item) => {
6465
+ const PKValue = JSON.parse(item.value);
6466
+ const { inviterRoomId, inviteeRoomId } = PKValue;
6467
+ const roomId = (mainRoomId === inviterRoomId) ? inviteeRoomId : inviterRoomId;
6468
+ pkInfo[roomId] = JSON.parse(item.value);
6469
+ });
6470
+ return pkInfo;
6471
+ };
6450
6472
  /**
6451
6473
  * 解析观众加房间 kv 数据
6452
6474
  * 远端无人员时,kvEntries 的 key 不包含 RC_ANCHOR_LIST
6453
6475
  * 远端无资源时,key 不包含 RC_RES_、RC_CDN
6454
6476
  * 远端有资源、无 CDN 资源时,key 不包含 RC_CDN
6477
+ * 服务端 bug,偶现无 RC_RTC_SESSIONID
6455
6478
  */
6456
6479
  const parseAudienceRoomData = (roomId, kvEntries) => {
6457
- const sessionId = kvEntries.filter((kvItem) => {
6480
+ const session = kvEntries.filter((kvItem) => {
6458
6481
  return kvItem.key === 'RC_RTC_SESSIONID';
6459
- })[0].value;
6482
+ })[0];
6483
+ const sessionId = session ? session.value : '';
6460
6484
  /**
6461
6485
  * 房间内远端人员
6462
6486
  */
@@ -8459,7 +8483,7 @@ class PolarisReporter {
8459
8483
  * 加入房间
8460
8484
  */
8461
8485
  sendR1() {
8462
- const rtcVersion = "5.3.0-rtc-roompk.1";
8486
+ const rtcVersion = "5.3.2-alpha.1";
8463
8487
  const imVersion = this._context.getCoreVersion();
8464
8488
  const platform = 'web';
8465
8489
  const pcName = navigator.platform;
@@ -8607,6 +8631,9 @@ class RCAbstractRoom {
8607
8631
  // 资源、人员变更消息需按队列逐个处理,确保内存状态不乱
8608
8632
  this.msgTaskQueue = new AsyncTaskQueue();
8609
8633
  this._appListener = null;
8634
+ /**
8635
+ * 存储连麦监听事件
8636
+ */
8610
8637
  this._onRecvPKMsg = null;
8611
8638
  this._token = data.token;
8612
8639
  this._sessionId = data.sessionId;
@@ -8619,7 +8646,7 @@ class RCAbstractRoom {
8619
8646
  this._roomResources = {};
8620
8647
  }
8621
8648
  else {
8622
- this._roomResources = parseRoomData(data);
8649
+ this._roomResources = parseRoomData(data, this._roomId);
8623
8650
  }
8624
8651
  // 根据解析出来的数据构建远端流
8625
8652
  this._initRemoteTracks();
@@ -8830,7 +8857,8 @@ class RCAbstractRoom {
8830
8857
  return;
8831
8858
  }
8832
8859
  const { uris, ignore } = content;
8833
- if (ignore) {
8860
+ // 内置 CDN 为自动时,先收到 cdn_uris,无 uris 时,不用再对比资源
8861
+ if (ignore || !uris) {
8834
8862
  return;
8835
8863
  }
8836
8864
  const publishedList = [];
@@ -8941,6 +8969,20 @@ class RCAbstractRoom {
8941
8969
  if (users.length === 0) {
8942
8970
  return;
8943
8971
  }
8972
+ /**
8973
+ * 过滤掉副房间身份的人员
8974
+ */
8975
+ for (let index = 0; index < users.length; index++) {
8976
+ const user = users[index];
8977
+ // 加入房间时
8978
+ if (user.extra && user.extra.roomId !== this._roomId) {
8979
+ return;
8980
+ }
8981
+ // 退出房间时
8982
+ if (+user.state === 1 && !this.getRemoteUserIds().includes(user.userId)) {
8983
+ return;
8984
+ }
8985
+ }
8944
8986
  /**
8945
8987
  * 主动加入房间
8946
8988
  */
@@ -9184,14 +9226,14 @@ class RCAbstractRoom {
9184
9226
  if (quitRoom) {
9185
9227
  // 退出 signal 房间
9186
9228
  yield this._context.quitRTCRoom(this._roomId);
9187
- // 退出主房间时,退出所有 PK 房间
9188
- this._isMainRoom && this._quitPKRoom();
9189
9229
  }
9230
+ // 退出主房间时,退出所有 PK 房间
9231
+ this._isMainRoom && this._quitAllPKRoom();
9190
9232
  this._pc.removeAllLocalTrack();
9191
9233
  // 停止 rtcPing 计时
9192
9234
  this._pinger.stop();
9193
- // 中断与 MediaServer 的 UDP 连接
9194
- yield this._service.exit(this._getRTCReqestHeaders());
9235
+ // 退出主房间时,中断与 MediaServer 的 UDP 连接
9236
+ this._isMainRoom && (yield this._service.exit(this._getRTCReqestHeaders()));
9195
9237
  // 销毁 pc 连接
9196
9238
  this._pc.destroy();
9197
9239
  // 销毁 polarisReport 实例
@@ -9268,6 +9310,10 @@ class RCAbstractRoom {
9268
9310
  }
9269
9311
  __publish(tracks) {
9270
9312
  return __awaiter(this, void 0, void 0, function* () {
9313
+ if (!this._isMainRoom && (this instanceof RCLivingRoom)) {
9314
+ logger.error('the `publish` is disabled in PK room ');
9315
+ return { code: RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM };
9316
+ }
9271
9317
  const roomStatusCode = this._assertRoomDestroyed();
9272
9318
  if (roomStatusCode) {
9273
9319
  logger.error(`publish failed, room has been destroyed. -> roomId: ${this._roomId}`);
@@ -9322,23 +9368,8 @@ class RCAbstractRoom {
9322
9368
  /**
9323
9369
  * 直播房间需携带 pushOtherRooms 信息
9324
9370
  */
9325
- if (this instanceof RCLivingRoom) {
9326
- const { code, roomPKHandler } = this.getRoomPKHandler();
9327
- if (code === RCRTCCode.SUCCESS && roomPKHandler) {
9328
- const joinedPKRooms = roomPKHandler.getJoinedPKRooms();
9329
- reqBody.pushOtherRooms = [];
9330
- for (const roomId in joinedPKRooms) {
9331
- const room = joinedPKRooms[roomId];
9332
- const sessionId = room.getSessionId();
9333
- const { inviterUserAutoMix: autoMix } = roomPKHandler.getPKInfo(roomId);
9334
- reqBody.pushOtherRooms.push({
9335
- roomId,
9336
- sessionId,
9337
- autoMix: autoMix
9338
- });
9339
- }
9340
- }
9341
- }
9371
+ const pushOtherRooms = this._getPushOtherRoomsParams();
9372
+ pushOtherRooms && (reqBody.pushOtherRooms = pushOtherRooms);
9342
9373
  const resp = yield this._exchangeHandle(reqBody);
9343
9374
  if (resp.code !== RCRTCCode.SUCCESS) {
9344
9375
  // TODO: 资源发送失败,需要移除已添加至 RTCPeerConnection 中的资源信息
@@ -9393,6 +9424,37 @@ class RCAbstractRoom {
9393
9424
  return { code: RCRTCCode.SUCCESS };
9394
9425
  });
9395
9426
  }
9427
+ /**
9428
+ * 获取跨房间连麦需携带参数 pushOtherRooms 的值
9429
+ */
9430
+ _getPushOtherRoomsParams() {
9431
+ if (this instanceof RCLivingRoom) {
9432
+ const { code, roomPKHandler } = this.getRoomPKHandler();
9433
+ const pushOtherRooms = [];
9434
+ if (code === RCRTCCode.SUCCESS && roomPKHandler) {
9435
+ const joinedPKRooms = roomPKHandler.getJoinedPKRooms();
9436
+ for (const roomId in joinedPKRooms) {
9437
+ const room = joinedPKRooms[roomId];
9438
+ const sessionId = room.getSessionId();
9439
+ /**
9440
+ * 直接加入 PK 房间,无连麦关系时,无 PKInfo 信息
9441
+ */
9442
+ const PKInfo = roomPKHandler.getPKInfo(roomId);
9443
+ if (!PKInfo) {
9444
+ return;
9445
+ }
9446
+ const { inviterUserAutoMix, inviteeUserAutoMix, inviterUserId } = PKInfo;
9447
+ const isInviter = (this._context.getCurrentId() === inviterUserId);
9448
+ pushOtherRooms.push({
9449
+ roomId,
9450
+ sessionId,
9451
+ autoMix: isInviter ? !!inviterUserAutoMix : !!inviteeUserAutoMix
9452
+ });
9453
+ }
9454
+ }
9455
+ return pushOtherRooms;
9456
+ }
9457
+ }
9396
9458
  /**
9397
9459
  * ice 断线后,尝试重新走 exchange
9398
9460
  */
@@ -9400,6 +9462,11 @@ class RCAbstractRoom {
9400
9462
  return __awaiter(this, void 0, void 0, function* () {
9401
9463
  push(() => __awaiter(this, void 0, void 0, function* () {
9402
9464
  const reqBody = yield this._createExchangeParams(this._subscribedList, true);
9465
+ /**
9466
+ * 直播房间需携带 pushOtherRooms 信息
9467
+ */
9468
+ const pushOtherRooms = this._getPushOtherRoomsParams();
9469
+ pushOtherRooms && (reqBody.pushOtherRooms = pushOtherRooms);
9403
9470
  // 发送 /exchange 请求
9404
9471
  const resp = yield this._exchangeHandle(reqBody);
9405
9472
  if (resp.code !== RCRTCCode.SUCCESS) {
@@ -9484,6 +9551,10 @@ class RCAbstractRoom {
9484
9551
  __unpublish(tracks) {
9485
9552
  var _a;
9486
9553
  return __awaiter(this, void 0, void 0, function* () {
9554
+ if (!this._isMainRoom && (this instanceof RCLivingRoom)) {
9555
+ logger.error('the `unpublish` is disabled in PK room ');
9556
+ return { code: RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM };
9557
+ }
9487
9558
  const roomStatusCode = this._assertRoomDestroyed();
9488
9559
  if (roomStatusCode) {
9489
9560
  logger.warn(`room has been destroyed, no need to unpublish tracks -> roomId: ${this._roomId}`);
@@ -9514,6 +9585,11 @@ class RCAbstractRoom {
9514
9585
  // 客户端主动调用 api 发请求时,清除 ice 断线重连的定时器
9515
9586
  this._pc.clearReTryExchangeTimer();
9516
9587
  const reqBody = yield this._createExchangeParams(this._subscribedList, false);
9588
+ /**
9589
+ * 直播房间需携带 pushOtherRooms 信息
9590
+ */
9591
+ const pushOtherRooms = this._getPushOtherRoomsParams();
9592
+ pushOtherRooms && (reqBody.pushOtherRooms = pushOtherRooms);
9517
9593
  const result = yield this._exchangeHandle(reqBody);
9518
9594
  if (result.code !== RCRTCCode.SUCCESS) {
9519
9595
  logger.error(`exchange failed -> code: ${result.code}`);
@@ -9747,6 +9823,11 @@ class RCAbstractRoom {
9747
9823
  this._pc.clearReTryExchangeTimer();
9748
9824
  this._pc.updateSubRemoteTracks(attrs.map(item => item.track));
9749
9825
  const reqBody = yield this._createExchangeParams(attrs, false);
9826
+ /**
9827
+ * 直播房间需携带 pushOtherRooms 信息
9828
+ */
9829
+ const pushOtherRooms = this._getPushOtherRoomsParams();
9830
+ pushOtherRooms && (reqBody.pushOtherRooms = pushOtherRooms);
9750
9831
  const result = yield this._exchangeHandle(reqBody);
9751
9832
  const subTrackIds = attrs.map((item) => { return item.track.getTrackId(); });
9752
9833
  if (result.code !== RCRTCCode.SUCCESS) {
@@ -9832,7 +9913,7 @@ class RCAbstractRoom {
9832
9913
  // 状态变更的资源
9833
9914
  const modified = {};
9834
9915
  // 当前最新的房间资源数据
9835
- const roomData = parseRoomData(data);
9916
+ const roomData = parseRoomData(data, this._roomId);
9836
9917
  const nowUserIds = Object.keys(roomData);
9837
9918
  const prevUserIds = Object.keys(this._roomResources);
9838
9919
  for (let i = nowUserIds.length - 1; i >= 0; i -= 1) {
@@ -9937,7 +10018,7 @@ class RCAbstractRoom {
9937
10018
  /**
9938
10019
  * 退出 PK 房间
9939
10020
  */
9940
- _quitPKRoom() { }
10021
+ _quitAllPKRoom() { }
9941
10022
  }
9942
10023
 
9943
10024
  /**
@@ -10493,7 +10574,7 @@ const parseNaviInfo = (info) => {
10493
10574
  };
10494
10575
 
10495
10576
  class RCLivingPKHandler {
10496
- constructor(_context, _runtime, _service, _initOptions,
10577
+ constructor(_PKInfo, _context, _runtime, _service, _initOptions,
10497
10578
  /**
10498
10579
  * 主直播房间
10499
10580
  */
@@ -10506,6 +10587,7 @@ class RCLivingPKHandler {
10506
10587
  * 退出 PK 房间回调
10507
10588
  */
10508
10589
  _onLeavePKRoom) {
10590
+ this._PKInfo = _PKInfo;
10509
10591
  this._context = _context;
10510
10592
  this._runtime = _runtime;
10511
10593
  this._service = _service;
@@ -10515,13 +10597,13 @@ class RCLivingPKHandler {
10515
10597
  this._onJoinedPKRoom = _onJoinedPKRoom;
10516
10598
  this._onLeavePKRoom = _onLeavePKRoom;
10517
10599
  /**
10518
- * PK 邀请超时时间
10600
+ * PK 邀请超时时间,默认 30s
10519
10601
  */
10520
- this._inviteTimeout = 30 * 1000;
10602
+ this._inviteTimeout = 30;
10521
10603
  /**
10522
10604
  * PK 房间信息
10523
10605
  */
10524
- this._PKInfo = {};
10606
+ // private _PKInfo: IPKInfo = {}
10525
10607
  this._appListener = null;
10526
10608
  /**
10527
10609
  * 跨房间连麦加入的 PK 房间
@@ -10543,6 +10625,9 @@ class RCLivingPKHandler {
10543
10625
  logger.error(error);
10544
10626
  }
10545
10627
  }
10628
+ /**
10629
+ * 收到连麦邀请
10630
+ */
10546
10631
  _onInvite(content) {
10547
10632
  const inviteInfo = (content.inviteInfo || {});
10548
10633
  const { inviterRoomId, inviterUserId, extra } = inviteInfo;
@@ -10554,6 +10639,9 @@ class RCLivingPKHandler {
10554
10639
  this._PKInfo[inviterRoomId] = inviteInfo;
10555
10640
  this._callAppListener('onRequestJoinOtherRoom', info);
10556
10641
  }
10642
+ /**
10643
+ * 收到取消连麦
10644
+ */
10557
10645
  _onCancelInvite(content) {
10558
10646
  const { inviterRoomId, inviterUserId, extra } = (content.inviteInfo || {});
10559
10647
  const cancelInfo = {
@@ -10567,9 +10655,12 @@ class RCLivingPKHandler {
10567
10655
  _onInviteTimeout(content) {
10568
10656
  // 因服务计时不准,暂不处理。(与移动端一致)
10569
10657
  }
10658
+ /**
10659
+ * 收到响应连麦
10660
+ */
10570
10661
  _onInviteAnswer(content) {
10571
- const { answerCode, inviteSessionId, inviteContent, inviteeUserAutoMix } = content;
10572
- const { inviterUserId, inviterRoomId, inviteeUserId, inviteeRoomId, extra } = inviteContent;
10662
+ const { answerCode, inviteContent } = content;
10663
+ const { inviteSessionId, inviterUserId, inviterRoomId, inviteeUserId, inviterUserAutoMix, inviteeUserAutoMix, inviteeRoomId, extra } = inviteContent;
10573
10664
  const answerInfo = {
10574
10665
  agree: answerCode === 1,
10575
10666
  inviterRoomId,
@@ -10577,19 +10668,35 @@ class RCLivingPKHandler {
10577
10668
  inviteeRoomId,
10578
10669
  inviteeUserId
10579
10670
  };
10671
+ /**
10672
+ * 收到非本人发起的邀请连麦时,需新组装 PKInfo
10673
+ */
10674
+ this._PKInfo[inviteeRoomId] = this._PKInfo[inviteeRoomId] || {
10675
+ inviteSessionId,
10676
+ inviterRoomId,
10677
+ inviterUserId,
10678
+ inviterUserAutoMix,
10679
+ inviteeRoomId
10680
+ };
10580
10681
  this._PKInfo[inviteeRoomId].inviteeUserAutoMix = inviteeUserAutoMix;
10581
10682
  this._callAppListener('onResponseJoinOtherRoom', answerInfo);
10582
10683
  }
10684
+ /**
10685
+ * 收到连麦结束
10686
+ */
10583
10687
  _onPKEnd(content) {
10584
- const { inviteeRoomId, inviterRoomId, userId } = content.inviteInfo;
10585
- const endInfo = {
10586
- endRoomId: inviteeRoomId,
10587
- endUserId: userId
10588
- };
10589
- const roomId = inviterRoomId === this._mainRoomId ? inviteeRoomId : inviterRoomId;
10590
- this.leaveOtherRoom(this._joinedPKRooms[roomId]);
10591
- delete this._PKInfo[roomId];
10592
- this._callAppListener('onFinishOtherRoom', endInfo);
10688
+ return __awaiter(this, void 0, void 0, function* () {
10689
+ const { inviteeRoomId, inviterRoomId, userId } = content.inviteInfo;
10690
+ const roomId = inviterRoomId === this._mainRoomId ? inviteeRoomId : inviterRoomId;
10691
+ const endInfo = {
10692
+ endRoomId: roomId,
10693
+ endUserId: userId
10694
+ };
10695
+ // 兼容先退出房间,再收到 pk 结束的情况
10696
+ this._joinedPKRooms[roomId] && (yield this.leaveOtherRoom(this._joinedPKRooms[roomId]));
10697
+ delete this._PKInfo[roomId];
10698
+ this._callAppListener('onFinishOtherRoom', endInfo);
10699
+ });
10593
10700
  }
10594
10701
  /**
10595
10702
  * 处理跨房间连麦相关消息
@@ -10615,17 +10722,17 @@ class RCLivingPKHandler {
10615
10722
  }
10616
10723
  }
10617
10724
  /**
10618
- * 跨房间连麦 PK 事件注册
10725
+ * 注册跨房间连麦监听事件
10619
10726
  */
10620
10727
  registerRoomPKEventListener(listener) {
10621
10728
  this._appListener = listener;
10622
10729
  }
10623
10730
  /**
10624
10731
  * 发起跨房间连麦请求
10625
- * @param inviteeRoomId 被邀请者所处的房间 ID
10626
- * @param inviteeUserId 被邀请者 ID
10627
- * @param options.autoMix 被邀请者的发布的资源在服务侧是否自动合流
10628
- * @param options.extra 拓展字段,用于邀请数据透传
10732
+ * @param inviteeRoomId 被邀请者所处的房间 roomId
10733
+ * @param inviteeUserId 被邀请者 userId
10734
+ * @param options.autoMix 是否要把邀请者发布的资源,合并到被邀请者房间内的 MCU 流中
10735
+ * @param options.extra 拓展字段,可随邀请连麦消息透传给被邀请者
10629
10736
  */
10630
10737
  requestJoinOtherRoom(inviteeRoomId, inviteeUserId, options) {
10631
10738
  return __awaiter(this, void 0, void 0, function* () {
@@ -10636,13 +10743,6 @@ class RCLivingPKHandler {
10636
10743
  logger.debug(`requestRoomPK -> inviteeRoomId: ${inviteeRoomId}; inviteeUserId: ${inviteeUserId}; options: ${JSON.stringify(options || {})}`);
10637
10744
  const inviteSessionId = getUUID();
10638
10745
  const autoMix = isBoolean(options === null || options === void 0 ? void 0 : options.autoMix) ? options === null || options === void 0 ? void 0 : options.autoMix : true;
10639
- this._PKInfo[inviteeRoomId] = {
10640
- inviteSessionId,
10641
- inviterRoomId: this._mainRoomId,
10642
- inviterUserId: this._context.getCurrentId(),
10643
- inviterUserAutoMix: autoMix,
10644
- inviteeRoomId
10645
- };
10646
10746
  const inviteInfo = {
10647
10747
  inviteSessionId,
10648
10748
  inviterRoomId: this._mainRoomId,
@@ -10665,13 +10765,24 @@ class RCLivingPKHandler {
10665
10765
  const code = yield this._context.requestRoomPK(params);
10666
10766
  if (code !== ErrorCode.SUCCESS) {
10667
10767
  logger.error(`requestRoomPK failed: ${code}`);
10668
- return { code: RCRTCCode.SIGNAL_ERROR };
10768
+ return { code };
10669
10769
  }
10770
+ logger.debug('requestRoomPK success');
10771
+ this._PKInfo[inviteeRoomId] = {
10772
+ inviteSessionId,
10773
+ inviterRoomId: this._mainRoomId,
10774
+ inviterUserId: this._context.getCurrentId(),
10775
+ inviterUserAutoMix: autoMix,
10776
+ inviteeRoomId
10777
+ };
10670
10778
  return { code: RCRTCCode.SUCCESS };
10671
10779
  });
10672
10780
  }
10673
10781
  /**
10674
- * 取消跨房间连麦 PK 请求
10782
+ * 取消跨房间连麦请求
10783
+ * @param inviteeRoomId 被邀请者所处的房间 roomId
10784
+ * @param inviteeUserId 被邀请者 userId
10785
+ * @param extra 附加信息,可随取消邀请连麦消息透传给被邀请者
10675
10786
  */
10676
10787
  cancelRequestJoinOtherRoom(inviteeRoomId, inviteeUserId, extra) {
10677
10788
  return __awaiter(this, void 0, void 0, function* () {
@@ -10679,6 +10790,10 @@ class RCLivingPKHandler {
10679
10790
  validate('inviteeUserId', inviteeUserId, notEmptyString, true))) {
10680
10791
  return { code: RCRTCCode.PARAMS_ERROR };
10681
10792
  }
10793
+ if (!this._PKInfo[inviteeRoomId]) {
10794
+ logger.error(`未发起过与 ${inviteeRoomId} 房间内 ${inviteeUserId} 连麦的请求`);
10795
+ return { code: RCRTCCode.PARAMS_ERROR };
10796
+ }
10682
10797
  logger.debug(`canceRequestJoinPK -> inviteeRoomId: ${inviteeRoomId}; inviteeUserId: ${inviteeUserId}; extra: ${extra}`);
10683
10798
  const inviteInfo = {
10684
10799
  inviterRoomId: this._mainRoomId,
@@ -10698,13 +10813,20 @@ class RCLivingPKHandler {
10698
10813
  const code = yield this._context.cancelRoomPK(params);
10699
10814
  if (code !== ErrorCode.SUCCESS) {
10700
10815
  logger.error(`canceRequestJoinPK failed: ${code}`);
10701
- return { code: RCRTCCode.SIGNAL_ERROR };
10816
+ return { code };
10702
10817
  }
10818
+ logger.debug('canceRequestJoinPK success');
10819
+ delete this._PKInfo[inviteeRoomId];
10703
10820
  return { code: RCRTCCode.SUCCESS };
10704
10821
  });
10705
10822
  }
10706
10823
  /**
10707
- * 跨房间连麦 PK 响应
10824
+ * 响应跨房间连麦请求
10825
+ * @param inviterRoomId 邀请者所处的房间 roomId
10826
+ * @param inviterUserId 邀请者 userId
10827
+ * @param agree 是否同意连麦
10828
+ * @param options.autoMix 是否要把被邀请者发布的资源,合并到邀请者房间内的 MCU 流中
10829
+ * @param options.extra 附加信息,可随响应连麦消息透传给邀请者
10708
10830
  */
10709
10831
  responseJoinOtherRoom(inviterRoomId, inviterUserId, agree, options) {
10710
10832
  return __awaiter(this, void 0, void 0, function* () {
@@ -10712,6 +10834,10 @@ class RCLivingPKHandler {
10712
10834
  validate('inviterUserId', inviterUserId, notEmptyString, true))) {
10713
10835
  return { code: RCRTCCode.PARAMS_ERROR };
10714
10836
  }
10837
+ if (!this._PKInfo[inviterRoomId]) {
10838
+ logger.error(`${inviterRoomId} 房间内的 ${inviterUserId} 未发起过连麦请求`);
10839
+ return { code: RCRTCCode.PARAMS_ERROR };
10840
+ }
10715
10841
  logger.debug(`responseRoomPK -> inviterRoomId: ${inviterRoomId}; inviterUserId: ${inviterUserId}; agree: ${agree}; options: ${JSON.stringify(options || {})}`);
10716
10842
  const { inviteSessionId, inviterUserAutoMix } = this._PKInfo[inviterRoomId];
10717
10843
  const autoMix = isBoolean(options === null || options === void 0 ? void 0 : options.autoMix) ? options === null || options === void 0 ? void 0 : options.autoMix : true;
@@ -10719,6 +10845,7 @@ class RCLivingPKHandler {
10719
10845
  inviteSessionId,
10720
10846
  inviterRoomId,
10721
10847
  inviterUserId,
10848
+ inviterUserAutoMix,
10722
10849
  inviteeRoomId: this._mainRoomId,
10723
10850
  inviteeUserId: this._context.getCurrentId(),
10724
10851
  inviteeUserAutoMix: autoMix
@@ -10736,28 +10863,26 @@ class RCLivingPKHandler {
10736
10863
  inviteRoomId: inviterRoomId,
10737
10864
  inviteUserId: inviterUserId,
10738
10865
  content: JSON.stringify(content),
10739
- key: `${inviterRoomId}|${inviterUserId}`,
10866
+ key: `${inviterRoomId}|${this._mainRoomId}`,
10740
10867
  value: JSON.stringify(value)
10741
10868
  };
10742
10869
  logger.debug(`responseRoomPK -> params: ${JSON.stringify(params)}`);
10743
10870
  const code = yield this._context.responseRoomPK(params);
10744
10871
  if (code !== ErrorCode.SUCCESS) {
10745
10872
  logger.error(`responseRoomPK failed: ${code}`);
10746
- return { code: RCRTCCode.SIGNAL_ERROR };
10873
+ return { code };
10747
10874
  }
10875
+ logger.debug('responseRoomPK success');
10876
+ this._PKInfo[inviterRoomId].inviteeUserAutoMix = autoMix;
10748
10877
  return { code: RCRTCCode.SUCCESS };
10749
10878
  });
10750
10879
  }
10751
10880
  /**
10752
- * 结束跨房间连麦 PK
10753
- * @param roomId 需要退出 PK 的房间 ID
10881
+ * 结束跨房间连麦
10882
+ * @param roomId 需要结束连麦的房间 roomId
10754
10883
  */
10755
10884
  _quitRoomPK(roomId) {
10756
10885
  return __awaiter(this, void 0, void 0, function* () {
10757
- if (!(validate('roomId', roomId, notEmptyString, true))) {
10758
- return { code: RCRTCCode.PARAMS_ERROR };
10759
- }
10760
- logger.debug(`quitRoomPK -> roomId: ${roomId}`);
10761
10886
  const { inviterRoomId, inviteeRoomId, inviterUserId } = this._PKInfo[roomId];
10762
10887
  const content = {
10763
10888
  inviteeRoomId,
@@ -10777,13 +10902,15 @@ class RCLivingPKHandler {
10777
10902
  logger.error(`quitRoomPK failed: ${code}`);
10778
10903
  return { code: RCRTCCode.SIGNAL_ERROR };
10779
10904
  }
10905
+ logger.debug('quitRoomPK success');
10906
+ delete this._PKInfo[roomId];
10780
10907
  return { code: RCRTCCode.SUCCESS };
10781
10908
  });
10782
10909
  }
10783
10910
  _relaseCrtRoom() { }
10784
10911
  /**
10785
- * 加入 PK 直播房间
10786
- * @roomId PK 房间 ID
10912
+ * 加入副直播房间
10913
+ * @roomId 副房间的 roomId
10787
10914
  */
10788
10915
  joinOtherRoom(roomId) {
10789
10916
  return __awaiter(this, void 0, void 0, function* () {
@@ -10793,11 +10920,19 @@ class RCLivingPKHandler {
10793
10920
  if (this._context.getConnectionStatus() !== ConnectionStatus.CONNECTED) {
10794
10921
  return { code: RCRTCCode.SIGNAL_DISCONNECTED };
10795
10922
  }
10796
- logger.debug(`joinPKRoom, roomId: ${roomId}`);
10923
+ logger.debug(`JoinPKRoom, roomId: ${roomId}`);
10924
+ if (this._joinedPKRooms[roomId]) {
10925
+ return { code: RCRTCCode.REPERT_JOIN_ROOM };
10926
+ }
10797
10927
  const livingType = RCLivingType.VIDEO; // signal 不处理 livingType 故写死 RCLivingType.VIDEO
10798
- const { code, data } = yield this._context.joinRTCRoom(roomId, RTCMode.LIVE, livingType);
10928
+ // 加入副房间时,携带主房间 Id,用于在房间内区分人员身份
10929
+ const extraUserData = {
10930
+ key: 'extra',
10931
+ value: `{"roomId": "${this._mainRoomId}"}`
10932
+ };
10933
+ const { code, data } = yield this._context.joinRTCRoom(roomId, RTCMode.LIVE, livingType, undefined, extraUserData);
10799
10934
  if (code !== ErrorCode.SUCCESS) {
10800
- logger.error(`joinRoom failed -> code: ${code}`);
10935
+ logger.error(`JoinPKRoom failed -> code: ${code}`);
10801
10936
  return { code: code };
10802
10937
  }
10803
10938
  logger.debug(`JoinPKRoom success -> userId: ${this._context.getCurrentId()}, roomId: ${roomId}, data: ${JSON.stringify(data)}`);
@@ -10805,45 +10940,47 @@ class RCLivingPKHandler {
10805
10940
  // 回调主直播房间,已加入 PK 房间
10806
10941
  this._joinedPKRooms[roomId] = room;
10807
10942
  this._onJoinedPKRoom(roomId, room);
10808
- const joinLivingResData = { room, code: RCRTCCode.SUCCESS, userIds: room.getRemoteUserIds(), tracks: room.getRemoteTracks() };
10809
- // 手动模式时,用户加入房间,需返回 CDN 开关状态
10810
- if (room.__getCDNPushMode() === RCInnerCDNPushMode.MANUAL) {
10811
- Object.assign(joinLivingResData, { CDNEnable: room.__getCDNEnable() });
10812
- }
10813
- return joinLivingResData;
10943
+ return { room, code: RCRTCCode.SUCCESS, userIds: room.getRemoteUserIds(), tracks: room.getRemoteTracks() };
10814
10944
  });
10815
10945
  }
10816
10946
  /**
10817
- * 退出 PK 直播房间房间
10818
- * @param room 要离开的 PK 房间 room 实例
10947
+ * 退出副房间
10948
+ * @param room 要退出的副房间的 room 实例
10949
+ * @param isQuitPK 是否要结束连麦
10819
10950
  */
10820
10951
  leaveOtherRoom(room, isQuitPK) {
10821
10952
  return __awaiter(this, void 0, void 0, function* () {
10822
10953
  return push(() => __awaiter(this, void 0, void 0, function* () {
10823
10954
  const roomId = room.getRoomId();
10955
+ logger.debug(`leavePKRoom -> userId: ${this._context.getCurrentId()} , roomId: ${roomId}`);
10956
+ yield room.__destroy(true);
10957
+ // 回调主直播房间离开 PK 房间
10958
+ delete this._joinedPKRooms[roomId];
10959
+ this._onLeavePKRoom(roomId);
10824
10960
  if (!this._PKInfo[roomId]) {
10825
10961
  return { code: RCRTCCode.SUCCESS };
10826
10962
  }
10827
10963
  // isQuitPK 为 true 时,结束连麦
10828
10964
  isQuitPK && this._quitRoomPK(roomId);
10829
- yield room.__destroy(true);
10830
- logger.debug(`leavePKRoom -> userId: ${this._context.getCurrentId()} , roomId: ${roomId}`);
10831
- // 回调主直播房间离开 PK 房间
10832
- delete this._joinedPKRooms[roomId];
10833
- this._onLeavePKRoom(roomId);
10834
- delete this._PKInfo[roomId];
10835
10965
  return { code: RCRTCCode.SUCCESS };
10836
10966
  }));
10837
10967
  });
10838
10968
  }
10839
10969
  /**
10840
- * 获取 _PKInfo
10970
+ * 获取连麦信息
10971
+ * @param roomId 连麦房间的 roomId
10841
10972
  */
10842
10973
  getPKInfo(roomId) {
10843
10974
  return this._PKInfo[roomId];
10844
10975
  }
10845
10976
  /**
10846
- * 获取已加入的 PK 房间
10977
+ * 获取所有连麦信息
10978
+ */
10979
+ getAllPKInfo() {
10980
+ return this._PKInfo;
10981
+ }
10982
+ /**
10983
+ * 获取已加入的副房间
10847
10984
  */
10848
10985
  getJoinedPKRooms() {
10849
10986
  return this._joinedPKRooms;
@@ -10872,11 +11009,43 @@ class RCLivingRoom extends RCAbstractRoom {
10872
11009
  this._mcuConfigBuilder = new RCMCUConfigBuilder(this._onMCUConfigFlush.bind(this), this._isValidResourceId.bind(this), this._sendCDNInfoSignal.bind(this));
10873
11010
  // 初始化 RCLivingPKHandler
10874
11011
  if (this._isMainRoom) {
10875
- this._roomPKHandler = new RCLivingPKHandler(context, runtime, service, initOptions, this, super._registerPKMsgListener.bind(this), this._onJoinedPKRoom.bind(this), this._onLeavePKRoom.bind(this));
11012
+ const PKInfo = getPKInfoByRoomData(this._roomId, data.roomInfo);
11013
+ this._roomPKHandler = new RCLivingPKHandler(PKInfo, context, runtime, service, initOptions, this, super._registerPKMsgListener.bind(this), this._onJoinedPKRoom.bind(this), this._onLeavePKRoom.bind(this));
10876
11014
  }
10877
11015
  const CDNUris = (_a = data.roomInfo.filter((item) => { return item.key === 'cdn_uris'; })[0]) === null || _a === void 0 ? void 0 : _a.value;
10878
11016
  CDNUris && (this._CDNUris = JSON.parse(CDNUris)[0]);
10879
11017
  }
11018
+ /**
11019
+ * resourceId 有效性验证
11020
+ * @param resourceId
11021
+ */
11022
+ _isValidResourceId(resourceId) {
11023
+ var _a;
11024
+ const { userId } = parseTrackId(resourceId);
11025
+ // 是否是主房间资源
11026
+ const isHostRoomResource = !!((_a = this._roomResources[userId]) === null || _a === void 0 ? void 0 : _a.find(item => getTrackId(item) === resourceId));
11027
+ // 是否是主房间资源
11028
+ let isPKRoomResource = false;
11029
+ /**
11030
+ * 无副房间时,只验证是否为主房间资源
11031
+ */
11032
+ const { code, roomPKHandler } = this.getRoomPKHandler();
11033
+ if (code !== RCRTCCode.SUCCESS || !roomPKHandler) {
11034
+ return isHostRoomResource;
11035
+ }
11036
+ /**
11037
+ * 有副房间时,需验证是否为主房间或副房间资源
11038
+ */
11039
+ const joinedPKRooms = roomPKHandler.getJoinedPKRooms();
11040
+ const PKRoomRemoteTracks = [];
11041
+ Object.values(joinedPKRooms).map((room) => {
11042
+ PKRoomRemoteTracks.push(...room.getRemoteTracks());
11043
+ });
11044
+ isPKRoomResource = PKRoomRemoteTracks.some((track) => {
11045
+ return resourceId === track.getTrackId();
11046
+ });
11047
+ return isHostRoomResource || isPKRoomResource;
11048
+ }
10880
11049
  getLivingType() {
10881
11050
  return this._livingType;
10882
11051
  }
@@ -10884,6 +11053,10 @@ class RCLivingRoom extends RCAbstractRoom {
10884
11053
  * 获取 MCU 配置构建对象
10885
11054
  */
10886
11055
  getMCUConfigBuilder() {
11056
+ if (!this._isMainRoom) {
11057
+ logger.error('the `getMCUConfigBuilder` is disabled in PK room ');
11058
+ return { code: RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM };
11059
+ }
10887
11060
  return this._mcuConfigBuilder;
10888
11061
  }
10889
11062
  /**
@@ -10940,6 +11113,10 @@ class RCLivingRoom extends RCAbstractRoom {
10940
11113
  */
10941
11114
  enableInnerCDN(enable) {
10942
11115
  return __awaiter(this, void 0, void 0, function* () {
11116
+ if (!this._isMainRoom) {
11117
+ logger.error('the `enableInnerCDN` is disabled in PK room ');
11118
+ return { code: RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM };
11119
+ }
10943
11120
  if (!isBoolean(enable)) {
10944
11121
  logger.error('`enable` is invalid');
10945
11122
  return { code: RCRTCCode.PARAMS_ERROR };
@@ -11063,7 +11240,7 @@ class RCLivingRoom extends RCAbstractRoom {
11063
11240
  * 观众切换为主播后直接处理人员变更及资源变更
11064
11241
  */
11065
11242
  _afterChangedRole(data) {
11066
- const parseData = parseRoomData(data);
11243
+ const parseData = parseRoomData(data, this._roomId);
11067
11244
  const currentUserId = this._context.getCurrentId();
11068
11245
  const joinedAnchorList = Object.keys(parseData);
11069
11246
  // 观众升级主播成功后返回房间实例,才可注册房间事件,需异步抛出
@@ -11113,33 +11290,46 @@ class RCLivingRoom extends RCAbstractRoom {
11113
11290
  */
11114
11291
  _onJoinedPKRoom(roomId, room) {
11115
11292
  /**
11116
- * 连麦双方加入副房间之后,如果己方发布过资源,
11293
+ * 加入副房间之后,如果己方发布过资源,且参与连麦,
11117
11294
  * 需携带 pushOtherRooms 与 mediaServer 重新交互
11118
11295
  */
11119
- const pubTracks = this.getLocalTracks();
11120
- if (!pubTracks.length) {
11121
- return;
11296
+ const { code, roomPKHandler } = this.getRoomPKHandler();
11297
+ if (code === RCRTCCode.SUCCESS && roomPKHandler) {
11298
+ const PKInfo = roomPKHandler.getPKInfo(roomId);
11299
+ if (!PKInfo) {
11300
+ return;
11301
+ }
11302
+ this._exchangeWithPushOtherRoom();
11122
11303
  }
11123
- this._exchangeWithPushOtherRoom(roomId);
11124
11304
  }
11305
+ /**
11306
+ * 离开 PK 房间后,如果参与过连麦,pushOtherRooms 需去掉退出的连麦房间配置,重新和 mediaServer 交互
11307
+ */
11125
11308
  _onLeavePKRoom(roomId) {
11309
+ const { code, roomPKHandler } = this.getRoomPKHandler();
11310
+ if (code === RCRTCCode.SUCCESS && roomPKHandler) {
11311
+ const PKInfo = roomPKHandler.getPKInfo(roomId);
11312
+ if (!PKInfo) {
11313
+ return;
11314
+ }
11315
+ this._exchangeWithPushOtherRoom();
11316
+ }
11126
11317
  }
11127
11318
  /**
11128
11319
  * 携带 pushOtherRooms 与 mediaServer 重新交互
11129
- * @param roomId 副房间 roomId
11130
11320
  */
11131
- _exchangeWithPushOtherRoom(roomId) {
11321
+ _exchangeWithPushOtherRoom() {
11132
11322
  return __awaiter(this, void 0, void 0, function* () {
11323
+ /**
11324
+ * 如果己方未发布过资源,无需发请求
11325
+ */
11326
+ const pubTracks = this.getLocalTracks();
11327
+ if (!pubTracks.length) {
11328
+ return;
11329
+ }
11133
11330
  const reqBody = yield this._createExchangeParams(this._subscribedList, false);
11134
- const joinedPKRooms = this._roomPKHandler.getJoinedPKRooms();
11135
- const sessionId = joinedPKRooms[roomId].getSessionId();
11136
- const { inviterUserAutoMix: autoMix } = this._roomPKHandler.getPKInfo(roomId);
11137
- const pushOtherRooms = {
11138
- roomId,
11139
- sessionId,
11140
- autoMix: autoMix
11141
- };
11142
- reqBody.pushOtherRooms = [pushOtherRooms];
11331
+ const pushOtherRooms = this._getPushOtherRoomsParams();
11332
+ pushOtherRooms && (reqBody.pushOtherRooms = pushOtherRooms);
11143
11333
  const resp = yield this._exchangeHandle(reqBody);
11144
11334
  if (resp.code !== RCRTCCode.SUCCESS) {
11145
11335
  logger.error(`reTryExchange failed: ${resp.code}`);
@@ -11158,6 +11348,7 @@ class RCLivingRoom extends RCAbstractRoom {
11158
11348
  }
11159
11349
  /**
11160
11350
  * 获取 PK 业务处理器
11351
+ * @since version 5.3.0
11161
11352
  */
11162
11353
  getRoomPKHandler() {
11163
11354
  if (!this._isMainRoom) {
@@ -11172,14 +11363,14 @@ class RCLivingRoom extends RCAbstractRoom {
11172
11363
  };
11173
11364
  }
11174
11365
  /**
11175
- * 退出 PK 房间
11366
+ * 退出所有连麦房间
11176
11367
  */
11177
- _quitPKRoom() {
11368
+ _quitAllPKRoom() {
11178
11369
  const PKRooms = this._roomPKHandler.getJoinedPKRooms();
11179
- const roomIds = Object.keys(PKRooms);
11180
- roomIds.forEach((roomId) => {
11181
- this._context.quitRTCRoom(roomId);
11182
- });
11370
+ for (const roomId in PKRooms) {
11371
+ const room = PKRooms[roomId];
11372
+ this._roomPKHandler.leaveOtherRoom(room);
11373
+ }
11183
11374
  }
11184
11375
  }
11185
11376
 
@@ -11196,7 +11387,7 @@ const getCommonHeader = () => ({
11196
11387
  'Content-Type': 'application/json;charset=UTF-8',
11197
11388
  'Cache-Control': 'no-cache',
11198
11389
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
11199
- ClientVersion: "5.3.0-rtc-roompk.1",
11390
+ ClientVersion: "5.3.2-alpha.1",
11200
11391
  'Client-Session-Id': getUUID(),
11201
11392
  'Request-Id': Date.now().toString()
11202
11393
  });
@@ -12245,7 +12436,7 @@ class RCAudienceLivingRoom {
12245
12436
  /**
12246
12437
  * CDN 资源减少: 上次 CDNUris 中有 url,变更后无 url
12247
12438
  */
12248
- if (this._CDNUris.url && newCDNUris.url) {
12439
+ if (this._CDNUris.url && !newCDNUris.url) {
12249
12440
  this._callAppListener('onCDNInfoDisable');
12250
12441
  /**
12251
12442
  * 更新内存中存储的 cdn_uris 数据
@@ -12604,13 +12795,35 @@ class RCRTCClient {
12604
12795
  if (message.conversationType !== ConversationType.RTC_ROOM) {
12605
12796
  return false;
12606
12797
  }
12607
- const PKRooms = this._getJoinedPKRooms();
12608
- PKRooms.forEach((room) => {
12609
- room.__parseInnerMessage(message);
12610
- });
12798
+ // 给连麦房间增加消息处理器
12799
+ if (this._crtRoom instanceof RCLivingRoom) {
12800
+ const PKRooms = this._getJoinedPKRoomList();
12801
+ PKRooms.forEach((room) => {
12802
+ room.__parseInnerMessage(message);
12803
+ });
12804
+ }
12611
12805
  (_a = this._crtRoom) === null || _a === void 0 ? void 0 : _a.__parseInnerMessage(message);
12612
12806
  return true;
12613
12807
  }
12808
+ /**
12809
+ * 获取加入的连麦房间
12810
+ */
12811
+ _getJoinedPKRoomList() {
12812
+ const { code, roomPKHandler } = this._crtRoom.getRoomPKHandler();
12813
+ if (code === RCRTCCode.SUCCESS && roomPKHandler) {
12814
+ const PKRooms = roomPKHandler.getJoinedPKRooms() || {};
12815
+ return Object.values(PKRooms);
12816
+ }
12817
+ return [];
12818
+ }
12819
+ _getPKRoomIds() {
12820
+ const { code, roomPKHandler } = this._crtRoom.getRoomPKHandler();
12821
+ if (code === RCRTCCode.SUCCESS && roomPKHandler) {
12822
+ const PKInfo = roomPKHandler.getAllPKInfo();
12823
+ return Object.keys(PKInfo);
12824
+ }
12825
+ return [];
12826
+ }
12614
12827
  /**
12615
12828
  * 获取当前用户 Id,若 IM 未连接,这返回 `''`
12616
12829
  * @returns
@@ -12694,7 +12907,7 @@ class RCRTCClient {
12694
12907
  logger.debug(`JoinRoom success -> userId: ${this._context.getCurrentId()}, roomId: ${roomId}, data: ${JSON.stringify(data)}`);
12695
12908
  const room = new RCLivingRoom(this._context, this._runtime, roomId, data, this._service, this._options, this._releaseCrtRoomObj.bind(this), livingType, false, true);
12696
12909
  this._crtRoom = room;
12697
- const joinLivingResData = { room, code: RCRTCCode.SUCCESS, userIds: room.getRemoteUserIds(), tracks: room.getRemoteTracks() };
12910
+ const joinLivingResData = { room, code: RCRTCCode.SUCCESS, userIds: room.getRemoteUserIds(), tracks: room.getRemoteTracks(), PKRoomIds: this._getPKRoomIds() };
12698
12911
  // 手动模式时,用户加入房间,需返回 CDN 开关状态
12699
12912
  if (room.__getCDNPushMode() === RCInnerCDNPushMode.MANUAL) {
12700
12913
  Object.assign(joinLivingResData, { CDNEnable: room.__getCDNEnable() });
@@ -12711,25 +12924,18 @@ class RCRTCClient {
12711
12924
  }
12712
12925
  return this._audience;
12713
12926
  }
12714
- _getJoinedPKRooms() {
12715
- if (this._crtRoom instanceof RCLivingRoom) {
12716
- const { code, roomPKHandler } = this._crtRoom.getRoomPKHandler();
12717
- if (code === RCRTCCode.SUCCESS && roomPKHandler) {
12718
- const PKRooms = roomPKHandler.getJoinedPKRooms();
12719
- return Object.values(PKRooms);
12720
- }
12721
- }
12722
- return [];
12723
- }
12724
12927
  _onIMStatusChange(status) {
12725
12928
  logger.debug(`signal server connection state change: ${status}`);
12726
12929
  if (status !== ConnectionStatus.CONNECTED) {
12727
12930
  return;
12728
12931
  }
12729
- const PKRooms = this._getJoinedPKRooms();
12730
- PKRooms.forEach((room) => {
12731
- room.__onReconnected();
12732
- });
12932
+ // 给连麦房间增加重连处理
12933
+ if (this._crtRoom instanceof RCLivingRoom) {
12934
+ const PKRooms = this._getJoinedPKRoomList();
12935
+ PKRooms.forEach((room) => {
12936
+ room.__onReconnected();
12937
+ });
12938
+ }
12733
12939
  this._crtRoom && this._crtRoom.__onReconnected();
12734
12940
  }
12735
12941
  _onIMDisconnect() {
@@ -12884,7 +13090,7 @@ class RCRTCClient {
12884
13090
  * @param tag 屏幕共享视轨数据标识
12885
13091
  * @param options
12886
13092
  * @description
12887
- * 支持 Electron 平台下通过制定 `chromeMediaSrouceId` 的方式获取屏幕共享视频。
13093
+ * 支持 Electron 平台下通过制定 `chromeMediaSourceId` 的方式获取屏幕共享视频。
12888
13094
  * 参考:https://www.electronjs.org/docs/api/desktop-capturer
12889
13095
  */
12890
13096
  createScreenVideoTrack(tag = 'screenshare', options) {
@@ -13092,13 +13298,10 @@ class RCRTCClient {
13092
13298
  return {
13093
13299
  room,
13094
13300
  code: RCRTCCode.SUCCESS,
13095
- remoteInfo: {
13096
- remoteUserIds: room.getRemoteUserIds(),
13097
- remoteRTCTracks: room.getRemoteRTCTracks(),
13098
- remoteMCUTracks: room.getRemoteMCUTracks(),
13099
- remoteTracks: room.getRemoteTracks(),
13100
- CDNUris: room.getCDNInfo()
13101
- }
13301
+ userIds: room.getRemoteUserIds(),
13302
+ RTCTracks: room.getRemoteRTCTracks(),
13303
+ MCUTracks: room.getRemoteMCUTracks(),
13304
+ CDNUris: room.getCDNInfo()
13102
13305
  };
13103
13306
  });
13104
13307
  }
@@ -13142,7 +13345,7 @@ class RCRTCClient {
13142
13345
  this._crtRoom = crtRoom;
13143
13346
  // 重置观众房间
13144
13347
  this._crtAudienceLivingRoom = null;
13145
- return { room: crtRoom, code: RCRTCCode.SUCCESS };
13348
+ return { room: crtRoom, code: RCRTCCode.SUCCESS, userIds: room.getRemoteUserIds(), tracks: crtRoom.getRemoteTracks() };
13146
13349
  });
13147
13350
  }
13148
13351
  /**
@@ -13173,13 +13376,10 @@ class RCRTCClient {
13173
13376
  return {
13174
13377
  room: crtRoom,
13175
13378
  code: RCRTCCode.SUCCESS,
13176
- remoteInfo: {
13177
- remoteUserIds: crtRoom.getRemoteUserIds(),
13178
- remoteRTCTracks: crtRoom.getRemoteRTCTracks(),
13179
- remoteMCUTracks: crtRoom.getRemoteMCUTracks(),
13180
- remoteTracks: crtRoom.getRemoteTracks(),
13181
- CDNUris: crtRoom.getCDNInfo()
13182
- }
13379
+ userIds: crtRoom.getRemoteUserIds(),
13380
+ RTCTracks: crtRoom.getRemoteRTCTracks(),
13381
+ MCUTracks: crtRoom.getRemoteMCUTracks(),
13382
+ CDNUris: crtRoom.getCDNInfo()
13183
13383
  };
13184
13384
  });
13185
13385
  }
@@ -13226,9 +13426,9 @@ const installer = {
13226
13426
  logger.error('Please use the https protocol or use `http://localhost` to open the page!');
13227
13427
  return false;
13228
13428
  }
13229
- VersionManage.add('plugin-rtc', "5.3.0-rtc-roompk.1");
13230
- if (!VersionManage.validEngine("5.1.0-rtc-roompk.1")) {
13231
- logger.error(`The current engine version '${VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"5.1.0-rtc-roompk.1"}'.`);
13429
+ VersionManage.add('plugin-rtc', "5.3.2-alpha.1");
13430
+ if (!VersionManage.validEngine("5.1.2-alpha.1")) {
13431
+ logger.error(`The current engine version '${VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"5.1.2-alpha.1"}'.`);
13232
13432
  return false;
13233
13433
  }
13234
13434
  return true;
@@ -13236,7 +13436,7 @@ const installer = {
13236
13436
  setup(context, runtime, options = {}) {
13237
13437
  logger.setLogLevel(options.logLevel);
13238
13438
  logger.setLogStdout(options.logStdout);
13239
- logger.warn(`RCRTC Version: ${"5.3.0-rtc-roompk.1"}, Commit: ${"381b45b74bd1cee88cf1e6e79108809734bb17ea"}`);
13439
+ logger.warn(`RCRTC Version: ${"5.3.2-alpha.1"}, Commit: ${"db999e233480c8537357ef17495b0bbb67c692fe"}`);
13240
13440
  logger.warn(`browserInfo.browser -> ${browserInfo.browser}`);
13241
13441
  logger.warn(`browserInfo.supportsUnifiedPlan -> ${browserInfo.supportsUnifiedPlan}`);
13242
13442
  logger.warn(`browserInfo.version -> ${browserInfo.version}`);