@rongcloud/plugin-call 5.1.2-alpha.1 → 5.1.2-alpha.2

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,16 +1,14 @@
1
1
  /*
2
- * RCCall - v5.1.2-alpha.1
3
- * CommitId - 5a6d3a159d1171c71f1bb419dfac59eb8e886f91
4
- * Mon Feb 27 2023 10:35:06 GMT+0800 (China Standard Time)
2
+ * RCCall - v5.1.2-alpha.2
3
+ * CommitId - 8d4f8b00cda704283faad34d0e81a4e048e09d08
4
+ * Tue Feb 28 2023 21:09:53 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
+ import { RTCJoinType, LogLevel, ErrorCode, VersionManage } from '@rongcloud/engine';
7
8
  import { RCCallMediaType, RCCallLanguage, RCCallSessionState, RCCallEndReason, RCCallErrorCode, RCCallEngine } from '@rongcloud/plugin-call-engine';
8
9
  export { RCCallEndReason, RCCallErrorCode, RCCallLanguage, RCCallMediaType, RCCallSessionState, RCCallUserState } from '@rongcloud/plugin-call-engine';
9
- import { Logger, RTCJoinType, LogLevel, VersionManage, ErrorCode } from '@rongcloud/engine';
10
10
  import { RCRTCCode, RCKickReason } from '@rongcloud/plugin-rtc';
11
11
 
12
- const logger = new Logger('RCCall');
13
-
14
12
  /*! *****************************************************************************
15
13
  Copyright (c) Microsoft Corporation.
16
14
 
@@ -254,6 +252,11 @@ const validatePushContent = (pushContent) => {
254
252
  return { result: false, msg: '\'pushContent\' parameter must be of type \'string\'' };
255
253
  }
256
254
  };
255
+ const validatePushConfig = (pushConfig) => {
256
+ const { pushTitle, pushContent } = pushConfig;
257
+ const conclusion = [validatePushTitle(pushTitle), validatePushContent(pushContent)];
258
+ return conclusion;
259
+ };
257
260
  const validateUserIds = (userIds) => {
258
261
  if (!Array.isArray(userIds)) {
259
262
  return { result: false, msg: '\'userIds\' parameter is required, must be of type \'string[]\'' };
@@ -347,13 +350,14 @@ class RCCallSession {
347
350
  /**
348
351
  * rtc实例
349
352
  */
350
- _rtcClient,
353
+ _rtcClient, _logger,
351
354
  /**
352
355
  * session的其它选项
353
356
  */
354
357
  _options = {}) {
355
358
  this._stateMachine = _stateMachine;
356
359
  this._rtcClient = _rtcClient;
360
+ this._logger = _logger;
357
361
  this._options = _options;
358
362
  /**
359
363
  * 用户传进来的 对session的监听 (要在RCCallClient的_onInvite里判断,要求执行完onSession必须注册session的监听,所以这里是public)
@@ -374,7 +378,7 @@ class RCCallSession {
374
378
  * @param info
375
379
  */
376
380
  onUserStateChange: ({ user, reason }) => {
377
- logger.info(`[RCCallSession onUserStateChange] userId->${user === null || user === void 0 ? void 0 : user.userId} state->${user === null || user === void 0 ? void 0 : user.state} reason->${reason}`);
381
+ this._logger.info('_', `[RCCallSession onUserStateChange] userId->${user === null || user === void 0 ? void 0 : user.userId} state->${user === null || user === void 0 ? void 0 : user.state} reason->${reason}`);
378
382
  },
379
383
  /**
380
384
  * 房间状态变更
@@ -382,18 +386,18 @@ class RCCallSession {
382
386
  */
383
387
  onStateChange: (info) => __awaiter(this, void 0, void 0, function* () {
384
388
  const { state, reason } = info;
385
- logger.info(`[RCCallSession onStateChange] : state->${state} reason->${reason}`);
389
+ this._logger.info('_', `[RCCallSession onStateChange] : state->${state} reason->${reason}`);
386
390
  // 如果在通话中,就加房间
387
391
  if (state === RCCallSessionState.KEEPING) {
388
392
  const roomId = this._stateMachine.getCallId();
389
- logger.info(`[RCCallSession onStateChange] roomId: ${roomId}`);
393
+ this._logger.info('_', `[RCCallSession onStateChange] roomId: ${roomId}`);
390
394
  try {
391
395
  // 加房间
392
396
  yield this._joinRoom(roomId);
393
397
  }
394
398
  catch (error) {
395
399
  this._exceptionClose(RCCallEndReason.NETWORK_ERROR);
396
- logger.error(`[RCCallSession onStateChange] joinRoom throw exception roomId -> ${roomId}`);
400
+ this._logger.error('_', `[RCCallSession onStateChange] joinRoom throw exception roomId -> ${roomId}`);
397
401
  console.error(error);
398
402
  }
399
403
  /**
@@ -413,7 +417,7 @@ class RCCallSession {
413
417
  return;
414
418
  }
415
419
  this._options.localTracks && this._destroyTracks(this._options.localTracks);
416
- logger.info('[RCCallSession onStateChange] localTracks destroyed');
420
+ this._logger.info('_', '[RCCallSession onStateChange] localTracks destroyed');
417
421
  this._leaveRoom();
418
422
  this._room = null;
419
423
  }
@@ -423,13 +427,13 @@ class RCCallSession {
423
427
  * @param sender 发起用户信息
424
428
  */
425
429
  onRinging: (sender) => {
426
- logger.info(`[RCCallSession onRinging]sender: sender.userId -> ${sender.userId}`);
430
+ this._logger.info('_', `[RCCallSession onRinging]sender: sender.userId -> ${sender.userId}`);
427
431
  try {
428
432
  // 通知用户响铃
429
433
  this._listener.onRinging(sender, this);
430
434
  }
431
435
  catch (error) {
432
- logger.error('[RCCallSession onRinging] method exception -> onRinging');
436
+ this._logger.error('_', '[RCCallSession onRinging] method exception -> onRinging');
433
437
  console.error(error);
434
438
  }
435
439
  },
@@ -437,13 +441,13 @@ class RCCallSession {
437
441
  * 当远端用户同意接听
438
442
  */
439
443
  onAccept: (sender) => {
440
- logger.info(`[RCCallSession onAccept]sender: sender.userId -> ${sender.userId}`);
444
+ this._logger.info('_', `[RCCallSession onAccept]sender: sender.userId -> ${sender.userId}`);
441
445
  try {
442
446
  // 通知本端,远端用户已接听
443
447
  this._listener.onAccept(sender, this);
444
448
  }
445
449
  catch (error) {
446
- logger.error('[RCCallSession onAccept] method exception -> onAccept');
450
+ this._logger.error('_', '[RCCallSession onAccept] method exception -> onAccept');
447
451
  console.error(error);
448
452
  }
449
453
  },
@@ -451,13 +455,13 @@ class RCCallSession {
451
455
  * 当有远端用户挂断
452
456
  */
453
457
  onHungup: (sender, reason) => {
454
- logger.info(`[RCCallSession onHungup]sender: sender.userId -> ${sender.userId} reason->${reason}`);
458
+ this._logger.info('_', `[RCCallSession onHungup]sender: sender.userId -> ${sender.userId} reason->${reason}`);
455
459
  try {
456
460
  // 通知本端,远端用户已挂断
457
461
  this._listener.onHungup(sender, reason, this);
458
462
  }
459
463
  catch (error) {
460
- logger.error('[RCCallSession onHungup] method exception -> onHungup');
464
+ this._logger.error('_', '[RCCallSession onHungup] method exception -> onHungup');
461
465
  console.error(error);
462
466
  }
463
467
  },
@@ -466,13 +470,13 @@ class RCCallSession {
466
470
  * @param sender 发起用户信息
467
471
  */
468
472
  onMemberModify: ({ sender, invitedUsers }) => {
469
- logger.info(`[RCCallSession onMemberModify] sender.userId -> ${sender.userId}`);
473
+ this._logger.info('_', `[RCCallSession onMemberModify] sender.userId -> ${sender.userId}`);
470
474
  try {
471
475
  // 通知用户人员变更
472
476
  this._listener.onMemberModify(sender, invitedUsers, this);
473
477
  }
474
478
  catch (error) {
475
- logger.error('[RCCallSession onMemberModify] method exception -> onMemberModify');
479
+ this._logger.error('_', '[RCCallSession onMemberModify] method exception -> onMemberModify');
476
480
  console.error(error);
477
481
  }
478
482
  },
@@ -481,7 +485,7 @@ class RCCallSession {
481
485
  * @param sender 发起用户信息
482
486
  */
483
487
  onMediaModify: ({ sender, mediaType }) => {
484
- logger.info(`[RCCallSession onMediaModify]sender: sender.userId -> ${sender.userId} mediaType: ${mediaType}`);
488
+ this._logger.info('_', `[RCCallSession onMediaModify]sender: sender.userId -> ${sender.userId} mediaType: ${mediaType}`);
485
489
  if (mediaType === RCCallMediaType.AUDIO) {
486
490
  // 远端收到通话降级通知后,远端执行降级通话(不发消息)
487
491
  this._setMediaTypeToAudio();
@@ -490,7 +494,7 @@ class RCCallSession {
490
494
  this._listener.onMediaModify(sender, mediaType, this);
491
495
  }
492
496
  catch (error) {
493
- logger.error('[RCCallSession onMediaModify] method exception -> onMediaModify');
497
+ this._logger.error('_', '[RCCallSession onMediaModify] method exception -> onMediaModify');
494
498
  console.error(error);
495
499
  }
496
500
  },
@@ -499,10 +503,15 @@ class RCCallSession {
499
503
  * @param sender 发起用户信息
500
504
  */
501
505
  crossAppkey: (isCrossAppkey) => {
502
- logger.info(`[RCCallSession crossAppkey] 是否跨 appkey: ${isCrossAppkey}`);
506
+ this._logger.info('_', `[RCCallSession crossAppkey] 是否跨 appkey: ${isCrossAppkey}`);
503
507
  this._options.isCrossAppkey = isCrossAppkey;
504
508
  }
505
509
  });
510
+ /**
511
+ * 设置挂断的推送信息
512
+ */
513
+ const { pushTitle, pushContent } = this._options.hungupPushConfig;
514
+ this._stateMachine.setHungupPushConfig(pushTitle, pushContent);
506
515
  }
507
516
  /**
508
517
  * 加入房间
@@ -531,7 +540,7 @@ class RCCallSession {
531
540
  else {
532
541
  this._exceptionClose(RCCallEndReason.NETWORK_ERROR);
533
542
  }
534
- logger.info(`[RCCallClient _joinRoom] join room failed: roomId -> ${roomId} RCRTCCode -> ${code}`);
543
+ this._logger.info('_', `[RCCallClient _joinRoom] join room failed: roomId -> ${roomId} RCRTCCode -> ${code}`);
535
544
  return { code: RCCallErrorCode.JOIN_ROOM_ERROR };
536
545
  }
537
546
  /**
@@ -554,7 +563,7 @@ class RCCallSession {
554
563
  }
555
564
  catch (error) {
556
565
  this._exceptionClose(RCCallEndReason.NETWORK_ERROR);
557
- logger.error(`[RCCallSession _joinRoom] _rtcClient.joinRTCRoom throw exception roomId -> ${roomId}`);
566
+ this._logger.error('_', `[RCCallSession _joinRoom] _rtcClient.joinRTCRoom throw exception roomId -> ${roomId}`);
558
567
  console.error(error);
559
568
  return { code: RCCallErrorCode.JOIN_ROOM_ERROR };
560
569
  }
@@ -569,7 +578,7 @@ class RCCallSession {
569
578
  catch (error) {
570
579
  // 结束通话session
571
580
  this._exceptionClose(RCCallEndReason.SUBSCRIBE_ERROR);
572
- logger.error(`[RCCallSession _joinRoom] _subscribeInRoomRemoteTrack Exception roomId -> ${roomId}`);
581
+ this._logger.error('_', `[RCCallSession _joinRoom] _subscribeInRoomRemoteTrack Exception roomId -> ${roomId}`);
573
582
  console.error(error);
574
583
  return { code: RCCallErrorCode.JOIN_ROOM_ERROR };
575
584
  }
@@ -580,7 +589,7 @@ class RCCallSession {
580
589
  catch (error) {
581
590
  // 结束通话session
582
591
  this._exceptionClose(RCCallEndReason.PUBLISH_ERROR);
583
- logger.error(`[RCCallSession _joinRoom] _publish Exception roomId -> ${roomId}`);
592
+ this._logger.error('_', `[RCCallSession _joinRoom] _publish Exception roomId -> ${roomId}`);
584
593
  console.error(error);
585
594
  return { code: RCCallErrorCode.JOIN_ROOM_ERROR };
586
595
  }
@@ -598,7 +607,7 @@ class RCCallSession {
598
607
  const { code } = yield this._subscribeRetry(tracks, this._options.isAllowSubscribeRetry, this._RETRYCOUNT);
599
608
  if (code !== RCRTCCode.SUCCESS) {
600
609
  this._exceptionClose(RCCallEndReason.SUBSCRIBE_ERROR);
601
- logger.error(`[RCCallSession _subscribeInRoomRemoteTrack] Resource subscription failed roomId -> ${this._stateMachine.getCallId()} RTC code -> ${code}`);
610
+ this._logger.error('_', `[RCCallSession _subscribeInRoomRemoteTrack] Resource subscription failed roomId -> ${this._stateMachine.getCallId()} RTC code -> ${code}`);
602
611
  }
603
612
  }
604
613
  });
@@ -617,7 +626,7 @@ class RCCallSession {
617
626
  this._listener.onTrackSubscribeFail && this._listener.onTrackSubscribeFail(code, this);
618
627
  }
619
628
  catch (error) {
620
- logger.error('[RCCallSession] _listener.onTrackSubscribeFail exception');
629
+ this._logger.error('_', '[RCCallSession] _listener.onTrackSubscribeFail exception');
621
630
  console.error(error);
622
631
  }
623
632
  // 如果不允许重试,直接返回
@@ -643,7 +652,7 @@ class RCCallSession {
643
652
  // 若资源发布失败
644
653
  if (code !== RCRTCCode.SUCCESS) {
645
654
  this._exceptionClose(RCCallEndReason.PUBLISH_ERROR);
646
- logger.info(`[RCCallSession _publist] Resource publishing failed: roomId -> ${this._stateMachine.getCallId()} RCRTCCode -> ${code}`);
655
+ this._logger.info('_', `[RCCallSession _publist] Resource publishing failed: roomId -> ${this._stateMachine.getCallId()} RCRTCCode -> ${code}`);
647
656
  return;
648
657
  }
649
658
  // 如果是主动发起的呼叫,已提前抛出了资源, 被动呼叫,这里才需要抛出
@@ -667,7 +676,7 @@ class RCCallSession {
667
676
  this._listener.onTrackPublishFail && this._listener.onTrackPublishFail(code, this);
668
677
  }
669
678
  catch (error) {
670
- logger.error('[RCCallSession] _listener.onTrackPublishFail exception');
679
+ this._logger.error('_', '[RCCallSession] _listener.onTrackPublishFail exception');
671
680
  console.error(error);
672
681
  }
673
682
  // 如果不允许重试,直接返回
@@ -691,10 +700,10 @@ class RCCallSession {
691
700
  // 退出房间
692
701
  const callBack = yield this._rtcClient.leaveRoom(this._room);
693
702
  // 成功退出房间,触发RCCallClient实例上的onSessionClose监听,抛给用户信息
694
- logger.info('[RCCallSession _leaveRoom] Successfully exited the room', callBack);
703
+ this._logger.info('_', `[RCCallSession _leaveRoom] Successfully exited the room code: ${callBack.code}`);
695
704
  }
696
705
  catch (error) {
697
- logger.error('[RCCallSession _leaveRoom] leaveRoom throw exception');
706
+ this._logger.error('_', '[RCCallSession _leaveRoom] leaveRoom throw exception');
698
707
  console.error(error);
699
708
  }
700
709
  finally {
@@ -733,19 +742,19 @@ class RCCallSession {
733
742
  if (mediaType === RCCallMediaType.AUDIO) {
734
743
  const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', constraints && constraints.audio && Object.assign({}, constraints.audio));
735
744
  if (code !== RCRTCCode.SUCCESS) {
736
- logger.error(`[RCCallSession _getLocalTrackCore] get Audio local tracks failed RCT code -> ${code}`);
745
+ this._logger.error('_', `[RCCallSession _getLocalTrackCore] get Audio local tracks failed RCT code -> ${code}`);
737
746
  return { code: RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
738
747
  }
739
- logger.info('[RCCallSession _getLocalTrackCore] successfully get Audio local tracks');
748
+ this._logger.info('_', '[RCCallSession _getLocalTrackCore] successfully get Audio local tracks');
740
749
  return { code: RCCallErrorCode.SUCCESS, tracks: [track] };
741
750
  }
742
751
  else {
743
752
  const { code, tracks } = yield this._rtcClient.createMicrophoneAndCameraTracks('RongCloudRTC', constraints && Object.assign({}, constraints));
744
753
  if (code !== RCRTCCode.SUCCESS) {
745
- logger.error(`[RCCallSession _getLocalTrackCore] get Audio and Video local tracks failed RCT code -> ${code}`);
754
+ this._logger.error('_', `[RCCallSession _getLocalTrackCore] get Audio and Video local tracks failed RCT code -> ${code}`);
746
755
  return { code: RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR };
747
756
  }
748
- logger.info('[RCCallSession _getLocalTrackCore] successfully get audio and video local tracks');
757
+ this._logger.info('_', '[RCCallSession _getLocalTrackCore] successfully get audio and video local tracks');
749
758
  return { code: RCCallErrorCode.SUCCESS, tracks };
750
759
  }
751
760
  });
@@ -789,7 +798,7 @@ class RCCallSession {
789
798
  const localTracks = [];
790
799
  const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', audioConstraints);
791
800
  if (code !== RCRTCCode.SUCCESS) {
792
- logger.error(`[RCCallSession changeDevice] get local Audio tracks failed RCTLib code -> ${code}`);
801
+ this._logger.error('_', `[RCCallSession changeDevice] get local Audio tracks failed RCTLib code -> ${code}`);
793
802
  return { code: RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
794
803
  }
795
804
  this._options.localTracks && this._options.localTracks.forEach((track) => {
@@ -820,12 +829,14 @@ class RCCallSession {
820
829
  * 群呼叫中继续邀请
821
830
  * @param userIds 被邀请用户 ID 列表
822
831
  * @param options.extra 消息的扩展信息
823
- * @param options.pushTitle 通知的标题
824
- * @param options.pushContent 通知内容
832
+ * @deprecated 5.1.2 废弃 options.pushTitle 通知的标题
833
+ * @deprecated 5.1.2 废弃 options.pushContent 通知内容
825
834
  */
826
835
  invite(userIds, options = {}) {
836
+ var _a, _b;
827
837
  return __awaiter(this, void 0, void 0, function* () {
828
- const { extra = '', pushTitle = '', pushContent = '' } = options;
838
+ const { extra = '' } = options;
839
+ const { pushTitle = '', pushContent = '' } = (((_a = this._options.callPushConfig) === null || _a === void 0 ? void 0 : _a.pushTitle) || ((_b = this._options.callPushConfig) === null || _b === void 0 ? void 0 : _b.pushContent)) ? this._options.callPushConfig : options;
829
840
  const conclusion = [validateUserIds(userIds), validateExtra(extra), validatePushTitle(pushTitle), validatePushContent(pushContent)];
830
841
  const messages = [];
831
842
  const result = conclusion.every((obj) => {
@@ -859,7 +870,7 @@ class RCCallSession {
859
870
  // 发送接听的消息
860
871
  const { code } = yield this._stateMachine.accept();
861
872
  if (code !== RCCallErrorCode.SUCCESS) {
862
- logger.error(`[RCCallSession accept]Send accept message failed -> code: ${code}`);
873
+ this._logger.error('_', `[RCCallSession accept]Send accept message failed -> code: ${code}`);
863
874
  return { code };
864
875
  }
865
876
  return { code };
@@ -883,7 +894,7 @@ class RCCallSession {
883
894
  return __awaiter(this, void 0, void 0, function* () {
884
895
  const { code } = yield this._stateMachine.changeMediaType(mediaType);
885
896
  if (code !== RCCallErrorCode.SUCCESS) {
886
- logger.error(`[RCCallSession _changeMediaType] change media type fail code-> ${code}`);
897
+ this._logger.error('_', `[RCCallSession _changeMediaType] change media type fail code-> ${code}`);
887
898
  }
888
899
  return { code };
889
900
  });
@@ -932,7 +943,7 @@ class RCCallSession {
932
943
  const { code: _code } = yield this._room.publish([track]);
933
944
  // 若资源发布失败
934
945
  if (_code !== RCRTCCode.SUCCESS) {
935
- logger.error(`[RCCallSession _enableVideo] Resource publishing failed: RCRTCCode -> ${code}`);
946
+ this._logger.error('_', `[RCCallSession _enableVideo] Resource publishing failed: RCRTCCode -> ${code}`);
936
947
  return;
937
948
  }
938
949
  // 通知业务层trackReady
@@ -956,7 +967,7 @@ class RCCallSession {
956
967
  // 取消发布视频
957
968
  const { code } = yield this._room.unpublish(tracks);
958
969
  if (code !== RCRTCCode.SUCCESS) {
959
- logger.error(`[RCCallSession disableVideo] unpublish failed -> ${code}`);
970
+ this._logger.error('_', `[RCCallSession disableVideo] unpublish failed -> ${code}`);
960
971
  }
961
972
  // 关闭摄像头
962
973
  this._destroyTracks(tracks);
@@ -982,12 +993,12 @@ class RCCallSession {
982
993
  disableVideoTrack() {
983
994
  return __awaiter(this, void 0, void 0, function* () {
984
995
  if (!this._room) {
985
- logger.error(`[RCCallSession disableAudioTrack] Room missing audio track -> ${RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
996
+ this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
986
997
  return { code: RCCallErrorCode.NOT_IN_ROOM_ERROR };
987
998
  }
988
999
  const tracks = this._getLocalVideoTracks();
989
1000
  if (!tracks.length) {
990
- logger.error(`[RCCallSession disableVideoTrack] Room missing video track -> ${RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
1001
+ this._logger.error('_', `[RCCallSession disableVideoTrack] Room missing video track -> ${RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
991
1002
  return { code: RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR };
992
1003
  }
993
1004
  // 禁用视频
@@ -1001,7 +1012,7 @@ class RCCallSession {
1001
1012
  // 取消发布视频
1002
1013
  const { code } = yield this._room.unpublish(tracks);
1003
1014
  if (code !== RCRTCCode.SUCCESS) {
1004
- logger.error(`[RCCallSession disableVideo] unpublish failed -> ${code}`);
1015
+ this._logger.error('_', `[RCCallSession disableVideo] unpublish failed -> ${code}`);
1005
1016
  return { code: RCCallErrorCode.UNPUBLISH_VIDEO_ERROR };
1006
1017
  }
1007
1018
  tracks.forEach((track) => {
@@ -1017,14 +1028,14 @@ class RCCallSession {
1017
1028
  enableVideoTrack() {
1018
1029
  return __awaiter(this, void 0, void 0, function* () {
1019
1030
  if (!this._room) {
1020
- logger.error(`[RCCallSession disableAudioTrack] Room missing audio track -> ${RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
1031
+ this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
1021
1032
  return { code: RCCallErrorCode.NOT_IN_ROOM_ERROR };
1022
1033
  }
1023
1034
  // 如果不需关闭摄像头
1024
1035
  if (!this._options.isOffCameraWhenVideoDisable) {
1025
1036
  const tracks = this._getLocalVideoTracks();
1026
1037
  if (!tracks.length) {
1027
- logger.error(`[RCCallSession EnableVideoTrack] Room missing video track -> ${RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
1038
+ this._logger.error('_', `[RCCallSession EnableVideoTrack] Room missing video track -> ${RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
1028
1039
  return { code: RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR };
1029
1040
  }
1030
1041
  // 启用视频
@@ -1036,7 +1047,7 @@ class RCCallSession {
1036
1047
  // 获得本端视频资源
1037
1048
  const { code, track } = yield this._rtcClient.createCameraVideoTrack();
1038
1049
  if (code !== RCRTCCode.SUCCESS) {
1039
- logger.error(`[RCCallSession EnableVideoTrack] Get Resource failed: RCRTCCode -> ${code}`);
1050
+ this._logger.error('_', `[RCCallSession EnableVideoTrack] Get Resource failed: RCRTCCode -> ${code}`);
1040
1051
  return { code: RCCallErrorCode.GET_LOCAL_VIDEO_TRACK_ERROR };
1041
1052
  }
1042
1053
  const localTracks = [];
@@ -1059,7 +1070,7 @@ class RCCallSession {
1059
1070
  const { code: _code } = yield this._room.publish([track]);
1060
1071
  // 若资源发布失败
1061
1072
  if (_code !== RCRTCCode.SUCCESS) {
1062
- logger.error(`[RCCallSession EnableVideoTrack] Resource publishing failed: RCRTCCode -> ${code}`);
1073
+ this._logger.error('_', `[RCCallSession EnableVideoTrack] Resource publishing failed: RCRTCCode -> ${code}`);
1063
1074
  return { code: RCCallErrorCode.VIDEO_PUBLISH_ERROR };
1064
1075
  }
1065
1076
  // 启用
@@ -1075,7 +1086,7 @@ class RCCallSession {
1075
1086
  disableAudioTrack() {
1076
1087
  return __awaiter(this, void 0, void 0, function* () {
1077
1088
  if (!this._room) {
1078
- logger.error(`[RCCallSession disableAudioTrack] Room missing audio track -> ${RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
1089
+ this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
1079
1090
  return { code: RCCallErrorCode.NOT_IN_ROOM_ERROR };
1080
1091
  }
1081
1092
  const tracks = this._getLocalAudioTracks();
@@ -1091,12 +1102,12 @@ class RCCallSession {
1091
1102
  enableAudioTrack() {
1092
1103
  return __awaiter(this, void 0, void 0, function* () {
1093
1104
  if (!this._room) {
1094
- logger.error(`[RCCallSession disableAudioTrack] Room missing audio track -> ${RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
1105
+ this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
1095
1106
  return { code: RCCallErrorCode.NOT_IN_ROOM_ERROR };
1096
1107
  }
1097
1108
  const tracks = this._getLocalAudioTracks();
1098
1109
  if (!tracks.length) {
1099
- logger.error(`[RCCallSession disableAudioTrack] Room missing audio track -> ${RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
1110
+ this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
1100
1111
  return { code: RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR };
1101
1112
  }
1102
1113
  // 启用音频
@@ -1122,7 +1133,7 @@ class RCCallSession {
1122
1133
  this._listener.onTrackReady(track, this);
1123
1134
  }
1124
1135
  catch (error) {
1125
- logger.error('[RCCallSession _notifyTrackReady] _listener onTrackReady exception');
1136
+ this._logger.error('_', '[RCCallSession _notifyTrackReady] _listener onTrackReady exception');
1126
1137
  console.error(error);
1127
1138
  }
1128
1139
  });
@@ -1176,7 +1187,7 @@ class RCCallSession {
1176
1187
  * @param audioTrack RCRemoteAudioTrack 类实例
1177
1188
  */
1178
1189
  onAudioMuteChange: (audioTrack) => {
1179
- logger.info(`[RCCallSession onAudioMuteChange] userId->${audioTrack.getUserId()} muted -> ${audioTrack.isOwnerMuted()}`);
1190
+ this._logger.info('_', `[RCCallSession onAudioMuteChange] userId->${audioTrack.getUserId()} muted -> ${audioTrack.isOwnerMuted()}`);
1180
1191
  const muteUser = {
1181
1192
  userId: audioTrack.getUserId(),
1182
1193
  muted: audioTrack.isOwnerMuted(),
@@ -1188,7 +1199,7 @@ class RCCallSession {
1188
1199
  this._listener.onAudioMuteChange(muteUser, this);
1189
1200
  }
1190
1201
  catch (error) {
1191
- logger.error('[RCCallSession onAudioMuteChange] Missing listening method -> onTrackMuteChange');
1202
+ this._logger.error('_', '[RCCallSession onAudioMuteChange] Missing listening method -> onTrackMuteChange');
1192
1203
  console.error(error);
1193
1204
  }
1194
1205
  },
@@ -1197,7 +1208,7 @@ class RCCallSession {
1197
1208
  * @param videoTrack RCRemoteVideoTrack 类实例对象
1198
1209
  */
1199
1210
  onVideoMuteChange: (videoTrack) => {
1200
- logger.info(`[RCCallSession onVideoMuteChange]userId->${videoTrack.getUserId()} muted -> ${videoTrack.isOwnerMuted()}`);
1211
+ this._logger.info('_', `[RCCallSession onVideoMuteChange]userId->${videoTrack.getUserId()} muted -> ${videoTrack.isOwnerMuted()}`);
1201
1212
  const muteUser = {
1202
1213
  userId: videoTrack.getUserId(),
1203
1214
  muted: videoTrack.isOwnerMuted(),
@@ -1209,7 +1220,7 @@ class RCCallSession {
1209
1220
  this._listener.onVideoMuteChange(muteUser, this);
1210
1221
  }
1211
1222
  catch (error) {
1212
- logger.error('[RCCallSession onVideoMuteChange] Missing listening method -> onVideoMuteChange');
1223
+ this._logger.error('_', '[RCCallSession onVideoMuteChange] Missing listening method -> onVideoMuteChange');
1213
1224
  console.error(error);
1214
1225
  }
1215
1226
  },
@@ -1224,7 +1235,7 @@ class RCCallSession {
1224
1235
  // 按业务需求选择需要订阅资源,通过 room.subscribe 接口进行订阅
1225
1236
  const { code } = yield this._room.subscribe(tracks);
1226
1237
  if (code !== RCRTCCode.SUCCESS) {
1227
- logger.error(`[RCCallSession onTrackPublish] subscribe failed RTCCode ->${code}`);
1238
+ this._logger.error('_', `[RCCallSession onTrackPublish] subscribe failed RTCCode ->${code}`);
1228
1239
  }
1229
1240
  }
1230
1241
  }),
@@ -1264,20 +1275,20 @@ class RCCallSession {
1264
1275
  * @param userIds
1265
1276
  */
1266
1277
  onUserLeave: (userIds) => {
1267
- logger.info(`[RCCallSession onUserLeave] listening onUserLeave userIds -> ${userIds === null || userIds === void 0 ? void 0 : userIds.join(',')}`);
1278
+ this._logger.info('_', `[RCCallSession onUserLeave] listening onUserLeave userIds -> ${userIds === null || userIds === void 0 ? void 0 : userIds.join(',')}`);
1268
1279
  this._stateMachine.userLeave(userIds);
1269
1280
  },
1270
1281
  /**
1271
1282
  * RTC 每次 Ping 结果
1272
1283
  */
1273
1284
  onPing: (result) => {
1274
- logger.info(`[RCCallSession onPing]${result}`);
1285
+ this._logger.info('_', `[RCCallSession onPing]${result}`);
1275
1286
  try {
1276
1287
  // 通知给业务
1277
1288
  this._listener.onPing && this._listener.onPing(result, this);
1278
1289
  }
1279
1290
  catch (error) {
1280
- logger.error('[RCCallSession onPing] listening onPing exception');
1291
+ this._logger.error('_', '[RCCallSession onPing] listening onPing exception');
1281
1292
  console.error(error);
1282
1293
  }
1283
1294
  }
@@ -1298,7 +1309,7 @@ class RCCallSession {
1298
1309
  this._listener.onRTCStateReport && this._listener.onRTCStateReport(report, this);
1299
1310
  }
1300
1311
  catch (error) {
1301
- logger.error('[RCCallSession onStateReport] listener onStateReport exception');
1312
+ this._logger.error('_', '[RCCallSession onStateReport] listener onStateReport exception');
1302
1313
  console.error(error);
1303
1314
  }
1304
1315
  },
@@ -1311,7 +1322,7 @@ class RCCallSession {
1311
1322
  this._listener.onICEConnectionStateChange && this._listener.onICEConnectionStateChange(state, this);
1312
1323
  }
1313
1324
  catch (error) {
1314
- logger.error('[RCCallSession onICEConnectionStateChange] onICEConnectionStateChange exception');
1325
+ this._logger.error('_', '[RCCallSession onICEConnectionStateChange] onICEConnectionStateChange exception');
1315
1326
  console.error(error);
1316
1327
  }
1317
1328
  }
@@ -1388,20 +1399,17 @@ class RCCallSession {
1388
1399
  }
1389
1400
  }
1390
1401
 
1391
- // plugin-call 版本上报
1392
- VersionManage.add('plugin-call', "5.1.2-alpha.1");
1393
- // 校验当前安装的 engine 版本是否可用
1394
- if (!VersionManage.validEngine("^5.5.4")) {
1395
- logger.error(`The current engine version '${VersionManage.getInfo().engine}' error,plugin-call required engine version at least '${"^5.5.4"}'.`);
1396
- }
1397
1402
  class RCCallClient {
1398
- constructor(_context, _runtime, _options) {
1403
+ constructor(_context, _runtime, _logger, _options) {
1399
1404
  this._context = _context;
1400
1405
  this._runtime = _runtime;
1406
+ this._logger = _logger;
1401
1407
  /**
1402
1408
  * session列表
1403
1409
  */
1404
1410
  this._sessionList = [];
1411
+ this._callPushConfig = {};
1412
+ this._hungupPushConfig = {};
1405
1413
  this._rtcClient = _options.rtcClient;
1406
1414
  this._options = Object.assign({
1407
1415
  /**
@@ -1433,7 +1441,7 @@ class RCCallClient {
1433
1441
  lang: RCCallLanguage.ZH
1434
1442
  }, _options);
1435
1443
  // 初始化callEngine, 并监听onInvite
1436
- this._callEngine = new RCCallEngine(this._context, _runtime, logger, {
1444
+ this._callEngine = new RCCallEngine(this._context, _runtime, this._logger, {
1437
1445
  /**
1438
1446
  * 监听收到invite
1439
1447
  */
@@ -1455,15 +1463,15 @@ class RCCallClient {
1455
1463
  this._options.onSessionClose(session, summaryInfo);
1456
1464
  }
1457
1465
  catch (error) {
1458
- logger.error('[RCCCallClient] options.onSessionClose exception');
1466
+ this._logger.error('_', '[RCCCallClient] options.onSessionClose exception');
1459
1467
  console.log(error);
1460
1468
  }
1461
1469
  });
1462
1470
  // 接听之前挂断其它的session
1463
1471
  eventEmitter.on('hungupOtherSession', ({ session }) => {
1464
1472
  const id = session.getSessionId();
1465
- logger.info(`[RCCallClient hungupOtherSession] sessionId ready to accept -> ${id}`);
1466
- logger.info(`[RCCallClient hungupOtherSession] sessionList ->${this._sessionList.map(ses => ses.getSessionId()).join(',')}`);
1473
+ this._logger.info('_', `[RCCallClient hungupOtherSession] sessionId ready to accept -> ${id}`);
1474
+ this._logger.info('_', `[RCCallClient hungupOtherSession] sessionList ->${this._sessionList.map(ses => ses.getSessionId()).join(',')}`);
1467
1475
  let i = 0;
1468
1476
  while (this._sessionList.length > 1) {
1469
1477
  // 如果与要接听的session不一致
@@ -1478,15 +1486,15 @@ class RCCallClient {
1478
1486
  i++;
1479
1487
  }
1480
1488
  }
1481
- logger.info(`[RCCallClient hungupOtherSession] current sessionList length ->${this._sessionList.length}`);
1489
+ this._logger.info('_', `[RCCallClient hungupOtherSession] current sessionList length ->${this._sessionList.length}`);
1482
1490
  });
1483
1491
  }
1484
1492
  /**
1485
1493
  * 监听onInvite
1486
1494
  */
1487
1495
  _onInvite(stateMachine, extra) {
1488
- logger.info('[RCCallClient _onInvite] Received invite message');
1489
- const session = new RCCallSession(stateMachine, this._rtcClient, {
1496
+ this._logger.info('_', '[RCCallClient _onInvite] Received invite message');
1497
+ const session = new RCCallSession(stateMachine, this._rtcClient, this._logger, {
1490
1498
  // 是否允许订阅重试
1491
1499
  isAllowSubscribeRetry: this._options.isAllowSubscribeRetry,
1492
1500
  // 是否允许发布重试
@@ -1502,9 +1510,11 @@ class RCCallClient {
1502
1510
  // 允许降级获得流,获得音视频不成功 ,降级获得音频, 默认不允许
1503
1511
  isAllowDemotionGetStream: this._options.isAllowDemotionGetStream,
1504
1512
  // 标明是被叫产生的session
1505
- produceType: ProduceTypes.CALLEE
1513
+ produceType: ProduceTypes.CALLEE,
1514
+ callPushConfig: this._callPushConfig,
1515
+ hungupPushConfig: this._hungupPushConfig
1506
1516
  });
1507
- logger.info('[RCCallClient _onInvite] Received invite message, successfully created session');
1517
+ this._logger.info('_', '[RCCallClient _onInvite] Received invite message, successfully created session');
1508
1518
  /**
1509
1519
  * 如果通话的时候不允许接听新的通话,直接挂断, 这些工作在callEngine里完成
1510
1520
  */
@@ -1514,7 +1524,7 @@ class RCCallClient {
1514
1524
  this._options.onSession(session, extra);
1515
1525
  }
1516
1526
  catch (error) {
1517
- logger.error('[RCCallClient _options.onSession] onSession exception');
1527
+ this._logger.error('_', '[RCCallClient _options.onSession] onSession exception');
1518
1528
  console.log(error);
1519
1529
  }
1520
1530
  // 必须在onSession里注册session监听事件,这里检测一下有没有注册
@@ -1525,7 +1535,7 @@ class RCCallClient {
1525
1535
  }
1526
1536
  }
1527
1537
  else {
1528
- logger.error('[RCCallClient _options.onSession] session Must Have Listener');
1538
+ this._logger.error('_', '[RCCallClient _options.onSession] session Must Have Listener');
1529
1539
  throw new Error('[RCCallSession _options.onSession] session Must Have Listener');
1530
1540
  }
1531
1541
  }
@@ -1539,7 +1549,7 @@ class RCCallClient {
1539
1549
  this._options.onOfflineRecord && this._options.onOfflineRecord(record);
1540
1550
  }
1541
1551
  catch (error) {
1542
- logger.error('[RCCallClient _options.onOfflineRecord] onOfflineRecord exception');
1552
+ this._logger.error('_', '[RCCallClient _options.onOfflineRecord] onOfflineRecord exception');
1543
1553
  console.log(error);
1544
1554
  }
1545
1555
  }
@@ -1551,7 +1561,7 @@ class RCCallClient {
1551
1561
  */
1552
1562
  registerUserInfo(info = {}) {
1553
1563
  this._callEngine.registerUserInfo(info);
1554
- logger.info('[RCCallClient registerUserInfo] successfully register user info data');
1564
+ this._logger.info('_', '[RCCallClient registerUserInfo] successfully register user info data');
1555
1565
  }
1556
1566
  /**
1557
1567
  * 跨App单呼,发送invite消息,回调回来接收stateMachine, 建session
@@ -1561,14 +1571,15 @@ class RCCallClient {
1561
1571
  * @param params.constraints 获取音频或音视频资源时的参数 可选
1562
1572
  * @param params.channelId 组织 Id 可选
1563
1573
  * @param params.extra 消息扩展信息
1564
- * @param params.pushTitle 通知的标题
1565
- * @param params.pushContent 通知的内容
1574
+ * @deprecated 5.1.2 版本废弃 params.pushTitle 通知的标题
1575
+ * @deprecated 5.1.2 版本废弃 params.pushContent 通知的内容
1566
1576
  * @param params.bitrate 需要设置的码率参数
1567
1577
  *
1568
1578
  */
1569
1579
  startCrossCall({ targetId, mediaType = RCCallMediaType.AUDIO, listener, constraints, channelId = '', extra = '', pushTitle = '', pushContent = '', bitrate }) {
1570
1580
  return __awaiter(this, void 0, void 0, function* () {
1571
- return this.__call({ targetId, mediaType, listener, constraints, channelId, extra, pushTitle, pushContent, bitrate, isCrossAppkey: true });
1581
+ const { pushTitle: pushTitleValue, pushContent: pushContentValue } = (this._callPushConfig.pushTitle || this._callPushConfig.pushContent) ? this._callPushConfig : { pushTitle, pushContent };
1582
+ return this.__call({ targetId, mediaType, listener, constraints, channelId, extra, pushTitle: pushTitleValue, pushContent: pushContentValue, bitrate, isCrossAppkey: true });
1572
1583
  });
1573
1584
  }
1574
1585
  /**
@@ -1579,19 +1590,20 @@ class RCCallClient {
1579
1590
  * @param params.constraints 获取音频或音视频资源时的参数 可选
1580
1591
  * @param params.channelId 组织 Id 可选
1581
1592
  * @param params.extra 消息扩展信息
1582
- * @param params.pushTitle 通知的标题
1583
- * @param params.pushContent 通知的内容
1593
+ * @deprecated 5.1.2 版本废弃 params.pushTitle 通知的标题
1594
+ * @deprecated 5.1.2 版本废弃 params.pushContent 通知的内容
1584
1595
  * @param params.bitrate 需要设置的码率参数
1585
1596
  *
1586
1597
  */
1587
1598
  call({ targetId, mediaType = RCCallMediaType.AUDIO, listener, constraints, channelId = '', extra = '', pushTitle = '', pushContent = '', bitrate }) {
1588
1599
  return __awaiter(this, void 0, void 0, function* () {
1589
- return this.__call({ targetId, mediaType, listener, constraints, channelId, extra, pushTitle, pushContent, bitrate });
1600
+ const { pushTitle: pushTitleValue, pushContent: pushContentValue } = (this._callPushConfig.pushTitle || this._callPushConfig.pushContent) ? this._callPushConfig : { pushTitle, pushContent };
1601
+ return this.__call({ targetId, mediaType, listener, constraints, channelId, extra, pushTitle: pushTitleValue, pushContent: pushContentValue, bitrate });
1590
1602
  });
1591
1603
  }
1592
1604
  __call({ targetId, mediaType = RCCallMediaType.AUDIO, listener, constraints, channelId = '', extra = '', pushTitle = '', pushContent = '', bitrate, isCrossAppkey = false }) {
1593
1605
  return __awaiter(this, void 0, void 0, function* () {
1594
- logger.info(`[RCCallClient call] extra->${extra} pushTitle->${pushTitle} pushContent->${pushContent}`);
1606
+ this._logger.info('_', `[RCCallClient call] extra->${extra} pushTitle->${pushTitle} pushContent->${pushContent}`);
1595
1607
  const conclusion = [validateTargetId(targetId), validateMediaType(mediaType), validateListener(listener), validateExtra(extra), validatePushTitle(pushTitle), validatePushContent(pushContent)];
1596
1608
  const messages = [];
1597
1609
  const result = conclusion.every((obj) => {
@@ -1622,8 +1634,8 @@ class RCCallClient {
1622
1634
  // 调用callEngine的call返回一个状态机的实例
1623
1635
  const { code, stateMachine } = yield this._callEngine.call(channelId, targetId, mediaType, extra, pushTitle, pushContent, isCrossAppkey);
1624
1636
  if (code === RCCallErrorCode.SUCCESS && stateMachine) {
1625
- logger.info('[RCCallClient call] successfully created state machine');
1626
- const session = new RCCallSession(stateMachine, this._rtcClient, {
1637
+ this._logger.info('_', '[RCCallClient call] successfully created state machine');
1638
+ const session = new RCCallSession(stateMachine, this._rtcClient, this._logger, {
1627
1639
  localTracks,
1628
1640
  // 是否允许订阅重试
1629
1641
  isAllowSubscribeRetry: this._options.isAllowSubscribeRetry,
@@ -1641,16 +1653,18 @@ class RCCallClient {
1641
1653
  isAllowDemotionGetStream: this._options.isAllowDemotionGetStream,
1642
1654
  // 标明是主叫产生的session
1643
1655
  produceType: ProduceTypes.CALLER,
1644
- isCrossAppkey
1656
+ isCrossAppkey,
1657
+ callPushConfig: this._callPushConfig,
1658
+ hungupPushConfig: this._hungupPushConfig
1645
1659
  });
1646
1660
  // session上注册监听事件
1647
1661
  session.registerSessionListener(listener);
1648
1662
  this._sessionList.push(session);
1649
- logger.info(`[RCCallClient call] successfully created session object, sessionId: ${session.getSessionId()}`);
1663
+ this._logger.info('_', `[RCCallClient call] successfully created session object, sessionId: ${session.getSessionId()}`);
1650
1664
  return { code, session };
1651
1665
  }
1652
1666
  else {
1653
- logger.error(`[RCCallClient call] call failed code ->: ${code}`);
1667
+ this._logger.error('_', `[RCCallClient call] call failed code ->: ${code}`);
1654
1668
  localTracks.forEach(track => {
1655
1669
  // 禁用视频
1656
1670
  track.mute();
@@ -1670,13 +1684,13 @@ class RCCallClient {
1670
1684
  * @param params.constraints 获取音频或音视频资源时的参数 可选
1671
1685
  * @param params.channelId 组织 Id 可选
1672
1686
  * @param params.extra 消息扩展信息 可选
1673
- * @param params.pushTitle 通知的标题
1674
- * @param params.pushContent 通知的内容
1687
+ * @deprecated 5.1.2 版本废弃 params.pushTitle 通知的标题
1688
+ * @deprecated 5.1.2 版本废弃 params.pushContent 通知的内容
1675
1689
  * @param params.bitrate 需要设置的码率参数
1676
1690
  */
1677
- callInGroup({ targetId, userIds, mediaType = RCCallMediaType.AUDIO, listener, constraints, channelId = '', extra = '', pushTitle = '', pushContent = '', bitrate }) {
1691
+ callInGroup({ targetId, userIds, mediaType = RCCallMediaType.AUDIO, listener, constraints, channelId = '', extra = '', bitrate }) {
1678
1692
  return __awaiter(this, void 0, void 0, function* () {
1679
- const conclusion = [validateTargetId(targetId), validateUserIds(userIds), validateMediaType(mediaType), validateListener(listener), validateExtra(extra), validatePushTitle(pushTitle), validatePushContent(pushContent)];
1693
+ const conclusion = [validateTargetId(targetId), validateUserIds(userIds), validateMediaType(mediaType), validateListener(listener), validateExtra(extra)];
1680
1694
  const messages = [];
1681
1695
  const result = conclusion.every((obj) => {
1682
1696
  !obj.result && messages.push(obj.msg);
@@ -1704,10 +1718,11 @@ class RCCallClient {
1704
1718
  listener.onTrackReady(track);
1705
1719
  });
1706
1720
  // 往组里发消息
1721
+ const { pushTitle, pushContent } = this._callPushConfig;
1707
1722
  const { code, stateMachine } = yield this._callEngine.callInGroup(channelId, targetId, mediaType, userIds, extra, pushTitle, pushContent);
1708
1723
  if (code === RCCallErrorCode.SUCCESS && stateMachine) {
1709
- logger.info('[RCCallClient callInGroup] successfully created state machine');
1710
- const session = new RCCallSession(stateMachine, this._rtcClient, {
1724
+ this._logger.info('_', '[RCCallClient callInGroup] successfully created state machine');
1725
+ const session = new RCCallSession(stateMachine, this._rtcClient, this._logger, {
1711
1726
  localTracks,
1712
1727
  // 是否允许订阅重试
1713
1728
  isAllowSubscribeRetry: this._options.isAllowSubscribeRetry,
@@ -1724,16 +1739,18 @@ class RCCallClient {
1724
1739
  // 允许降级获得流,获得音视频不成功 ,降级获得音频, 默认不允许
1725
1740
  isAllowDemotionGetStream: this._options.isAllowDemotionGetStream,
1726
1741
  // 标明是主叫产生的session
1727
- produceType: ProduceTypes.CALLER
1742
+ produceType: ProduceTypes.CALLER,
1743
+ callPushConfig: this._callPushConfig,
1744
+ hungupPushConfig: this._hungupPushConfig
1728
1745
  });
1729
1746
  // session上注册监听事件
1730
1747
  session.registerSessionListener(listener);
1731
1748
  this._sessionList.push(session);
1732
- logger.info(`[RCCallClient callInGroup] successfully created session object, sessionId: ${session.getSessionId()}`);
1749
+ this._logger.info('_', `[RCCallClient callInGroup] successfully created session object, sessionId: ${session.getSessionId()}`);
1733
1750
  return { code, session };
1734
1751
  }
1735
1752
  else {
1736
- logger.info(`[RCCallClient callInGroup] callInGroup failed code -> ${code}`);
1753
+ this._logger.info('_', `[RCCallClient callInGroup] callInGroup failed code -> ${code}`);
1737
1754
  localTracks.forEach(track => {
1738
1755
  // 禁用视频
1739
1756
  track.mute();
@@ -1753,19 +1770,19 @@ class RCCallClient {
1753
1770
  if (mediaType === RCCallMediaType.AUDIO) {
1754
1771
  const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', constraints && constraints.audio && Object.assign({}, constraints.audio));
1755
1772
  if (code !== RCRTCCode.SUCCESS) {
1756
- logger.error(`[RCCallClient _getTrack] get Audio local tracks failed RCT code -> ${code}`);
1773
+ this._logger.error('_', `[RCCallClient _getTrack] get Audio local tracks failed RCT code -> ${code}`);
1757
1774
  return { code: RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
1758
1775
  }
1759
- logger.info('[RCCallClient _getTrack] successfully get Audio local tracks');
1776
+ this._logger.info('_', '[RCCallClient _getTrack] successfully get Audio local tracks');
1760
1777
  return { code: RCCallErrorCode.SUCCESS, tracks: [track] };
1761
1778
  }
1762
1779
  else {
1763
1780
  const { code, tracks } = yield this._rtcClient.createMicrophoneAndCameraTracks('RongCloudRTC', constraints && Object.assign({}, constraints));
1764
1781
  if (code !== RCRTCCode.SUCCESS) {
1765
- logger.error(`[RCCallClient _getTrack] get Audio and Video local tracks failed RCT code -> ${code}`);
1782
+ this._logger.error('_', `[RCCallClient _getTrack] get Audio and Video local tracks failed RCT code -> ${code}`);
1766
1783
  return { code: RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR };
1767
1784
  }
1768
- logger.info('[RCCallClient _getTrack] successfully get audio and video local tracks');
1785
+ this._logger.info('_', '[RCCallClient _getTrack] successfully get audio and video local tracks');
1769
1786
  return { code: RCCallErrorCode.SUCCESS, tracks };
1770
1787
  }
1771
1788
  });
@@ -1808,14 +1825,40 @@ class RCCallClient {
1808
1825
  return __awaiter(this, void 0, void 0, function* () {
1809
1826
  const { code, data } = yield this._context.getRTCJoinedUserInfo(this._context.getCurrentId());
1810
1827
  if (code !== ErrorCode.SUCCESS) {
1811
- logger.error('getJoinedUserInfo error', code);
1828
+ this._logger.error('_', `getJoinedUserInfo error code: ${code}`);
1812
1829
  return { code: RCCallErrorCode.QUERY_JOINED_USER_INFO_ERROR };
1813
1830
  }
1814
1831
  return { code: RCCallErrorCode.SUCCESS, data };
1815
1832
  });
1816
1833
  }
1834
+ /**
1835
+ * 设置呼叫、挂断推送数据
1836
+ * @param callPushConfig 呼叫推送配置
1837
+ * @param callPushConfig.pushTitle 呼叫推送标题
1838
+ * @param callPushConfig.pushContent 呼叫推送内容
1839
+ * @param hungupPushConfig 挂断推送配置
1840
+ * @param hungupPushConfig.pushTitle 挂断推送标题
1841
+ * @param hungupPushConfig.pushContent 挂断推送内容
1842
+ */
1843
+ setPushConfig(callPushConfig = {}, hungupPushConfig = {}) {
1844
+ const conclusion = [callPushConfig, hungupPushConfig].map((pushConfig) => {
1845
+ return validatePushConfig(pushConfig);
1846
+ })[0];
1847
+ const messages = [];
1848
+ const result = conclusion.every((obj) => {
1849
+ !obj.result && messages.push(obj.msg);
1850
+ return obj.result;
1851
+ });
1852
+ if (!result) {
1853
+ throw new Error(`[RCCallClient callInGroup callPushConfig or hungupPushConfig] ${messages.join('\n')}`);
1854
+ }
1855
+ this._callPushConfig = callPushConfig;
1856
+ this._hungupPushConfig = hungupPushConfig;
1857
+ }
1817
1858
  }
1818
1859
 
1860
+ // plugin-call 版本上报
1861
+ VersionManage.add('plugin-call', "5.1.2-alpha.2");
1819
1862
  const installer = {
1820
1863
  tag: 'RCCall',
1821
1864
  verify(runtime) {
@@ -1827,10 +1870,13 @@ const installer = {
1827
1870
  if (!conclusion.result) {
1828
1871
  throw new Error(`[RCCallLib installer steup]${conclusion.msg}`);
1829
1872
  }
1830
- logger.setLogLevel(options.logLevel);
1831
- logger.setLogStdout(options.logStdout);
1832
- logger.warn(`RCCall Version: ${"5.1.2-alpha.1"}, Commit: ${"5a6d3a159d1171c71f1bb419dfac59eb8e886f91"}`);
1833
- return new RCCallClient(context, runtime, options);
1873
+ // 校验当前安装的 engine 版本是否可用
1874
+ if (!VersionManage.validEngine("^5.7.0")) {
1875
+ throw new Error(`The current engine version '${VersionManage.getInfo().engine}' error, plugin-call required engine version at least '${"^5.7.0"}'.`);
1876
+ }
1877
+ const logger = context.createLogger('RCCall', 'RTC');
1878
+ logger.warn('_', `RCCall Version: ${"5.1.2-alpha.2"}, Commit: ${"8d4f8b00cda704283faad34d0e81a4e048e09d08"}`);
1879
+ return new RCCallClient(context, runtime, logger, options);
1834
1880
  }
1835
1881
  };
1836
1882