@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.js CHANGED
@@ -1,19 +1,17 @@
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
7
  'use strict';
8
8
 
9
9
  Object.defineProperty(exports, '__esModule', { value: true });
10
10
 
11
- var pluginCallEngine = require('@rongcloud/plugin-call-engine');
12
11
  var engine = require('@rongcloud/engine');
12
+ var pluginCallEngine = require('@rongcloud/plugin-call-engine');
13
13
  var pluginRtc = require('@rongcloud/plugin-rtc');
14
14
 
15
- const logger = new engine.Logger('RCCall');
16
-
17
15
  /*! *****************************************************************************
18
16
  Copyright (c) Microsoft Corporation.
19
17
 
@@ -257,6 +255,11 @@ const validatePushContent = (pushContent) => {
257
255
  return { result: false, msg: '\'pushContent\' parameter must be of type \'string\'' };
258
256
  }
259
257
  };
258
+ const validatePushConfig = (pushConfig) => {
259
+ const { pushTitle, pushContent } = pushConfig;
260
+ const conclusion = [validatePushTitle(pushTitle), validatePushContent(pushContent)];
261
+ return conclusion;
262
+ };
260
263
  const validateUserIds = (userIds) => {
261
264
  if (!Array.isArray(userIds)) {
262
265
  return { result: false, msg: '\'userIds\' parameter is required, must be of type \'string[]\'' };
@@ -350,13 +353,14 @@ class RCCallSession {
350
353
  /**
351
354
  * rtc实例
352
355
  */
353
- _rtcClient,
356
+ _rtcClient, _logger,
354
357
  /**
355
358
  * session的其它选项
356
359
  */
357
360
  _options = {}) {
358
361
  this._stateMachine = _stateMachine;
359
362
  this._rtcClient = _rtcClient;
363
+ this._logger = _logger;
360
364
  this._options = _options;
361
365
  /**
362
366
  * 用户传进来的 对session的监听 (要在RCCallClient的_onInvite里判断,要求执行完onSession必须注册session的监听,所以这里是public)
@@ -377,7 +381,7 @@ class RCCallSession {
377
381
  * @param info
378
382
  */
379
383
  onUserStateChange: ({ user, reason }) => {
380
- 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}`);
384
+ 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}`);
381
385
  },
382
386
  /**
383
387
  * 房间状态变更
@@ -385,18 +389,18 @@ class RCCallSession {
385
389
  */
386
390
  onStateChange: (info) => __awaiter(this, void 0, void 0, function* () {
387
391
  const { state, reason } = info;
388
- logger.info(`[RCCallSession onStateChange] : state->${state} reason->${reason}`);
392
+ this._logger.info('_', `[RCCallSession onStateChange] : state->${state} reason->${reason}`);
389
393
  // 如果在通话中,就加房间
390
394
  if (state === pluginCallEngine.RCCallSessionState.KEEPING) {
391
395
  const roomId = this._stateMachine.getCallId();
392
- logger.info(`[RCCallSession onStateChange] roomId: ${roomId}`);
396
+ this._logger.info('_', `[RCCallSession onStateChange] roomId: ${roomId}`);
393
397
  try {
394
398
  // 加房间
395
399
  yield this._joinRoom(roomId);
396
400
  }
397
401
  catch (error) {
398
402
  this._exceptionClose(pluginCallEngine.RCCallEndReason.NETWORK_ERROR);
399
- logger.error(`[RCCallSession onStateChange] joinRoom throw exception roomId -> ${roomId}`);
403
+ this._logger.error('_', `[RCCallSession onStateChange] joinRoom throw exception roomId -> ${roomId}`);
400
404
  console.error(error);
401
405
  }
402
406
  /**
@@ -416,7 +420,7 @@ class RCCallSession {
416
420
  return;
417
421
  }
418
422
  this._options.localTracks && this._destroyTracks(this._options.localTracks);
419
- logger.info('[RCCallSession onStateChange] localTracks destroyed');
423
+ this._logger.info('_', '[RCCallSession onStateChange] localTracks destroyed');
420
424
  this._leaveRoom();
421
425
  this._room = null;
422
426
  }
@@ -426,13 +430,13 @@ class RCCallSession {
426
430
  * @param sender 发起用户信息
427
431
  */
428
432
  onRinging: (sender) => {
429
- logger.info(`[RCCallSession onRinging]sender: sender.userId -> ${sender.userId}`);
433
+ this._logger.info('_', `[RCCallSession onRinging]sender: sender.userId -> ${sender.userId}`);
430
434
  try {
431
435
  // 通知用户响铃
432
436
  this._listener.onRinging(sender, this);
433
437
  }
434
438
  catch (error) {
435
- logger.error('[RCCallSession onRinging] method exception -> onRinging');
439
+ this._logger.error('_', '[RCCallSession onRinging] method exception -> onRinging');
436
440
  console.error(error);
437
441
  }
438
442
  },
@@ -440,13 +444,13 @@ class RCCallSession {
440
444
  * 当远端用户同意接听
441
445
  */
442
446
  onAccept: (sender) => {
443
- logger.info(`[RCCallSession onAccept]sender: sender.userId -> ${sender.userId}`);
447
+ this._logger.info('_', `[RCCallSession onAccept]sender: sender.userId -> ${sender.userId}`);
444
448
  try {
445
449
  // 通知本端,远端用户已接听
446
450
  this._listener.onAccept(sender, this);
447
451
  }
448
452
  catch (error) {
449
- logger.error('[RCCallSession onAccept] method exception -> onAccept');
453
+ this._logger.error('_', '[RCCallSession onAccept] method exception -> onAccept');
450
454
  console.error(error);
451
455
  }
452
456
  },
@@ -454,13 +458,13 @@ class RCCallSession {
454
458
  * 当有远端用户挂断
455
459
  */
456
460
  onHungup: (sender, reason) => {
457
- logger.info(`[RCCallSession onHungup]sender: sender.userId -> ${sender.userId} reason->${reason}`);
461
+ this._logger.info('_', `[RCCallSession onHungup]sender: sender.userId -> ${sender.userId} reason->${reason}`);
458
462
  try {
459
463
  // 通知本端,远端用户已挂断
460
464
  this._listener.onHungup(sender, reason, this);
461
465
  }
462
466
  catch (error) {
463
- logger.error('[RCCallSession onHungup] method exception -> onHungup');
467
+ this._logger.error('_', '[RCCallSession onHungup] method exception -> onHungup');
464
468
  console.error(error);
465
469
  }
466
470
  },
@@ -469,13 +473,13 @@ class RCCallSession {
469
473
  * @param sender 发起用户信息
470
474
  */
471
475
  onMemberModify: ({ sender, invitedUsers }) => {
472
- logger.info(`[RCCallSession onMemberModify] sender.userId -> ${sender.userId}`);
476
+ this._logger.info('_', `[RCCallSession onMemberModify] sender.userId -> ${sender.userId}`);
473
477
  try {
474
478
  // 通知用户人员变更
475
479
  this._listener.onMemberModify(sender, invitedUsers, this);
476
480
  }
477
481
  catch (error) {
478
- logger.error('[RCCallSession onMemberModify] method exception -> onMemberModify');
482
+ this._logger.error('_', '[RCCallSession onMemberModify] method exception -> onMemberModify');
479
483
  console.error(error);
480
484
  }
481
485
  },
@@ -484,7 +488,7 @@ class RCCallSession {
484
488
  * @param sender 发起用户信息
485
489
  */
486
490
  onMediaModify: ({ sender, mediaType }) => {
487
- logger.info(`[RCCallSession onMediaModify]sender: sender.userId -> ${sender.userId} mediaType: ${mediaType}`);
491
+ this._logger.info('_', `[RCCallSession onMediaModify]sender: sender.userId -> ${sender.userId} mediaType: ${mediaType}`);
488
492
  if (mediaType === pluginCallEngine.RCCallMediaType.AUDIO) {
489
493
  // 远端收到通话降级通知后,远端执行降级通话(不发消息)
490
494
  this._setMediaTypeToAudio();
@@ -493,7 +497,7 @@ class RCCallSession {
493
497
  this._listener.onMediaModify(sender, mediaType, this);
494
498
  }
495
499
  catch (error) {
496
- logger.error('[RCCallSession onMediaModify] method exception -> onMediaModify');
500
+ this._logger.error('_', '[RCCallSession onMediaModify] method exception -> onMediaModify');
497
501
  console.error(error);
498
502
  }
499
503
  },
@@ -502,10 +506,15 @@ class RCCallSession {
502
506
  * @param sender 发起用户信息
503
507
  */
504
508
  crossAppkey: (isCrossAppkey) => {
505
- logger.info(`[RCCallSession crossAppkey] 是否跨 appkey: ${isCrossAppkey}`);
509
+ this._logger.info('_', `[RCCallSession crossAppkey] 是否跨 appkey: ${isCrossAppkey}`);
506
510
  this._options.isCrossAppkey = isCrossAppkey;
507
511
  }
508
512
  });
513
+ /**
514
+ * 设置挂断的推送信息
515
+ */
516
+ const { pushTitle, pushContent } = this._options.hungupPushConfig;
517
+ this._stateMachine.setHungupPushConfig(pushTitle, pushContent);
509
518
  }
510
519
  /**
511
520
  * 加入房间
@@ -534,7 +543,7 @@ class RCCallSession {
534
543
  else {
535
544
  this._exceptionClose(pluginCallEngine.RCCallEndReason.NETWORK_ERROR);
536
545
  }
537
- logger.info(`[RCCallClient _joinRoom] join room failed: roomId -> ${roomId} RCRTCCode -> ${code}`);
546
+ this._logger.info('_', `[RCCallClient _joinRoom] join room failed: roomId -> ${roomId} RCRTCCode -> ${code}`);
538
547
  return { code: pluginCallEngine.RCCallErrorCode.JOIN_ROOM_ERROR };
539
548
  }
540
549
  /**
@@ -557,7 +566,7 @@ class RCCallSession {
557
566
  }
558
567
  catch (error) {
559
568
  this._exceptionClose(pluginCallEngine.RCCallEndReason.NETWORK_ERROR);
560
- logger.error(`[RCCallSession _joinRoom] _rtcClient.joinRTCRoom throw exception roomId -> ${roomId}`);
569
+ this._logger.error('_', `[RCCallSession _joinRoom] _rtcClient.joinRTCRoom throw exception roomId -> ${roomId}`);
561
570
  console.error(error);
562
571
  return { code: pluginCallEngine.RCCallErrorCode.JOIN_ROOM_ERROR };
563
572
  }
@@ -572,7 +581,7 @@ class RCCallSession {
572
581
  catch (error) {
573
582
  // 结束通话session
574
583
  this._exceptionClose(pluginCallEngine.RCCallEndReason.SUBSCRIBE_ERROR);
575
- logger.error(`[RCCallSession _joinRoom] _subscribeInRoomRemoteTrack Exception roomId -> ${roomId}`);
584
+ this._logger.error('_', `[RCCallSession _joinRoom] _subscribeInRoomRemoteTrack Exception roomId -> ${roomId}`);
576
585
  console.error(error);
577
586
  return { code: pluginCallEngine.RCCallErrorCode.JOIN_ROOM_ERROR };
578
587
  }
@@ -583,7 +592,7 @@ class RCCallSession {
583
592
  catch (error) {
584
593
  // 结束通话session
585
594
  this._exceptionClose(pluginCallEngine.RCCallEndReason.PUBLISH_ERROR);
586
- logger.error(`[RCCallSession _joinRoom] _publish Exception roomId -> ${roomId}`);
595
+ this._logger.error('_', `[RCCallSession _joinRoom] _publish Exception roomId -> ${roomId}`);
587
596
  console.error(error);
588
597
  return { code: pluginCallEngine.RCCallErrorCode.JOIN_ROOM_ERROR };
589
598
  }
@@ -601,7 +610,7 @@ class RCCallSession {
601
610
  const { code } = yield this._subscribeRetry(tracks, this._options.isAllowSubscribeRetry, this._RETRYCOUNT);
602
611
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
603
612
  this._exceptionClose(pluginCallEngine.RCCallEndReason.SUBSCRIBE_ERROR);
604
- logger.error(`[RCCallSession _subscribeInRoomRemoteTrack] Resource subscription failed roomId -> ${this._stateMachine.getCallId()} RTC code -> ${code}`);
613
+ this._logger.error('_', `[RCCallSession _subscribeInRoomRemoteTrack] Resource subscription failed roomId -> ${this._stateMachine.getCallId()} RTC code -> ${code}`);
605
614
  }
606
615
  }
607
616
  });
@@ -620,7 +629,7 @@ class RCCallSession {
620
629
  this._listener.onTrackSubscribeFail && this._listener.onTrackSubscribeFail(code, this);
621
630
  }
622
631
  catch (error) {
623
- logger.error('[RCCallSession] _listener.onTrackSubscribeFail exception');
632
+ this._logger.error('_', '[RCCallSession] _listener.onTrackSubscribeFail exception');
624
633
  console.error(error);
625
634
  }
626
635
  // 如果不允许重试,直接返回
@@ -646,7 +655,7 @@ class RCCallSession {
646
655
  // 若资源发布失败
647
656
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
648
657
  this._exceptionClose(pluginCallEngine.RCCallEndReason.PUBLISH_ERROR);
649
- logger.info(`[RCCallSession _publist] Resource publishing failed: roomId -> ${this._stateMachine.getCallId()} RCRTCCode -> ${code}`);
658
+ this._logger.info('_', `[RCCallSession _publist] Resource publishing failed: roomId -> ${this._stateMachine.getCallId()} RCRTCCode -> ${code}`);
650
659
  return;
651
660
  }
652
661
  // 如果是主动发起的呼叫,已提前抛出了资源, 被动呼叫,这里才需要抛出
@@ -670,7 +679,7 @@ class RCCallSession {
670
679
  this._listener.onTrackPublishFail && this._listener.onTrackPublishFail(code, this);
671
680
  }
672
681
  catch (error) {
673
- logger.error('[RCCallSession] _listener.onTrackPublishFail exception');
682
+ this._logger.error('_', '[RCCallSession] _listener.onTrackPublishFail exception');
674
683
  console.error(error);
675
684
  }
676
685
  // 如果不允许重试,直接返回
@@ -694,10 +703,10 @@ class RCCallSession {
694
703
  // 退出房间
695
704
  const callBack = yield this._rtcClient.leaveRoom(this._room);
696
705
  // 成功退出房间,触发RCCallClient实例上的onSessionClose监听,抛给用户信息
697
- logger.info('[RCCallSession _leaveRoom] Successfully exited the room', callBack);
706
+ this._logger.info('_', `[RCCallSession _leaveRoom] Successfully exited the room code: ${callBack.code}`);
698
707
  }
699
708
  catch (error) {
700
- logger.error('[RCCallSession _leaveRoom] leaveRoom throw exception');
709
+ this._logger.error('_', '[RCCallSession _leaveRoom] leaveRoom throw exception');
701
710
  console.error(error);
702
711
  }
703
712
  finally {
@@ -736,19 +745,19 @@ class RCCallSession {
736
745
  if (mediaType === pluginCallEngine.RCCallMediaType.AUDIO) {
737
746
  const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', constraints && constraints.audio && Object.assign({}, constraints.audio));
738
747
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
739
- logger.error(`[RCCallSession _getLocalTrackCore] get Audio local tracks failed RCT code -> ${code}`);
748
+ this._logger.error('_', `[RCCallSession _getLocalTrackCore] get Audio local tracks failed RCT code -> ${code}`);
740
749
  return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
741
750
  }
742
- logger.info('[RCCallSession _getLocalTrackCore] successfully get Audio local tracks');
751
+ this._logger.info('_', '[RCCallSession _getLocalTrackCore] successfully get Audio local tracks');
743
752
  return { code: pluginCallEngine.RCCallErrorCode.SUCCESS, tracks: [track] };
744
753
  }
745
754
  else {
746
755
  const { code, tracks } = yield this._rtcClient.createMicrophoneAndCameraTracks('RongCloudRTC', constraints && Object.assign({}, constraints));
747
756
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
748
- logger.error(`[RCCallSession _getLocalTrackCore] get Audio and Video local tracks failed RCT code -> ${code}`);
757
+ this._logger.error('_', `[RCCallSession _getLocalTrackCore] get Audio and Video local tracks failed RCT code -> ${code}`);
749
758
  return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR };
750
759
  }
751
- logger.info('[RCCallSession _getLocalTrackCore] successfully get audio and video local tracks');
760
+ this._logger.info('_', '[RCCallSession _getLocalTrackCore] successfully get audio and video local tracks');
752
761
  return { code: pluginCallEngine.RCCallErrorCode.SUCCESS, tracks };
753
762
  }
754
763
  });
@@ -792,7 +801,7 @@ class RCCallSession {
792
801
  const localTracks = [];
793
802
  const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', audioConstraints);
794
803
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
795
- logger.error(`[RCCallSession changeDevice] get local Audio tracks failed RCTLib code -> ${code}`);
804
+ this._logger.error('_', `[RCCallSession changeDevice] get local Audio tracks failed RCTLib code -> ${code}`);
796
805
  return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
797
806
  }
798
807
  this._options.localTracks && this._options.localTracks.forEach((track) => {
@@ -823,12 +832,14 @@ class RCCallSession {
823
832
  * 群呼叫中继续邀请
824
833
  * @param userIds 被邀请用户 ID 列表
825
834
  * @param options.extra 消息的扩展信息
826
- * @param options.pushTitle 通知的标题
827
- * @param options.pushContent 通知内容
835
+ * @deprecated 5.1.2 废弃 options.pushTitle 通知的标题
836
+ * @deprecated 5.1.2 废弃 options.pushContent 通知内容
828
837
  */
829
838
  invite(userIds, options = {}) {
839
+ var _a, _b;
830
840
  return __awaiter(this, void 0, void 0, function* () {
831
- const { extra = '', pushTitle = '', pushContent = '' } = options;
841
+ const { extra = '' } = options;
842
+ 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;
832
843
  const conclusion = [validateUserIds(userIds), validateExtra(extra), validatePushTitle(pushTitle), validatePushContent(pushContent)];
833
844
  const messages = [];
834
845
  const result = conclusion.every((obj) => {
@@ -862,7 +873,7 @@ class RCCallSession {
862
873
  // 发送接听的消息
863
874
  const { code } = yield this._stateMachine.accept();
864
875
  if (code !== pluginCallEngine.RCCallErrorCode.SUCCESS) {
865
- logger.error(`[RCCallSession accept]Send accept message failed -> code: ${code}`);
876
+ this._logger.error('_', `[RCCallSession accept]Send accept message failed -> code: ${code}`);
866
877
  return { code };
867
878
  }
868
879
  return { code };
@@ -886,7 +897,7 @@ class RCCallSession {
886
897
  return __awaiter(this, void 0, void 0, function* () {
887
898
  const { code } = yield this._stateMachine.changeMediaType(mediaType);
888
899
  if (code !== pluginCallEngine.RCCallErrorCode.SUCCESS) {
889
- logger.error(`[RCCallSession _changeMediaType] change media type fail code-> ${code}`);
900
+ this._logger.error('_', `[RCCallSession _changeMediaType] change media type fail code-> ${code}`);
890
901
  }
891
902
  return { code };
892
903
  });
@@ -935,7 +946,7 @@ class RCCallSession {
935
946
  const { code: _code } = yield this._room.publish([track]);
936
947
  // 若资源发布失败
937
948
  if (_code !== pluginRtc.RCRTCCode.SUCCESS) {
938
- logger.error(`[RCCallSession _enableVideo] Resource publishing failed: RCRTCCode -> ${code}`);
949
+ this._logger.error('_', `[RCCallSession _enableVideo] Resource publishing failed: RCRTCCode -> ${code}`);
939
950
  return;
940
951
  }
941
952
  // 通知业务层trackReady
@@ -959,7 +970,7 @@ class RCCallSession {
959
970
  // 取消发布视频
960
971
  const { code } = yield this._room.unpublish(tracks);
961
972
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
962
- logger.error(`[RCCallSession disableVideo] unpublish failed -> ${code}`);
973
+ this._logger.error('_', `[RCCallSession disableVideo] unpublish failed -> ${code}`);
963
974
  }
964
975
  // 关闭摄像头
965
976
  this._destroyTracks(tracks);
@@ -985,12 +996,12 @@ class RCCallSession {
985
996
  disableVideoTrack() {
986
997
  return __awaiter(this, void 0, void 0, function* () {
987
998
  if (!this._room) {
988
- logger.error(`[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
999
+ this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
989
1000
  return { code: pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR };
990
1001
  }
991
1002
  const tracks = this._getLocalVideoTracks();
992
1003
  if (!tracks.length) {
993
- logger.error(`[RCCallSession disableVideoTrack] Room missing video track -> ${pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
1004
+ this._logger.error('_', `[RCCallSession disableVideoTrack] Room missing video track -> ${pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
994
1005
  return { code: pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR };
995
1006
  }
996
1007
  // 禁用视频
@@ -1004,7 +1015,7 @@ class RCCallSession {
1004
1015
  // 取消发布视频
1005
1016
  const { code } = yield this._room.unpublish(tracks);
1006
1017
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
1007
- logger.error(`[RCCallSession disableVideo] unpublish failed -> ${code}`);
1018
+ this._logger.error('_', `[RCCallSession disableVideo] unpublish failed -> ${code}`);
1008
1019
  return { code: pluginCallEngine.RCCallErrorCode.UNPUBLISH_VIDEO_ERROR };
1009
1020
  }
1010
1021
  tracks.forEach((track) => {
@@ -1020,14 +1031,14 @@ class RCCallSession {
1020
1031
  enableVideoTrack() {
1021
1032
  return __awaiter(this, void 0, void 0, function* () {
1022
1033
  if (!this._room) {
1023
- logger.error(`[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
1034
+ this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
1024
1035
  return { code: pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR };
1025
1036
  }
1026
1037
  // 如果不需关闭摄像头
1027
1038
  if (!this._options.isOffCameraWhenVideoDisable) {
1028
1039
  const tracks = this._getLocalVideoTracks();
1029
1040
  if (!tracks.length) {
1030
- logger.error(`[RCCallSession EnableVideoTrack] Room missing video track -> ${pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
1041
+ this._logger.error('_', `[RCCallSession EnableVideoTrack] Room missing video track -> ${pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
1031
1042
  return { code: pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR };
1032
1043
  }
1033
1044
  // 启用视频
@@ -1039,7 +1050,7 @@ class RCCallSession {
1039
1050
  // 获得本端视频资源
1040
1051
  const { code, track } = yield this._rtcClient.createCameraVideoTrack();
1041
1052
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
1042
- logger.error(`[RCCallSession EnableVideoTrack] Get Resource failed: RCRTCCode -> ${code}`);
1053
+ this._logger.error('_', `[RCCallSession EnableVideoTrack] Get Resource failed: RCRTCCode -> ${code}`);
1043
1054
  return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_VIDEO_TRACK_ERROR };
1044
1055
  }
1045
1056
  const localTracks = [];
@@ -1062,7 +1073,7 @@ class RCCallSession {
1062
1073
  const { code: _code } = yield this._room.publish([track]);
1063
1074
  // 若资源发布失败
1064
1075
  if (_code !== pluginRtc.RCRTCCode.SUCCESS) {
1065
- logger.error(`[RCCallSession EnableVideoTrack] Resource publishing failed: RCRTCCode -> ${code}`);
1076
+ this._logger.error('_', `[RCCallSession EnableVideoTrack] Resource publishing failed: RCRTCCode -> ${code}`);
1066
1077
  return { code: pluginCallEngine.RCCallErrorCode.VIDEO_PUBLISH_ERROR };
1067
1078
  }
1068
1079
  // 启用
@@ -1078,7 +1089,7 @@ class RCCallSession {
1078
1089
  disableAudioTrack() {
1079
1090
  return __awaiter(this, void 0, void 0, function* () {
1080
1091
  if (!this._room) {
1081
- logger.error(`[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
1092
+ this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
1082
1093
  return { code: pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR };
1083
1094
  }
1084
1095
  const tracks = this._getLocalAudioTracks();
@@ -1094,12 +1105,12 @@ class RCCallSession {
1094
1105
  enableAudioTrack() {
1095
1106
  return __awaiter(this, void 0, void 0, function* () {
1096
1107
  if (!this._room) {
1097
- logger.error(`[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
1108
+ this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
1098
1109
  return { code: pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR };
1099
1110
  }
1100
1111
  const tracks = this._getLocalAudioTracks();
1101
1112
  if (!tracks.length) {
1102
- logger.error(`[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
1113
+ this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
1103
1114
  return { code: pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR };
1104
1115
  }
1105
1116
  // 启用音频
@@ -1125,7 +1136,7 @@ class RCCallSession {
1125
1136
  this._listener.onTrackReady(track, this);
1126
1137
  }
1127
1138
  catch (error) {
1128
- logger.error('[RCCallSession _notifyTrackReady] _listener onTrackReady exception');
1139
+ this._logger.error('_', '[RCCallSession _notifyTrackReady] _listener onTrackReady exception');
1129
1140
  console.error(error);
1130
1141
  }
1131
1142
  });
@@ -1179,7 +1190,7 @@ class RCCallSession {
1179
1190
  * @param audioTrack RCRemoteAudioTrack 类实例
1180
1191
  */
1181
1192
  onAudioMuteChange: (audioTrack) => {
1182
- logger.info(`[RCCallSession onAudioMuteChange] userId->${audioTrack.getUserId()} muted -> ${audioTrack.isOwnerMuted()}`);
1193
+ this._logger.info('_', `[RCCallSession onAudioMuteChange] userId->${audioTrack.getUserId()} muted -> ${audioTrack.isOwnerMuted()}`);
1183
1194
  const muteUser = {
1184
1195
  userId: audioTrack.getUserId(),
1185
1196
  muted: audioTrack.isOwnerMuted(),
@@ -1191,7 +1202,7 @@ class RCCallSession {
1191
1202
  this._listener.onAudioMuteChange(muteUser, this);
1192
1203
  }
1193
1204
  catch (error) {
1194
- logger.error('[RCCallSession onAudioMuteChange] Missing listening method -> onTrackMuteChange');
1205
+ this._logger.error('_', '[RCCallSession onAudioMuteChange] Missing listening method -> onTrackMuteChange');
1195
1206
  console.error(error);
1196
1207
  }
1197
1208
  },
@@ -1200,7 +1211,7 @@ class RCCallSession {
1200
1211
  * @param videoTrack RCRemoteVideoTrack 类实例对象
1201
1212
  */
1202
1213
  onVideoMuteChange: (videoTrack) => {
1203
- logger.info(`[RCCallSession onVideoMuteChange]userId->${videoTrack.getUserId()} muted -> ${videoTrack.isOwnerMuted()}`);
1214
+ this._logger.info('_', `[RCCallSession onVideoMuteChange]userId->${videoTrack.getUserId()} muted -> ${videoTrack.isOwnerMuted()}`);
1204
1215
  const muteUser = {
1205
1216
  userId: videoTrack.getUserId(),
1206
1217
  muted: videoTrack.isOwnerMuted(),
@@ -1212,7 +1223,7 @@ class RCCallSession {
1212
1223
  this._listener.onVideoMuteChange(muteUser, this);
1213
1224
  }
1214
1225
  catch (error) {
1215
- logger.error('[RCCallSession onVideoMuteChange] Missing listening method -> onVideoMuteChange');
1226
+ this._logger.error('_', '[RCCallSession onVideoMuteChange] Missing listening method -> onVideoMuteChange');
1216
1227
  console.error(error);
1217
1228
  }
1218
1229
  },
@@ -1227,7 +1238,7 @@ class RCCallSession {
1227
1238
  // 按业务需求选择需要订阅资源,通过 room.subscribe 接口进行订阅
1228
1239
  const { code } = yield this._room.subscribe(tracks);
1229
1240
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
1230
- logger.error(`[RCCallSession onTrackPublish] subscribe failed RTCCode ->${code}`);
1241
+ this._logger.error('_', `[RCCallSession onTrackPublish] subscribe failed RTCCode ->${code}`);
1231
1242
  }
1232
1243
  }
1233
1244
  }),
@@ -1267,20 +1278,20 @@ class RCCallSession {
1267
1278
  * @param userIds
1268
1279
  */
1269
1280
  onUserLeave: (userIds) => {
1270
- logger.info(`[RCCallSession onUserLeave] listening onUserLeave userIds -> ${userIds === null || userIds === void 0 ? void 0 : userIds.join(',')}`);
1281
+ this._logger.info('_', `[RCCallSession onUserLeave] listening onUserLeave userIds -> ${userIds === null || userIds === void 0 ? void 0 : userIds.join(',')}`);
1271
1282
  this._stateMachine.userLeave(userIds);
1272
1283
  },
1273
1284
  /**
1274
1285
  * RTC 每次 Ping 结果
1275
1286
  */
1276
1287
  onPing: (result) => {
1277
- logger.info(`[RCCallSession onPing]${result}`);
1288
+ this._logger.info('_', `[RCCallSession onPing]${result}`);
1278
1289
  try {
1279
1290
  // 通知给业务
1280
1291
  this._listener.onPing && this._listener.onPing(result, this);
1281
1292
  }
1282
1293
  catch (error) {
1283
- logger.error('[RCCallSession onPing] listening onPing exception');
1294
+ this._logger.error('_', '[RCCallSession onPing] listening onPing exception');
1284
1295
  console.error(error);
1285
1296
  }
1286
1297
  }
@@ -1301,7 +1312,7 @@ class RCCallSession {
1301
1312
  this._listener.onRTCStateReport && this._listener.onRTCStateReport(report, this);
1302
1313
  }
1303
1314
  catch (error) {
1304
- logger.error('[RCCallSession onStateReport] listener onStateReport exception');
1315
+ this._logger.error('_', '[RCCallSession onStateReport] listener onStateReport exception');
1305
1316
  console.error(error);
1306
1317
  }
1307
1318
  },
@@ -1314,7 +1325,7 @@ class RCCallSession {
1314
1325
  this._listener.onICEConnectionStateChange && this._listener.onICEConnectionStateChange(state, this);
1315
1326
  }
1316
1327
  catch (error) {
1317
- logger.error('[RCCallSession onICEConnectionStateChange] onICEConnectionStateChange exception');
1328
+ this._logger.error('_', '[RCCallSession onICEConnectionStateChange] onICEConnectionStateChange exception');
1318
1329
  console.error(error);
1319
1330
  }
1320
1331
  }
@@ -1391,20 +1402,17 @@ class RCCallSession {
1391
1402
  }
1392
1403
  }
1393
1404
 
1394
- // plugin-call 版本上报
1395
- engine.VersionManage.add('plugin-call', "5.1.2-alpha.1");
1396
- // 校验当前安装的 engine 版本是否可用
1397
- if (!engine.VersionManage.validEngine("^5.5.4")) {
1398
- logger.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error,plugin-call required engine version at least '${"^5.5.4"}'.`);
1399
- }
1400
1405
  class RCCallClient {
1401
- constructor(_context, _runtime, _options) {
1406
+ constructor(_context, _runtime, _logger, _options) {
1402
1407
  this._context = _context;
1403
1408
  this._runtime = _runtime;
1409
+ this._logger = _logger;
1404
1410
  /**
1405
1411
  * session列表
1406
1412
  */
1407
1413
  this._sessionList = [];
1414
+ this._callPushConfig = {};
1415
+ this._hungupPushConfig = {};
1408
1416
  this._rtcClient = _options.rtcClient;
1409
1417
  this._options = Object.assign({
1410
1418
  /**
@@ -1436,7 +1444,7 @@ class RCCallClient {
1436
1444
  lang: pluginCallEngine.RCCallLanguage.ZH
1437
1445
  }, _options);
1438
1446
  // 初始化callEngine, 并监听onInvite
1439
- this._callEngine = new pluginCallEngine.RCCallEngine(this._context, _runtime, logger, {
1447
+ this._callEngine = new pluginCallEngine.RCCallEngine(this._context, _runtime, this._logger, {
1440
1448
  /**
1441
1449
  * 监听收到invite
1442
1450
  */
@@ -1458,15 +1466,15 @@ class RCCallClient {
1458
1466
  this._options.onSessionClose(session, summaryInfo);
1459
1467
  }
1460
1468
  catch (error) {
1461
- logger.error('[RCCCallClient] options.onSessionClose exception');
1469
+ this._logger.error('_', '[RCCCallClient] options.onSessionClose exception');
1462
1470
  console.log(error);
1463
1471
  }
1464
1472
  });
1465
1473
  // 接听之前挂断其它的session
1466
1474
  eventEmitter.on('hungupOtherSession', ({ session }) => {
1467
1475
  const id = session.getSessionId();
1468
- logger.info(`[RCCallClient hungupOtherSession] sessionId ready to accept -> ${id}`);
1469
- logger.info(`[RCCallClient hungupOtherSession] sessionList ->${this._sessionList.map(ses => ses.getSessionId()).join(',')}`);
1476
+ this._logger.info('_', `[RCCallClient hungupOtherSession] sessionId ready to accept -> ${id}`);
1477
+ this._logger.info('_', `[RCCallClient hungupOtherSession] sessionList ->${this._sessionList.map(ses => ses.getSessionId()).join(',')}`);
1470
1478
  let i = 0;
1471
1479
  while (this._sessionList.length > 1) {
1472
1480
  // 如果与要接听的session不一致
@@ -1481,15 +1489,15 @@ class RCCallClient {
1481
1489
  i++;
1482
1490
  }
1483
1491
  }
1484
- logger.info(`[RCCallClient hungupOtherSession] current sessionList length ->${this._sessionList.length}`);
1492
+ this._logger.info('_', `[RCCallClient hungupOtherSession] current sessionList length ->${this._sessionList.length}`);
1485
1493
  });
1486
1494
  }
1487
1495
  /**
1488
1496
  * 监听onInvite
1489
1497
  */
1490
1498
  _onInvite(stateMachine, extra) {
1491
- logger.info('[RCCallClient _onInvite] Received invite message');
1492
- const session = new RCCallSession(stateMachine, this._rtcClient, {
1499
+ this._logger.info('_', '[RCCallClient _onInvite] Received invite message');
1500
+ const session = new RCCallSession(stateMachine, this._rtcClient, this._logger, {
1493
1501
  // 是否允许订阅重试
1494
1502
  isAllowSubscribeRetry: this._options.isAllowSubscribeRetry,
1495
1503
  // 是否允许发布重试
@@ -1505,9 +1513,11 @@ class RCCallClient {
1505
1513
  // 允许降级获得流,获得音视频不成功 ,降级获得音频, 默认不允许
1506
1514
  isAllowDemotionGetStream: this._options.isAllowDemotionGetStream,
1507
1515
  // 标明是被叫产生的session
1508
- produceType: ProduceTypes.CALLEE
1516
+ produceType: ProduceTypes.CALLEE,
1517
+ callPushConfig: this._callPushConfig,
1518
+ hungupPushConfig: this._hungupPushConfig
1509
1519
  });
1510
- logger.info('[RCCallClient _onInvite] Received invite message, successfully created session');
1520
+ this._logger.info('_', '[RCCallClient _onInvite] Received invite message, successfully created session');
1511
1521
  /**
1512
1522
  * 如果通话的时候不允许接听新的通话,直接挂断, 这些工作在callEngine里完成
1513
1523
  */
@@ -1517,7 +1527,7 @@ class RCCallClient {
1517
1527
  this._options.onSession(session, extra);
1518
1528
  }
1519
1529
  catch (error) {
1520
- logger.error('[RCCallClient _options.onSession] onSession exception');
1530
+ this._logger.error('_', '[RCCallClient _options.onSession] onSession exception');
1521
1531
  console.log(error);
1522
1532
  }
1523
1533
  // 必须在onSession里注册session监听事件,这里检测一下有没有注册
@@ -1528,7 +1538,7 @@ class RCCallClient {
1528
1538
  }
1529
1539
  }
1530
1540
  else {
1531
- logger.error('[RCCallClient _options.onSession] session Must Have Listener');
1541
+ this._logger.error('_', '[RCCallClient _options.onSession] session Must Have Listener');
1532
1542
  throw new Error('[RCCallSession _options.onSession] session Must Have Listener');
1533
1543
  }
1534
1544
  }
@@ -1542,7 +1552,7 @@ class RCCallClient {
1542
1552
  this._options.onOfflineRecord && this._options.onOfflineRecord(record);
1543
1553
  }
1544
1554
  catch (error) {
1545
- logger.error('[RCCallClient _options.onOfflineRecord] onOfflineRecord exception');
1555
+ this._logger.error('_', '[RCCallClient _options.onOfflineRecord] onOfflineRecord exception');
1546
1556
  console.log(error);
1547
1557
  }
1548
1558
  }
@@ -1554,7 +1564,7 @@ class RCCallClient {
1554
1564
  */
1555
1565
  registerUserInfo(info = {}) {
1556
1566
  this._callEngine.registerUserInfo(info);
1557
- logger.info('[RCCallClient registerUserInfo] successfully register user info data');
1567
+ this._logger.info('_', '[RCCallClient registerUserInfo] successfully register user info data');
1558
1568
  }
1559
1569
  /**
1560
1570
  * 跨App单呼,发送invite消息,回调回来接收stateMachine, 建session
@@ -1564,14 +1574,15 @@ class RCCallClient {
1564
1574
  * @param params.constraints 获取音频或音视频资源时的参数 可选
1565
1575
  * @param params.channelId 组织 Id 可选
1566
1576
  * @param params.extra 消息扩展信息
1567
- * @param params.pushTitle 通知的标题
1568
- * @param params.pushContent 通知的内容
1577
+ * @deprecated 5.1.2 版本废弃 params.pushTitle 通知的标题
1578
+ * @deprecated 5.1.2 版本废弃 params.pushContent 通知的内容
1569
1579
  * @param params.bitrate 需要设置的码率参数
1570
1580
  *
1571
1581
  */
1572
1582
  startCrossCall({ targetId, mediaType = pluginCallEngine.RCCallMediaType.AUDIO, listener, constraints, channelId = '', extra = '', pushTitle = '', pushContent = '', bitrate }) {
1573
1583
  return __awaiter(this, void 0, void 0, function* () {
1574
- return this.__call({ targetId, mediaType, listener, constraints, channelId, extra, pushTitle, pushContent, bitrate, isCrossAppkey: true });
1584
+ const { pushTitle: pushTitleValue, pushContent: pushContentValue } = (this._callPushConfig.pushTitle || this._callPushConfig.pushContent) ? this._callPushConfig : { pushTitle, pushContent };
1585
+ return this.__call({ targetId, mediaType, listener, constraints, channelId, extra, pushTitle: pushTitleValue, pushContent: pushContentValue, bitrate, isCrossAppkey: true });
1575
1586
  });
1576
1587
  }
1577
1588
  /**
@@ -1582,19 +1593,20 @@ class RCCallClient {
1582
1593
  * @param params.constraints 获取音频或音视频资源时的参数 可选
1583
1594
  * @param params.channelId 组织 Id 可选
1584
1595
  * @param params.extra 消息扩展信息
1585
- * @param params.pushTitle 通知的标题
1586
- * @param params.pushContent 通知的内容
1596
+ * @deprecated 5.1.2 版本废弃 params.pushTitle 通知的标题
1597
+ * @deprecated 5.1.2 版本废弃 params.pushContent 通知的内容
1587
1598
  * @param params.bitrate 需要设置的码率参数
1588
1599
  *
1589
1600
  */
1590
1601
  call({ targetId, mediaType = pluginCallEngine.RCCallMediaType.AUDIO, listener, constraints, channelId = '', extra = '', pushTitle = '', pushContent = '', bitrate }) {
1591
1602
  return __awaiter(this, void 0, void 0, function* () {
1592
- return this.__call({ targetId, mediaType, listener, constraints, channelId, extra, pushTitle, pushContent, bitrate });
1603
+ const { pushTitle: pushTitleValue, pushContent: pushContentValue } = (this._callPushConfig.pushTitle || this._callPushConfig.pushContent) ? this._callPushConfig : { pushTitle, pushContent };
1604
+ return this.__call({ targetId, mediaType, listener, constraints, channelId, extra, pushTitle: pushTitleValue, pushContent: pushContentValue, bitrate });
1593
1605
  });
1594
1606
  }
1595
1607
  __call({ targetId, mediaType = pluginCallEngine.RCCallMediaType.AUDIO, listener, constraints, channelId = '', extra = '', pushTitle = '', pushContent = '', bitrate, isCrossAppkey = false }) {
1596
1608
  return __awaiter(this, void 0, void 0, function* () {
1597
- logger.info(`[RCCallClient call] extra->${extra} pushTitle->${pushTitle} pushContent->${pushContent}`);
1609
+ this._logger.info('_', `[RCCallClient call] extra->${extra} pushTitle->${pushTitle} pushContent->${pushContent}`);
1598
1610
  const conclusion = [validateTargetId(targetId), validateMediaType(mediaType), validateListener(listener), validateExtra(extra), validatePushTitle(pushTitle), validatePushContent(pushContent)];
1599
1611
  const messages = [];
1600
1612
  const result = conclusion.every((obj) => {
@@ -1625,8 +1637,8 @@ class RCCallClient {
1625
1637
  // 调用callEngine的call返回一个状态机的实例
1626
1638
  const { code, stateMachine } = yield this._callEngine.call(channelId, targetId, mediaType, extra, pushTitle, pushContent, isCrossAppkey);
1627
1639
  if (code === pluginCallEngine.RCCallErrorCode.SUCCESS && stateMachine) {
1628
- logger.info('[RCCallClient call] successfully created state machine');
1629
- const session = new RCCallSession(stateMachine, this._rtcClient, {
1640
+ this._logger.info('_', '[RCCallClient call] successfully created state machine');
1641
+ const session = new RCCallSession(stateMachine, this._rtcClient, this._logger, {
1630
1642
  localTracks,
1631
1643
  // 是否允许订阅重试
1632
1644
  isAllowSubscribeRetry: this._options.isAllowSubscribeRetry,
@@ -1644,16 +1656,18 @@ class RCCallClient {
1644
1656
  isAllowDemotionGetStream: this._options.isAllowDemotionGetStream,
1645
1657
  // 标明是主叫产生的session
1646
1658
  produceType: ProduceTypes.CALLER,
1647
- isCrossAppkey
1659
+ isCrossAppkey,
1660
+ callPushConfig: this._callPushConfig,
1661
+ hungupPushConfig: this._hungupPushConfig
1648
1662
  });
1649
1663
  // session上注册监听事件
1650
1664
  session.registerSessionListener(listener);
1651
1665
  this._sessionList.push(session);
1652
- logger.info(`[RCCallClient call] successfully created session object, sessionId: ${session.getSessionId()}`);
1666
+ this._logger.info('_', `[RCCallClient call] successfully created session object, sessionId: ${session.getSessionId()}`);
1653
1667
  return { code, session };
1654
1668
  }
1655
1669
  else {
1656
- logger.error(`[RCCallClient call] call failed code ->: ${code}`);
1670
+ this._logger.error('_', `[RCCallClient call] call failed code ->: ${code}`);
1657
1671
  localTracks.forEach(track => {
1658
1672
  // 禁用视频
1659
1673
  track.mute();
@@ -1673,13 +1687,13 @@ class RCCallClient {
1673
1687
  * @param params.constraints 获取音频或音视频资源时的参数 可选
1674
1688
  * @param params.channelId 组织 Id 可选
1675
1689
  * @param params.extra 消息扩展信息 可选
1676
- * @param params.pushTitle 通知的标题
1677
- * @param params.pushContent 通知的内容
1690
+ * @deprecated 5.1.2 版本废弃 params.pushTitle 通知的标题
1691
+ * @deprecated 5.1.2 版本废弃 params.pushContent 通知的内容
1678
1692
  * @param params.bitrate 需要设置的码率参数
1679
1693
  */
1680
- callInGroup({ targetId, userIds, mediaType = pluginCallEngine.RCCallMediaType.AUDIO, listener, constraints, channelId = '', extra = '', pushTitle = '', pushContent = '', bitrate }) {
1694
+ callInGroup({ targetId, userIds, mediaType = pluginCallEngine.RCCallMediaType.AUDIO, listener, constraints, channelId = '', extra = '', bitrate }) {
1681
1695
  return __awaiter(this, void 0, void 0, function* () {
1682
- const conclusion = [validateTargetId(targetId), validateUserIds(userIds), validateMediaType(mediaType), validateListener(listener), validateExtra(extra), validatePushTitle(pushTitle), validatePushContent(pushContent)];
1696
+ const conclusion = [validateTargetId(targetId), validateUserIds(userIds), validateMediaType(mediaType), validateListener(listener), validateExtra(extra)];
1683
1697
  const messages = [];
1684
1698
  const result = conclusion.every((obj) => {
1685
1699
  !obj.result && messages.push(obj.msg);
@@ -1707,10 +1721,11 @@ class RCCallClient {
1707
1721
  listener.onTrackReady(track);
1708
1722
  });
1709
1723
  // 往组里发消息
1724
+ const { pushTitle, pushContent } = this._callPushConfig;
1710
1725
  const { code, stateMachine } = yield this._callEngine.callInGroup(channelId, targetId, mediaType, userIds, extra, pushTitle, pushContent);
1711
1726
  if (code === pluginCallEngine.RCCallErrorCode.SUCCESS && stateMachine) {
1712
- logger.info('[RCCallClient callInGroup] successfully created state machine');
1713
- const session = new RCCallSession(stateMachine, this._rtcClient, {
1727
+ this._logger.info('_', '[RCCallClient callInGroup] successfully created state machine');
1728
+ const session = new RCCallSession(stateMachine, this._rtcClient, this._logger, {
1714
1729
  localTracks,
1715
1730
  // 是否允许订阅重试
1716
1731
  isAllowSubscribeRetry: this._options.isAllowSubscribeRetry,
@@ -1727,16 +1742,18 @@ class RCCallClient {
1727
1742
  // 允许降级获得流,获得音视频不成功 ,降级获得音频, 默认不允许
1728
1743
  isAllowDemotionGetStream: this._options.isAllowDemotionGetStream,
1729
1744
  // 标明是主叫产生的session
1730
- produceType: ProduceTypes.CALLER
1745
+ produceType: ProduceTypes.CALLER,
1746
+ callPushConfig: this._callPushConfig,
1747
+ hungupPushConfig: this._hungupPushConfig
1731
1748
  });
1732
1749
  // session上注册监听事件
1733
1750
  session.registerSessionListener(listener);
1734
1751
  this._sessionList.push(session);
1735
- logger.info(`[RCCallClient callInGroup] successfully created session object, sessionId: ${session.getSessionId()}`);
1752
+ this._logger.info('_', `[RCCallClient callInGroup] successfully created session object, sessionId: ${session.getSessionId()}`);
1736
1753
  return { code, session };
1737
1754
  }
1738
1755
  else {
1739
- logger.info(`[RCCallClient callInGroup] callInGroup failed code -> ${code}`);
1756
+ this._logger.info('_', `[RCCallClient callInGroup] callInGroup failed code -> ${code}`);
1740
1757
  localTracks.forEach(track => {
1741
1758
  // 禁用视频
1742
1759
  track.mute();
@@ -1756,19 +1773,19 @@ class RCCallClient {
1756
1773
  if (mediaType === pluginCallEngine.RCCallMediaType.AUDIO) {
1757
1774
  const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', constraints && constraints.audio && Object.assign({}, constraints.audio));
1758
1775
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
1759
- logger.error(`[RCCallClient _getTrack] get Audio local tracks failed RCT code -> ${code}`);
1776
+ this._logger.error('_', `[RCCallClient _getTrack] get Audio local tracks failed RCT code -> ${code}`);
1760
1777
  return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
1761
1778
  }
1762
- logger.info('[RCCallClient _getTrack] successfully get Audio local tracks');
1779
+ this._logger.info('_', '[RCCallClient _getTrack] successfully get Audio local tracks');
1763
1780
  return { code: pluginCallEngine.RCCallErrorCode.SUCCESS, tracks: [track] };
1764
1781
  }
1765
1782
  else {
1766
1783
  const { code, tracks } = yield this._rtcClient.createMicrophoneAndCameraTracks('RongCloudRTC', constraints && Object.assign({}, constraints));
1767
1784
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
1768
- logger.error(`[RCCallClient _getTrack] get Audio and Video local tracks failed RCT code -> ${code}`);
1785
+ this._logger.error('_', `[RCCallClient _getTrack] get Audio and Video local tracks failed RCT code -> ${code}`);
1769
1786
  return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR };
1770
1787
  }
1771
- logger.info('[RCCallClient _getTrack] successfully get audio and video local tracks');
1788
+ this._logger.info('_', '[RCCallClient _getTrack] successfully get audio and video local tracks');
1772
1789
  return { code: pluginCallEngine.RCCallErrorCode.SUCCESS, tracks };
1773
1790
  }
1774
1791
  });
@@ -1811,14 +1828,40 @@ class RCCallClient {
1811
1828
  return __awaiter(this, void 0, void 0, function* () {
1812
1829
  const { code, data } = yield this._context.getRTCJoinedUserInfo(this._context.getCurrentId());
1813
1830
  if (code !== engine.ErrorCode.SUCCESS) {
1814
- logger.error('getJoinedUserInfo error', code);
1831
+ this._logger.error('_', `getJoinedUserInfo error code: ${code}`);
1815
1832
  return { code: pluginCallEngine.RCCallErrorCode.QUERY_JOINED_USER_INFO_ERROR };
1816
1833
  }
1817
1834
  return { code: pluginCallEngine.RCCallErrorCode.SUCCESS, data };
1818
1835
  });
1819
1836
  }
1837
+ /**
1838
+ * 设置呼叫、挂断推送数据
1839
+ * @param callPushConfig 呼叫推送配置
1840
+ * @param callPushConfig.pushTitle 呼叫推送标题
1841
+ * @param callPushConfig.pushContent 呼叫推送内容
1842
+ * @param hungupPushConfig 挂断推送配置
1843
+ * @param hungupPushConfig.pushTitle 挂断推送标题
1844
+ * @param hungupPushConfig.pushContent 挂断推送内容
1845
+ */
1846
+ setPushConfig(callPushConfig = {}, hungupPushConfig = {}) {
1847
+ const conclusion = [callPushConfig, hungupPushConfig].map((pushConfig) => {
1848
+ return validatePushConfig(pushConfig);
1849
+ })[0];
1850
+ const messages = [];
1851
+ const result = conclusion.every((obj) => {
1852
+ !obj.result && messages.push(obj.msg);
1853
+ return obj.result;
1854
+ });
1855
+ if (!result) {
1856
+ throw new Error(`[RCCallClient callInGroup callPushConfig or hungupPushConfig] ${messages.join('\n')}`);
1857
+ }
1858
+ this._callPushConfig = callPushConfig;
1859
+ this._hungupPushConfig = hungupPushConfig;
1860
+ }
1820
1861
  }
1821
1862
 
1863
+ // plugin-call 版本上报
1864
+ engine.VersionManage.add('plugin-call', "5.1.2-alpha.2");
1822
1865
  const installer = {
1823
1866
  tag: 'RCCall',
1824
1867
  verify(runtime) {
@@ -1830,10 +1873,13 @@ const installer = {
1830
1873
  if (!conclusion.result) {
1831
1874
  throw new Error(`[RCCallLib installer steup]${conclusion.msg}`);
1832
1875
  }
1833
- logger.setLogLevel(options.logLevel);
1834
- logger.setLogStdout(options.logStdout);
1835
- logger.warn(`RCCall Version: ${"5.1.2-alpha.1"}, Commit: ${"5a6d3a159d1171c71f1bb419dfac59eb8e886f91"}`);
1836
- return new RCCallClient(context, runtime, options);
1876
+ // 校验当前安装的 engine 版本是否可用
1877
+ if (!engine.VersionManage.validEngine("^5.7.0")) {
1878
+ throw new Error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-call required engine version at least '${"^5.7.0"}'.`);
1879
+ }
1880
+ const logger = context.createLogger('RCCall', 'RTC');
1881
+ logger.warn('_', `RCCall Version: ${"5.1.2-alpha.2"}, Commit: ${"8d4f8b00cda704283faad34d0e81a4e048e09d08"}`);
1882
+ return new RCCallClient(context, runtime, logger, options);
1837
1883
  }
1838
1884
  };
1839
1885