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

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