@rongcloud/plugin-rtc 5.2.4-beem.6 → 5.2.4-beem.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -3
- package/dist/index.esm.js +59 -48
- package/dist/index.js +59 -48
- package/dist/index.umd.js +59 -48
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* RCRTC - v5.2.4-beem.
|
|
3
|
-
* CommitId -
|
|
4
|
-
*
|
|
2
|
+
* RCRTC - v5.2.4-beem.9
|
|
3
|
+
* CommitId - 23137f0f952c4650554fb300ff96fc6c1485a834
|
|
4
|
+
* Fri Jun 03 2022 12:42:39 GMT+0800 (China Standard Time)
|
|
5
5
|
* ©2020 RongCloud, Inc. All rights reserved.
|
|
6
6
|
*/
|
|
7
7
|
import { EventEmitter, LogLevel, RTCMode, IRuntime, RTCPluginContext, IServerRTCRoomEntry, IJoinRTCRoomData, IReceivedMessage, KVString, RTCJoinType, IRTCJoinedInfo, IPluginGenerator } from '@rongcloud/engine';
|
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* RCRTC - v5.2.4-beem.
|
|
3
|
-
* CommitId -
|
|
4
|
-
*
|
|
2
|
+
* RCRTC - v5.2.4-beem.9
|
|
3
|
+
* CommitId - 23137f0f952c4650554fb300ff96fc6c1485a834
|
|
4
|
+
* Fri Jun 03 2022 12:42:39 GMT+0800 (China Standard Time)
|
|
5
5
|
* ©2020 RongCloud, Inc. All rights reserved.
|
|
6
6
|
*/
|
|
7
7
|
import { Logger, EventEmitter, isNumber, ErrorCode, ConnectionStatus, assert, ConversationType, RTCApiType, validate, isArray, RTCMode, isHttpUrl, isBoolean, HttpMethod, isString, notEmptyString, RTCJoinType, RTCIdentityChangeType, VersionManage } from '@rongcloud/engine';
|
|
@@ -127,8 +127,13 @@ var RTCSignalCode;
|
|
|
127
127
|
|
|
128
128
|
class AsyncTaskQueue {
|
|
129
129
|
constructor() {
|
|
130
|
+
/**
|
|
131
|
+
* 多个队列时便于区分队列实例的索引
|
|
132
|
+
*/
|
|
133
|
+
this.index = AsyncTaskQueue.queueCount++;
|
|
130
134
|
this.queue = [];
|
|
131
135
|
this.locked = false;
|
|
136
|
+
this.taskCount = 0;
|
|
132
137
|
}
|
|
133
138
|
checkToStart() {
|
|
134
139
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -136,8 +141,8 @@ class AsyncTaskQueue {
|
|
|
136
141
|
return;
|
|
137
142
|
}
|
|
138
143
|
this.locked = true;
|
|
139
|
-
const { resolve, task, reject } = this.queue.shift();
|
|
140
|
-
logger.info(`async task
|
|
144
|
+
const { resolve, task, reject, name, index } = this.queue.shift();
|
|
145
|
+
logger.info(`[${this.index}] async task exec -> task: ${name}, index: ${index}, length: ${this.queue.length}`);
|
|
141
146
|
let result;
|
|
142
147
|
try {
|
|
143
148
|
result = yield task();
|
|
@@ -151,15 +156,21 @@ class AsyncTaskQueue {
|
|
|
151
156
|
this.checkToStart();
|
|
152
157
|
});
|
|
153
158
|
}
|
|
154
|
-
push(task) {
|
|
159
|
+
push(task, _name = '') {
|
|
155
160
|
const promise = new Promise((resolve, reject) => {
|
|
156
|
-
const
|
|
157
|
-
|
|
161
|
+
const name = task.name || _name;
|
|
162
|
+
const index = this.taskCount++;
|
|
163
|
+
const length = this.queue.push({ resolve, task, reject, name, index });
|
|
164
|
+
logger.info(`[${this.index}] async task queue add -> task: ${name}, index: ${index}, length: ${length}`);
|
|
158
165
|
});
|
|
159
166
|
this.checkToStart();
|
|
160
167
|
return promise;
|
|
161
168
|
}
|
|
162
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* 实例递增计数
|
|
172
|
+
*/
|
|
173
|
+
AsyncTaskQueue.queueCount = 0;
|
|
163
174
|
const defQueeu = new AsyncTaskQueue();
|
|
164
175
|
/**
|
|
165
176
|
* 将异步任务推送到异步队列,队列内任务先进先出,依次执行,执行完成后通过
|
|
@@ -167,8 +178,8 @@ const defQueeu = new AsyncTaskQueue();
|
|
|
167
178
|
* @param task 传参不能是 `async () => {}` 所定义的异步函数,
|
|
168
179
|
* 只能使用明确的 `() => Promise<T> | T` 形式,避免转义时微任务被提前执行
|
|
169
180
|
*/
|
|
170
|
-
const push = (task) => {
|
|
171
|
-
return defQueeu.push(task);
|
|
181
|
+
const push = (task, name = '') => {
|
|
182
|
+
return defQueeu.push(task, name);
|
|
172
183
|
};
|
|
173
184
|
|
|
174
185
|
/*
|
|
@@ -8506,7 +8517,7 @@ class PolarisReporter {
|
|
|
8506
8517
|
* 加入房间
|
|
8507
8518
|
*/
|
|
8508
8519
|
sendR1() {
|
|
8509
|
-
const rtcVersion = "5.2.4-beem.
|
|
8520
|
+
const rtcVersion = "5.2.4-beem.9";
|
|
8510
8521
|
const imVersion = this._context.getCoreVersion();
|
|
8511
8522
|
const platform = 'web';
|
|
8512
8523
|
const pcName = navigator.platform;
|
|
@@ -8676,7 +8687,7 @@ class RCAbstractRoom {
|
|
|
8676
8687
|
* 需先清除房间内的己方资源,通知房间内其他人己方已取消当前资源的发布
|
|
8677
8688
|
* 该步骤没有必要与 MediaServer 的交互,因后续资源变更交互为全量交互
|
|
8678
8689
|
*/
|
|
8679
|
-
selfRes.length > 0 && push(() => this._unpublishPrev(selfRes));
|
|
8690
|
+
selfRes.length > 0 && push(() => this._unpublishPrev(selfRes), 'unpub-prev');
|
|
8680
8691
|
/**
|
|
8681
8692
|
* 观众升级为主播后不会收到全量 uri 消息,需直接触发人员、资源变更
|
|
8682
8693
|
*/
|
|
@@ -8795,29 +8806,20 @@ class RCAbstractRoom {
|
|
|
8795
8806
|
});
|
|
8796
8807
|
}
|
|
8797
8808
|
__parseInnerMessage(message) {
|
|
8798
|
-
|
|
8799
|
-
// 过滤非 RTC 消息
|
|
8800
|
-
if (conversationType !== ConversationType.RTC_ROOM) {
|
|
8801
|
-
return false;
|
|
8802
|
-
}
|
|
8803
|
-
// 为 RTC 消息,但不属于当前房间,不处理
|
|
8804
|
-
if (roomId !== this._roomId) {
|
|
8805
|
-
return true;
|
|
8806
|
-
}
|
|
8807
|
-
logger.info(`recv inner msg -> message: ${JSON.stringify(message)} | roomid: ${this._roomId}`);
|
|
8809
|
+
logger.info(`room parse msg -> ${message.messageUId}`);
|
|
8808
8810
|
const content = message.content;
|
|
8809
8811
|
switch (message.messageType) {
|
|
8810
8812
|
case RCRTCMessageType.KICK:
|
|
8811
8813
|
this._kickoff(true, content);
|
|
8812
8814
|
break;
|
|
8813
8815
|
case RCRTCMessageType.STATE:
|
|
8814
|
-
this.msgTaskQueue.push(() => this._stateHandle(content));
|
|
8816
|
+
this.msgTaskQueue.push(() => this._stateHandle(content), `parse ${message.messageType}`);
|
|
8815
8817
|
break;
|
|
8816
8818
|
case RCRTCMessageType.MODIFY:
|
|
8817
8819
|
case RCRTCMessageType.PUBLISH:
|
|
8818
8820
|
case RCRTCMessageType.UNPUBLISH:
|
|
8819
8821
|
case RCRTCMessageType.TOTAL_CONTENT_RESOURCE:
|
|
8820
|
-
this.msgTaskQueue.push(() => this._resourceHandle(content, message.messageType, message.senderUserId));
|
|
8822
|
+
this.msgTaskQueue.push(() => this._resourceHandle(content, message.messageType, message.senderUserId), `parse ${message.messageType}`);
|
|
8821
8823
|
break;
|
|
8822
8824
|
case RCRTCMessageType.ROOM_NOTIFY:
|
|
8823
8825
|
this._callAppListener('onRoomAttributeChange', message.messageType, message.content);
|
|
@@ -8938,7 +8940,7 @@ class RCAbstractRoom {
|
|
|
8938
8940
|
if (subedTracks.length) {
|
|
8939
8941
|
const trackIds = subedTracks.map(item => item.getTrackId());
|
|
8940
8942
|
logger.info(`resub tracks -> ${JSON.stringify(trackIds)}`);
|
|
8941
|
-
const { code } = yield push(() => this.__subscribe(subedTracks, true));
|
|
8943
|
+
const { code } = yield push(() => this.__subscribe(subedTracks, true), 'resub');
|
|
8942
8944
|
if (code !== RCRTCCode.SUCCESS) {
|
|
8943
8945
|
logger.error(`resub tracks failed -> code: ${code}, ids: ${JSON.stringify(trackIds)}`);
|
|
8944
8946
|
}
|
|
@@ -9290,7 +9292,7 @@ class RCAbstractRoom {
|
|
|
9290
9292
|
break;
|
|
9291
9293
|
}
|
|
9292
9294
|
}
|
|
9293
|
-
const code = yield push(() => this._context.setRTCTotalRes(this._roomId, buildPlusMessage(RCRTCMessageType.MODIFY, plusList), buildTotalURIMessageContent(publishedList), RCRTCMessageType.TOTAL_CONTENT_RESOURCE));
|
|
9295
|
+
const code = yield push(() => this._context.setRTCTotalRes(this._roomId, buildPlusMessage(RCRTCMessageType.MODIFY, plusList), buildTotalURIMessageContent(publishedList), RCRTCMessageType.TOTAL_CONTENT_RESOURCE), 'send-local-muted');
|
|
9294
9296
|
if (code !== ErrorCode.SUCCESS) {
|
|
9295
9297
|
logger.error('notice `track.enabled` change failed -> code: ' + code);
|
|
9296
9298
|
}
|
|
@@ -9320,7 +9322,7 @@ class RCAbstractRoom {
|
|
|
9320
9322
|
*/
|
|
9321
9323
|
publish(tracks) {
|
|
9322
9324
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9323
|
-
return push(() => this.__publish(tracks));
|
|
9325
|
+
return push(() => this.__publish(tracks), 'pub');
|
|
9324
9326
|
});
|
|
9325
9327
|
}
|
|
9326
9328
|
__publish(tracks) {
|
|
@@ -9454,7 +9456,7 @@ class RCAbstractRoom {
|
|
|
9454
9456
|
if (resCode !== RCRTCCode.SUCCESS) {
|
|
9455
9457
|
return { code: resCode };
|
|
9456
9458
|
}
|
|
9457
|
-
}));
|
|
9459
|
+
}), 'retry-exchange');
|
|
9458
9460
|
});
|
|
9459
9461
|
}
|
|
9460
9462
|
_exchangeHandle(body) {
|
|
@@ -9515,7 +9517,7 @@ class RCAbstractRoom {
|
|
|
9515
9517
|
*/
|
|
9516
9518
|
unpublish(tracks) {
|
|
9517
9519
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9518
|
-
return push(() => this.__unpublish(tracks));
|
|
9520
|
+
return push(() => this.__unpublish(tracks), 'unpub');
|
|
9519
9521
|
});
|
|
9520
9522
|
}
|
|
9521
9523
|
__unpublish(tracks) {
|
|
@@ -9602,7 +9604,7 @@ class RCAbstractRoom {
|
|
|
9602
9604
|
*/
|
|
9603
9605
|
subscribe(tracks) {
|
|
9604
9606
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9605
|
-
return push(() => this.__subscribe(tracks, false));
|
|
9607
|
+
return push(() => this.__subscribe(tracks, false), 'sub');
|
|
9606
9608
|
});
|
|
9607
9609
|
}
|
|
9608
9610
|
__subscribe(tracks, forceReq = false) {
|
|
@@ -9657,7 +9659,7 @@ class RCAbstractRoom {
|
|
|
9657
9659
|
*/
|
|
9658
9660
|
unsubscribe(tracks) {
|
|
9659
9661
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9660
|
-
return push(() => this.__unsubscribe(tracks));
|
|
9662
|
+
return push(() => this.__unsubscribe(tracks), 'unsub');
|
|
9661
9663
|
});
|
|
9662
9664
|
}
|
|
9663
9665
|
__unsubscribe(tracks) {
|
|
@@ -9718,7 +9720,7 @@ class RCAbstractRoom {
|
|
|
9718
9720
|
*/
|
|
9719
9721
|
updateSubList(tracks) {
|
|
9720
9722
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9721
|
-
return push(() => this._updateSubListHandle(tracks, false));
|
|
9723
|
+
return push(() => this._updateSubListHandle(tracks, false), 'update-sub-list');
|
|
9722
9724
|
});
|
|
9723
9725
|
}
|
|
9724
9726
|
_updateSubListHandle(tracks, forceReq = false) {
|
|
@@ -10567,7 +10569,7 @@ class RCLivingRoom extends RCAbstractRoom {
|
|
|
10567
10569
|
/**
|
|
10568
10570
|
* 扩散 cdn_uris
|
|
10569
10571
|
*/
|
|
10570
|
-
const { code: sendSingalCode } = yield push(() => __awaiter(this, void 0, void 0, function* () { return this._sendCDNInfoSignal(); }));
|
|
10572
|
+
const { code: sendSingalCode } = yield push(() => __awaiter(this, void 0, void 0, function* () { return this._sendCDNInfoSignal(); }), 'send-cdninfo');
|
|
10571
10573
|
if (sendSingalCode === RCRTCCode.SUCCESS) {
|
|
10572
10574
|
logger.info('enableInnerCDN succeed');
|
|
10573
10575
|
return { code: RCRTCCode.SUCCESS };
|
|
@@ -10768,7 +10770,7 @@ const getCommonHeader = () => ({
|
|
|
10768
10770
|
'Content-Type': 'application/json;charset=UTF-8',
|
|
10769
10771
|
'Cache-Control': 'no-cache',
|
|
10770
10772
|
ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
|
|
10771
|
-
ClientVersion: "5.2.4-beem.
|
|
10773
|
+
ClientVersion: "5.2.4-beem.9",
|
|
10772
10774
|
'Client-Session-Id': getUUID(),
|
|
10773
10775
|
'Request-Id': Date.now().toString()
|
|
10774
10776
|
});
|
|
@@ -11059,7 +11061,7 @@ class RCAudienceClient {
|
|
|
11059
11061
|
*/
|
|
11060
11062
|
subscribe(liveUrl, livingType, mediaType, subTiny = false) {
|
|
11061
11063
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11062
|
-
return push(() => this.__subscribe(liveUrl, livingType, mediaType, subTiny));
|
|
11064
|
+
return push(() => this.__subscribe(liveUrl, livingType, mediaType, subTiny), 'audience-client-sub');
|
|
11063
11065
|
});
|
|
11064
11066
|
}
|
|
11065
11067
|
__subscribe(liveUrl, livingType, mediaType, subTiny = false) {
|
|
@@ -11154,7 +11156,7 @@ class RCAudienceClient {
|
|
|
11154
11156
|
*/
|
|
11155
11157
|
unsubscribe() {
|
|
11156
11158
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11157
|
-
return push(() => this.__unsubscribe());
|
|
11159
|
+
return push(() => this.__unsubscribe(), 'audience-client-unsub');
|
|
11158
11160
|
});
|
|
11159
11161
|
}
|
|
11160
11162
|
__unsubscribe() {
|
|
@@ -11500,7 +11502,7 @@ class RCAudienceLivingRoom {
|
|
|
11500
11502
|
if (subedTracks.length) {
|
|
11501
11503
|
const trackIds = subedTracks.map(item => item.getTrackId());
|
|
11502
11504
|
logger.debug(`resub tracks -> ${JSON.stringify(trackIds)}`);
|
|
11503
|
-
const { code } = yield push(() => this._subscribeHandle(subedTracks, true));
|
|
11505
|
+
const { code } = yield push(() => this._subscribeHandle(subedTracks, true), 'audience-resub');
|
|
11504
11506
|
if (code !== RCRTCCode.SUCCESS) {
|
|
11505
11507
|
logger.error(`resub tracks failed -> code: ${code}, ids: ${JSON.stringify(trackIds)}`);
|
|
11506
11508
|
}
|
|
@@ -11600,7 +11602,7 @@ class RCAudienceLivingRoom {
|
|
|
11600
11602
|
if (resCode !== RCRTCCode.SUCCESS) {
|
|
11601
11603
|
return { code: resCode };
|
|
11602
11604
|
}
|
|
11603
|
-
}));
|
|
11605
|
+
}), 'audience-retry-exchange');
|
|
11604
11606
|
});
|
|
11605
11607
|
}
|
|
11606
11608
|
/**
|
|
@@ -11945,7 +11947,7 @@ class RCAudienceLivingRoom {
|
|
|
11945
11947
|
*/
|
|
11946
11948
|
subscribe(tracks) {
|
|
11947
11949
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11948
|
-
return push(() => this._subscribeHandle(tracks, false));
|
|
11950
|
+
return push(() => this._subscribeHandle(tracks, false), 'audience-sub');
|
|
11949
11951
|
});
|
|
11950
11952
|
}
|
|
11951
11953
|
__unsubscribe(tracks) {
|
|
@@ -11971,7 +11973,7 @@ class RCAudienceLivingRoom {
|
|
|
11971
11973
|
*/
|
|
11972
11974
|
unsubscribe(tracks) {
|
|
11973
11975
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11974
|
-
return push(() => this.__unsubscribe(tracks));
|
|
11976
|
+
return push(() => this.__unsubscribe(tracks), 'audience-unsub');
|
|
11975
11977
|
});
|
|
11976
11978
|
}
|
|
11977
11979
|
/**
|
|
@@ -12196,7 +12198,16 @@ class RCRTCClient {
|
|
|
12196
12198
|
if (message.conversationType !== ConversationType.RTC_ROOM) {
|
|
12197
12199
|
return false;
|
|
12198
12200
|
}
|
|
12199
|
-
(
|
|
12201
|
+
logger.info(`recv inner msg -> message: ${JSON.stringify(message)}`);
|
|
12202
|
+
if (!this._crtRoom) {
|
|
12203
|
+
logger.warn(`ignore msg, crt room does not exist -> messageUId: ${message.messageUId}`);
|
|
12204
|
+
}
|
|
12205
|
+
else if (message.targetId !== this._crtRoom.getRoomId()) {
|
|
12206
|
+
logger.warn(`ignore msg, roomId mismatch -> crtRoomId: ${this._crtRoom.getRoomId()}, msgTargetId: ${message.targetId}`);
|
|
12207
|
+
}
|
|
12208
|
+
else {
|
|
12209
|
+
(_a = this._crtRoom) === null || _a === void 0 ? void 0 : _a.__parseInnerMessage(message);
|
|
12210
|
+
}
|
|
12200
12211
|
return true;
|
|
12201
12212
|
}
|
|
12202
12213
|
/**
|
|
@@ -12215,7 +12226,7 @@ class RCRTCClient {
|
|
|
12215
12226
|
* @param roomType 加入房间的类型 默认参数 RTCMode.RTC
|
|
12216
12227
|
*/
|
|
12217
12228
|
joinRTCRoom(roomId, joinType, outerUserDatas, useMutilPeerC, roomType = RTCMode.RTC) {
|
|
12218
|
-
return push(() => this._joinRTCRoom(roomId, joinType, outerUserDatas, useMutilPeerC, roomType));
|
|
12229
|
+
return push(() => this._joinRTCRoom(roomId, joinType, outerUserDatas, useMutilPeerC, roomType), 'join-rtcroom');
|
|
12219
12230
|
}
|
|
12220
12231
|
_joinRTCRoom(roomId, joinType, outerUserDatas, useMutilPeerC, roomType = RTCMode.RTC) {
|
|
12221
12232
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -12257,7 +12268,7 @@ class RCRTCClient {
|
|
|
12257
12268
|
* @param livingType 直播间类型,`RCLivingType.AUDIO` 为音频直播,`RCLivingType.VIDEO` 为音视频直播
|
|
12258
12269
|
*/
|
|
12259
12270
|
joinLivingRoom(roomId, livingType) {
|
|
12260
|
-
return push(() => this._joinLivingRoom(roomId, livingType));
|
|
12271
|
+
return push(() => this._joinLivingRoom(roomId, livingType), 'join-livingroom');
|
|
12261
12272
|
}
|
|
12262
12273
|
_joinLivingRoom(roomId, livingType) {
|
|
12263
12274
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -12325,7 +12336,7 @@ class RCRTCClient {
|
|
|
12325
12336
|
* 退出并销毁当前房间实例,退出后该房间的所有方法将不可用
|
|
12326
12337
|
*/
|
|
12327
12338
|
leaveRoom(room) {
|
|
12328
|
-
return push(() => this._leaveRoom(room));
|
|
12339
|
+
return push(() => this._leaveRoom(room), 'leave-room');
|
|
12329
12340
|
}
|
|
12330
12341
|
_leaveRoom(room) {
|
|
12331
12342
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -12801,9 +12812,9 @@ const installer = {
|
|
|
12801
12812
|
logger.error('Please use the https protocol or use `http://localhost` to open the page!');
|
|
12802
12813
|
return false;
|
|
12803
12814
|
}
|
|
12804
|
-
VersionManage.add('plugin-rtc', "5.2.4-beem.
|
|
12805
|
-
if (!VersionManage.validEngine("4.6.0-beem.
|
|
12806
|
-
logger.error(`The current engine version '${VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"4.6.0-beem.
|
|
12815
|
+
VersionManage.add('plugin-rtc', "5.2.4-beem.9");
|
|
12816
|
+
if (!VersionManage.validEngine("4.6.0-beem.9")) {
|
|
12817
|
+
logger.error(`The current engine version '${VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"4.6.0-beem.9"}'.`);
|
|
12807
12818
|
return false;
|
|
12808
12819
|
}
|
|
12809
12820
|
return true;
|
|
@@ -12811,7 +12822,7 @@ const installer = {
|
|
|
12811
12822
|
setup(context, runtime, options = {}) {
|
|
12812
12823
|
logger.setLogLevel(options.logLevel);
|
|
12813
12824
|
logger.setLogStdout(options.logStdout);
|
|
12814
|
-
logger.warn(`RCRTC Version: ${"5.2.4-beem.
|
|
12825
|
+
logger.warn(`RCRTC Version: ${"5.2.4-beem.9"}, Commit: ${"23137f0f952c4650554fb300ff96fc6c1485a834"}`);
|
|
12815
12826
|
logger.warn(`browserInfo.browser -> ${browserInfo.browser}`);
|
|
12816
12827
|
logger.warn(`browserInfo.supportsUnifiedPlan -> ${browserInfo.supportsUnifiedPlan}`);
|
|
12817
12828
|
logger.warn(`browserInfo.version -> ${browserInfo.version}`);
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* RCRTC - v5.2.4-beem.
|
|
3
|
-
* CommitId -
|
|
4
|
-
*
|
|
2
|
+
* RCRTC - v5.2.4-beem.9
|
|
3
|
+
* CommitId - 23137f0f952c4650554fb300ff96fc6c1485a834
|
|
4
|
+
* Fri Jun 03 2022 12:42:39 GMT+0800 (China Standard Time)
|
|
5
5
|
* ©2020 RongCloud, Inc. All rights reserved.
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
@@ -130,8 +130,13 @@ var RTCSignalCode;
|
|
|
130
130
|
|
|
131
131
|
class AsyncTaskQueue {
|
|
132
132
|
constructor() {
|
|
133
|
+
/**
|
|
134
|
+
* 多个队列时便于区分队列实例的索引
|
|
135
|
+
*/
|
|
136
|
+
this.index = AsyncTaskQueue.queueCount++;
|
|
133
137
|
this.queue = [];
|
|
134
138
|
this.locked = false;
|
|
139
|
+
this.taskCount = 0;
|
|
135
140
|
}
|
|
136
141
|
checkToStart() {
|
|
137
142
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -139,8 +144,8 @@ class AsyncTaskQueue {
|
|
|
139
144
|
return;
|
|
140
145
|
}
|
|
141
146
|
this.locked = true;
|
|
142
|
-
const { resolve, task, reject } = this.queue.shift();
|
|
143
|
-
logger.info(`async task
|
|
147
|
+
const { resolve, task, reject, name, index } = this.queue.shift();
|
|
148
|
+
logger.info(`[${this.index}] async task exec -> task: ${name}, index: ${index}, length: ${this.queue.length}`);
|
|
144
149
|
let result;
|
|
145
150
|
try {
|
|
146
151
|
result = yield task();
|
|
@@ -154,15 +159,21 @@ class AsyncTaskQueue {
|
|
|
154
159
|
this.checkToStart();
|
|
155
160
|
});
|
|
156
161
|
}
|
|
157
|
-
push(task) {
|
|
162
|
+
push(task, _name = '') {
|
|
158
163
|
const promise = new Promise((resolve, reject) => {
|
|
159
|
-
const
|
|
160
|
-
|
|
164
|
+
const name = task.name || _name;
|
|
165
|
+
const index = this.taskCount++;
|
|
166
|
+
const length = this.queue.push({ resolve, task, reject, name, index });
|
|
167
|
+
logger.info(`[${this.index}] async task queue add -> task: ${name}, index: ${index}, length: ${length}`);
|
|
161
168
|
});
|
|
162
169
|
this.checkToStart();
|
|
163
170
|
return promise;
|
|
164
171
|
}
|
|
165
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* 实例递增计数
|
|
175
|
+
*/
|
|
176
|
+
AsyncTaskQueue.queueCount = 0;
|
|
166
177
|
const defQueeu = new AsyncTaskQueue();
|
|
167
178
|
/**
|
|
168
179
|
* 将异步任务推送到异步队列,队列内任务先进先出,依次执行,执行完成后通过
|
|
@@ -170,8 +181,8 @@ const defQueeu = new AsyncTaskQueue();
|
|
|
170
181
|
* @param task 传参不能是 `async () => {}` 所定义的异步函数,
|
|
171
182
|
* 只能使用明确的 `() => Promise<T> | T` 形式,避免转义时微任务被提前执行
|
|
172
183
|
*/
|
|
173
|
-
const push = (task) => {
|
|
174
|
-
return defQueeu.push(task);
|
|
184
|
+
const push = (task, name = '') => {
|
|
185
|
+
return defQueeu.push(task, name);
|
|
175
186
|
};
|
|
176
187
|
|
|
177
188
|
/*
|
|
@@ -8509,7 +8520,7 @@ class PolarisReporter {
|
|
|
8509
8520
|
* 加入房间
|
|
8510
8521
|
*/
|
|
8511
8522
|
sendR1() {
|
|
8512
|
-
const rtcVersion = "5.2.4-beem.
|
|
8523
|
+
const rtcVersion = "5.2.4-beem.9";
|
|
8513
8524
|
const imVersion = this._context.getCoreVersion();
|
|
8514
8525
|
const platform = 'web';
|
|
8515
8526
|
const pcName = navigator.platform;
|
|
@@ -8679,7 +8690,7 @@ class RCAbstractRoom {
|
|
|
8679
8690
|
* 需先清除房间内的己方资源,通知房间内其他人己方已取消当前资源的发布
|
|
8680
8691
|
* 该步骤没有必要与 MediaServer 的交互,因后续资源变更交互为全量交互
|
|
8681
8692
|
*/
|
|
8682
|
-
selfRes.length > 0 && push(() => this._unpublishPrev(selfRes));
|
|
8693
|
+
selfRes.length > 0 && push(() => this._unpublishPrev(selfRes), 'unpub-prev');
|
|
8683
8694
|
/**
|
|
8684
8695
|
* 观众升级为主播后不会收到全量 uri 消息,需直接触发人员、资源变更
|
|
8685
8696
|
*/
|
|
@@ -8798,29 +8809,20 @@ class RCAbstractRoom {
|
|
|
8798
8809
|
});
|
|
8799
8810
|
}
|
|
8800
8811
|
__parseInnerMessage(message) {
|
|
8801
|
-
|
|
8802
|
-
// 过滤非 RTC 消息
|
|
8803
|
-
if (conversationType !== engine.ConversationType.RTC_ROOM) {
|
|
8804
|
-
return false;
|
|
8805
|
-
}
|
|
8806
|
-
// 为 RTC 消息,但不属于当前房间,不处理
|
|
8807
|
-
if (roomId !== this._roomId) {
|
|
8808
|
-
return true;
|
|
8809
|
-
}
|
|
8810
|
-
logger.info(`recv inner msg -> message: ${JSON.stringify(message)} | roomid: ${this._roomId}`);
|
|
8812
|
+
logger.info(`room parse msg -> ${message.messageUId}`);
|
|
8811
8813
|
const content = message.content;
|
|
8812
8814
|
switch (message.messageType) {
|
|
8813
8815
|
case RCRTCMessageType.KICK:
|
|
8814
8816
|
this._kickoff(true, content);
|
|
8815
8817
|
break;
|
|
8816
8818
|
case RCRTCMessageType.STATE:
|
|
8817
|
-
this.msgTaskQueue.push(() => this._stateHandle(content));
|
|
8819
|
+
this.msgTaskQueue.push(() => this._stateHandle(content), `parse ${message.messageType}`);
|
|
8818
8820
|
break;
|
|
8819
8821
|
case RCRTCMessageType.MODIFY:
|
|
8820
8822
|
case RCRTCMessageType.PUBLISH:
|
|
8821
8823
|
case RCRTCMessageType.UNPUBLISH:
|
|
8822
8824
|
case RCRTCMessageType.TOTAL_CONTENT_RESOURCE:
|
|
8823
|
-
this.msgTaskQueue.push(() => this._resourceHandle(content, message.messageType, message.senderUserId));
|
|
8825
|
+
this.msgTaskQueue.push(() => this._resourceHandle(content, message.messageType, message.senderUserId), `parse ${message.messageType}`);
|
|
8824
8826
|
break;
|
|
8825
8827
|
case RCRTCMessageType.ROOM_NOTIFY:
|
|
8826
8828
|
this._callAppListener('onRoomAttributeChange', message.messageType, message.content);
|
|
@@ -8941,7 +8943,7 @@ class RCAbstractRoom {
|
|
|
8941
8943
|
if (subedTracks.length) {
|
|
8942
8944
|
const trackIds = subedTracks.map(item => item.getTrackId());
|
|
8943
8945
|
logger.info(`resub tracks -> ${JSON.stringify(trackIds)}`);
|
|
8944
|
-
const { code } = yield push(() => this.__subscribe(subedTracks, true));
|
|
8946
|
+
const { code } = yield push(() => this.__subscribe(subedTracks, true), 'resub');
|
|
8945
8947
|
if (code !== exports.RCRTCCode.SUCCESS) {
|
|
8946
8948
|
logger.error(`resub tracks failed -> code: ${code}, ids: ${JSON.stringify(trackIds)}`);
|
|
8947
8949
|
}
|
|
@@ -9293,7 +9295,7 @@ class RCAbstractRoom {
|
|
|
9293
9295
|
break;
|
|
9294
9296
|
}
|
|
9295
9297
|
}
|
|
9296
|
-
const code = yield push(() => this._context.setRTCTotalRes(this._roomId, buildPlusMessage(RCRTCMessageType.MODIFY, plusList), buildTotalURIMessageContent(publishedList), RCRTCMessageType.TOTAL_CONTENT_RESOURCE));
|
|
9298
|
+
const code = yield push(() => this._context.setRTCTotalRes(this._roomId, buildPlusMessage(RCRTCMessageType.MODIFY, plusList), buildTotalURIMessageContent(publishedList), RCRTCMessageType.TOTAL_CONTENT_RESOURCE), 'send-local-muted');
|
|
9297
9299
|
if (code !== engine.ErrorCode.SUCCESS) {
|
|
9298
9300
|
logger.error('notice `track.enabled` change failed -> code: ' + code);
|
|
9299
9301
|
}
|
|
@@ -9323,7 +9325,7 @@ class RCAbstractRoom {
|
|
|
9323
9325
|
*/
|
|
9324
9326
|
publish(tracks) {
|
|
9325
9327
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9326
|
-
return push(() => this.__publish(tracks));
|
|
9328
|
+
return push(() => this.__publish(tracks), 'pub');
|
|
9327
9329
|
});
|
|
9328
9330
|
}
|
|
9329
9331
|
__publish(tracks) {
|
|
@@ -9457,7 +9459,7 @@ class RCAbstractRoom {
|
|
|
9457
9459
|
if (resCode !== exports.RCRTCCode.SUCCESS) {
|
|
9458
9460
|
return { code: resCode };
|
|
9459
9461
|
}
|
|
9460
|
-
}));
|
|
9462
|
+
}), 'retry-exchange');
|
|
9461
9463
|
});
|
|
9462
9464
|
}
|
|
9463
9465
|
_exchangeHandle(body) {
|
|
@@ -9518,7 +9520,7 @@ class RCAbstractRoom {
|
|
|
9518
9520
|
*/
|
|
9519
9521
|
unpublish(tracks) {
|
|
9520
9522
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9521
|
-
return push(() => this.__unpublish(tracks));
|
|
9523
|
+
return push(() => this.__unpublish(tracks), 'unpub');
|
|
9522
9524
|
});
|
|
9523
9525
|
}
|
|
9524
9526
|
__unpublish(tracks) {
|
|
@@ -9605,7 +9607,7 @@ class RCAbstractRoom {
|
|
|
9605
9607
|
*/
|
|
9606
9608
|
subscribe(tracks) {
|
|
9607
9609
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9608
|
-
return push(() => this.__subscribe(tracks, false));
|
|
9610
|
+
return push(() => this.__subscribe(tracks, false), 'sub');
|
|
9609
9611
|
});
|
|
9610
9612
|
}
|
|
9611
9613
|
__subscribe(tracks, forceReq = false) {
|
|
@@ -9660,7 +9662,7 @@ class RCAbstractRoom {
|
|
|
9660
9662
|
*/
|
|
9661
9663
|
unsubscribe(tracks) {
|
|
9662
9664
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9663
|
-
return push(() => this.__unsubscribe(tracks));
|
|
9665
|
+
return push(() => this.__unsubscribe(tracks), 'unsub');
|
|
9664
9666
|
});
|
|
9665
9667
|
}
|
|
9666
9668
|
__unsubscribe(tracks) {
|
|
@@ -9721,7 +9723,7 @@ class RCAbstractRoom {
|
|
|
9721
9723
|
*/
|
|
9722
9724
|
updateSubList(tracks) {
|
|
9723
9725
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9724
|
-
return push(() => this._updateSubListHandle(tracks, false));
|
|
9726
|
+
return push(() => this._updateSubListHandle(tracks, false), 'update-sub-list');
|
|
9725
9727
|
});
|
|
9726
9728
|
}
|
|
9727
9729
|
_updateSubListHandle(tracks, forceReq = false) {
|
|
@@ -10570,7 +10572,7 @@ class RCLivingRoom extends RCAbstractRoom {
|
|
|
10570
10572
|
/**
|
|
10571
10573
|
* 扩散 cdn_uris
|
|
10572
10574
|
*/
|
|
10573
|
-
const { code: sendSingalCode } = yield push(() => __awaiter(this, void 0, void 0, function* () { return this._sendCDNInfoSignal(); }));
|
|
10575
|
+
const { code: sendSingalCode } = yield push(() => __awaiter(this, void 0, void 0, function* () { return this._sendCDNInfoSignal(); }), 'send-cdninfo');
|
|
10574
10576
|
if (sendSingalCode === exports.RCRTCCode.SUCCESS) {
|
|
10575
10577
|
logger.info('enableInnerCDN succeed');
|
|
10576
10578
|
return { code: exports.RCRTCCode.SUCCESS };
|
|
@@ -10771,7 +10773,7 @@ const getCommonHeader = () => ({
|
|
|
10771
10773
|
'Content-Type': 'application/json;charset=UTF-8',
|
|
10772
10774
|
'Cache-Control': 'no-cache',
|
|
10773
10775
|
ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
|
|
10774
|
-
ClientVersion: "5.2.4-beem.
|
|
10776
|
+
ClientVersion: "5.2.4-beem.9",
|
|
10775
10777
|
'Client-Session-Id': getUUID(),
|
|
10776
10778
|
'Request-Id': Date.now().toString()
|
|
10777
10779
|
});
|
|
@@ -11062,7 +11064,7 @@ class RCAudienceClient {
|
|
|
11062
11064
|
*/
|
|
11063
11065
|
subscribe(liveUrl, livingType, mediaType, subTiny = false) {
|
|
11064
11066
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11065
|
-
return push(() => this.__subscribe(liveUrl, livingType, mediaType, subTiny));
|
|
11067
|
+
return push(() => this.__subscribe(liveUrl, livingType, mediaType, subTiny), 'audience-client-sub');
|
|
11066
11068
|
});
|
|
11067
11069
|
}
|
|
11068
11070
|
__subscribe(liveUrl, livingType, mediaType, subTiny = false) {
|
|
@@ -11157,7 +11159,7 @@ class RCAudienceClient {
|
|
|
11157
11159
|
*/
|
|
11158
11160
|
unsubscribe() {
|
|
11159
11161
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11160
|
-
return push(() => this.__unsubscribe());
|
|
11162
|
+
return push(() => this.__unsubscribe(), 'audience-client-unsub');
|
|
11161
11163
|
});
|
|
11162
11164
|
}
|
|
11163
11165
|
__unsubscribe() {
|
|
@@ -11503,7 +11505,7 @@ class RCAudienceLivingRoom {
|
|
|
11503
11505
|
if (subedTracks.length) {
|
|
11504
11506
|
const trackIds = subedTracks.map(item => item.getTrackId());
|
|
11505
11507
|
logger.debug(`resub tracks -> ${JSON.stringify(trackIds)}`);
|
|
11506
|
-
const { code } = yield push(() => this._subscribeHandle(subedTracks, true));
|
|
11508
|
+
const { code } = yield push(() => this._subscribeHandle(subedTracks, true), 'audience-resub');
|
|
11507
11509
|
if (code !== exports.RCRTCCode.SUCCESS) {
|
|
11508
11510
|
logger.error(`resub tracks failed -> code: ${code}, ids: ${JSON.stringify(trackIds)}`);
|
|
11509
11511
|
}
|
|
@@ -11603,7 +11605,7 @@ class RCAudienceLivingRoom {
|
|
|
11603
11605
|
if (resCode !== exports.RCRTCCode.SUCCESS) {
|
|
11604
11606
|
return { code: resCode };
|
|
11605
11607
|
}
|
|
11606
|
-
}));
|
|
11608
|
+
}), 'audience-retry-exchange');
|
|
11607
11609
|
});
|
|
11608
11610
|
}
|
|
11609
11611
|
/**
|
|
@@ -11948,7 +11950,7 @@ class RCAudienceLivingRoom {
|
|
|
11948
11950
|
*/
|
|
11949
11951
|
subscribe(tracks) {
|
|
11950
11952
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11951
|
-
return push(() => this._subscribeHandle(tracks, false));
|
|
11953
|
+
return push(() => this._subscribeHandle(tracks, false), 'audience-sub');
|
|
11952
11954
|
});
|
|
11953
11955
|
}
|
|
11954
11956
|
__unsubscribe(tracks) {
|
|
@@ -11974,7 +11976,7 @@ class RCAudienceLivingRoom {
|
|
|
11974
11976
|
*/
|
|
11975
11977
|
unsubscribe(tracks) {
|
|
11976
11978
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11977
|
-
return push(() => this.__unsubscribe(tracks));
|
|
11979
|
+
return push(() => this.__unsubscribe(tracks), 'audience-unsub');
|
|
11978
11980
|
});
|
|
11979
11981
|
}
|
|
11980
11982
|
/**
|
|
@@ -12199,7 +12201,16 @@ class RCRTCClient {
|
|
|
12199
12201
|
if (message.conversationType !== engine.ConversationType.RTC_ROOM) {
|
|
12200
12202
|
return false;
|
|
12201
12203
|
}
|
|
12202
|
-
(
|
|
12204
|
+
logger.info(`recv inner msg -> message: ${JSON.stringify(message)}`);
|
|
12205
|
+
if (!this._crtRoom) {
|
|
12206
|
+
logger.warn(`ignore msg, crt room does not exist -> messageUId: ${message.messageUId}`);
|
|
12207
|
+
}
|
|
12208
|
+
else if (message.targetId !== this._crtRoom.getRoomId()) {
|
|
12209
|
+
logger.warn(`ignore msg, roomId mismatch -> crtRoomId: ${this._crtRoom.getRoomId()}, msgTargetId: ${message.targetId}`);
|
|
12210
|
+
}
|
|
12211
|
+
else {
|
|
12212
|
+
(_a = this._crtRoom) === null || _a === void 0 ? void 0 : _a.__parseInnerMessage(message);
|
|
12213
|
+
}
|
|
12203
12214
|
return true;
|
|
12204
12215
|
}
|
|
12205
12216
|
/**
|
|
@@ -12218,7 +12229,7 @@ class RCRTCClient {
|
|
|
12218
12229
|
* @param roomType 加入房间的类型 默认参数 RTCMode.RTC
|
|
12219
12230
|
*/
|
|
12220
12231
|
joinRTCRoom(roomId, joinType, outerUserDatas, useMutilPeerC, roomType = engine.RTCMode.RTC) {
|
|
12221
|
-
return push(() => this._joinRTCRoom(roomId, joinType, outerUserDatas, useMutilPeerC, roomType));
|
|
12232
|
+
return push(() => this._joinRTCRoom(roomId, joinType, outerUserDatas, useMutilPeerC, roomType), 'join-rtcroom');
|
|
12222
12233
|
}
|
|
12223
12234
|
_joinRTCRoom(roomId, joinType, outerUserDatas, useMutilPeerC, roomType = engine.RTCMode.RTC) {
|
|
12224
12235
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -12260,7 +12271,7 @@ class RCRTCClient {
|
|
|
12260
12271
|
* @param livingType 直播间类型,`RCLivingType.AUDIO` 为音频直播,`RCLivingType.VIDEO` 为音视频直播
|
|
12261
12272
|
*/
|
|
12262
12273
|
joinLivingRoom(roomId, livingType) {
|
|
12263
|
-
return push(() => this._joinLivingRoom(roomId, livingType));
|
|
12274
|
+
return push(() => this._joinLivingRoom(roomId, livingType), 'join-livingroom');
|
|
12264
12275
|
}
|
|
12265
12276
|
_joinLivingRoom(roomId, livingType) {
|
|
12266
12277
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -12328,7 +12339,7 @@ class RCRTCClient {
|
|
|
12328
12339
|
* 退出并销毁当前房间实例,退出后该房间的所有方法将不可用
|
|
12329
12340
|
*/
|
|
12330
12341
|
leaveRoom(room) {
|
|
12331
|
-
return push(() => this._leaveRoom(room));
|
|
12342
|
+
return push(() => this._leaveRoom(room), 'leave-room');
|
|
12332
12343
|
}
|
|
12333
12344
|
_leaveRoom(room) {
|
|
12334
12345
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -12804,9 +12815,9 @@ const installer = {
|
|
|
12804
12815
|
logger.error('Please use the https protocol or use `http://localhost` to open the page!');
|
|
12805
12816
|
return false;
|
|
12806
12817
|
}
|
|
12807
|
-
engine.VersionManage.add('plugin-rtc', "5.2.4-beem.
|
|
12808
|
-
if (!engine.VersionManage.validEngine("4.6.0-beem.
|
|
12809
|
-
logger.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"4.6.0-beem.
|
|
12818
|
+
engine.VersionManage.add('plugin-rtc', "5.2.4-beem.9");
|
|
12819
|
+
if (!engine.VersionManage.validEngine("4.6.0-beem.9")) {
|
|
12820
|
+
logger.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"4.6.0-beem.9"}'.`);
|
|
12810
12821
|
return false;
|
|
12811
12822
|
}
|
|
12812
12823
|
return true;
|
|
@@ -12814,7 +12825,7 @@ const installer = {
|
|
|
12814
12825
|
setup(context, runtime, options = {}) {
|
|
12815
12826
|
logger.setLogLevel(options.logLevel);
|
|
12816
12827
|
logger.setLogStdout(options.logStdout);
|
|
12817
|
-
logger.warn(`RCRTC Version: ${"5.2.4-beem.
|
|
12828
|
+
logger.warn(`RCRTC Version: ${"5.2.4-beem.9"}, Commit: ${"23137f0f952c4650554fb300ff96fc6c1485a834"}`);
|
|
12818
12829
|
logger.warn(`browserInfo.browser -> ${browserInfo.browser}`);
|
|
12819
12830
|
logger.warn(`browserInfo.supportsUnifiedPlan -> ${browserInfo.supportsUnifiedPlan}`);
|
|
12820
12831
|
logger.warn(`browserInfo.version -> ${browserInfo.version}`);
|
package/dist/index.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* RCRTC - v5.2.4-beem.
|
|
3
|
-
* CommitId -
|
|
4
|
-
*
|
|
2
|
+
* RCRTC - v5.2.4-beem.9
|
|
3
|
+
* CommitId - 23137f0f952c4650554fb300ff96fc6c1485a834
|
|
4
|
+
* Fri Jun 03 2022 12:42:39 GMT+0800 (China Standard Time)
|
|
5
5
|
* ©2020 RongCloud, Inc. All rights reserved.
|
|
6
6
|
*/
|
|
7
7
|
(function (global, factory) {
|
|
@@ -130,8 +130,13 @@
|
|
|
130
130
|
|
|
131
131
|
class AsyncTaskQueue {
|
|
132
132
|
constructor() {
|
|
133
|
+
/**
|
|
134
|
+
* 多个队列时便于区分队列实例的索引
|
|
135
|
+
*/
|
|
136
|
+
this.index = AsyncTaskQueue.queueCount++;
|
|
133
137
|
this.queue = [];
|
|
134
138
|
this.locked = false;
|
|
139
|
+
this.taskCount = 0;
|
|
135
140
|
}
|
|
136
141
|
checkToStart() {
|
|
137
142
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -139,8 +144,8 @@
|
|
|
139
144
|
return;
|
|
140
145
|
}
|
|
141
146
|
this.locked = true;
|
|
142
|
-
const { resolve, task, reject } = this.queue.shift();
|
|
143
|
-
logger.info(`async task
|
|
147
|
+
const { resolve, task, reject, name, index } = this.queue.shift();
|
|
148
|
+
logger.info(`[${this.index}] async task exec -> task: ${name}, index: ${index}, length: ${this.queue.length}`);
|
|
144
149
|
let result;
|
|
145
150
|
try {
|
|
146
151
|
result = yield task();
|
|
@@ -154,15 +159,21 @@
|
|
|
154
159
|
this.checkToStart();
|
|
155
160
|
});
|
|
156
161
|
}
|
|
157
|
-
push(task) {
|
|
162
|
+
push(task, _name = '') {
|
|
158
163
|
const promise = new Promise((resolve, reject) => {
|
|
159
|
-
const
|
|
160
|
-
|
|
164
|
+
const name = task.name || _name;
|
|
165
|
+
const index = this.taskCount++;
|
|
166
|
+
const length = this.queue.push({ resolve, task, reject, name, index });
|
|
167
|
+
logger.info(`[${this.index}] async task queue add -> task: ${name}, index: ${index}, length: ${length}`);
|
|
161
168
|
});
|
|
162
169
|
this.checkToStart();
|
|
163
170
|
return promise;
|
|
164
171
|
}
|
|
165
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* 实例递增计数
|
|
175
|
+
*/
|
|
176
|
+
AsyncTaskQueue.queueCount = 0;
|
|
166
177
|
const defQueeu = new AsyncTaskQueue();
|
|
167
178
|
/**
|
|
168
179
|
* 将异步任务推送到异步队列,队列内任务先进先出,依次执行,执行完成后通过
|
|
@@ -170,8 +181,8 @@
|
|
|
170
181
|
* @param task 传参不能是 `async () => {}` 所定义的异步函数,
|
|
171
182
|
* 只能使用明确的 `() => Promise<T> | T` 形式,避免转义时微任务被提前执行
|
|
172
183
|
*/
|
|
173
|
-
const push = (task) => {
|
|
174
|
-
return defQueeu.push(task);
|
|
184
|
+
const push = (task, name = '') => {
|
|
185
|
+
return defQueeu.push(task, name);
|
|
175
186
|
};
|
|
176
187
|
|
|
177
188
|
/*
|
|
@@ -8509,7 +8520,7 @@
|
|
|
8509
8520
|
* 加入房间
|
|
8510
8521
|
*/
|
|
8511
8522
|
sendR1() {
|
|
8512
|
-
const rtcVersion = "5.2.4-beem.
|
|
8523
|
+
const rtcVersion = "5.2.4-beem.9";
|
|
8513
8524
|
const imVersion = this._context.getCoreVersion();
|
|
8514
8525
|
const platform = 'web';
|
|
8515
8526
|
const pcName = navigator.platform;
|
|
@@ -8679,7 +8690,7 @@
|
|
|
8679
8690
|
* 需先清除房间内的己方资源,通知房间内其他人己方已取消当前资源的发布
|
|
8680
8691
|
* 该步骤没有必要与 MediaServer 的交互,因后续资源变更交互为全量交互
|
|
8681
8692
|
*/
|
|
8682
|
-
selfRes.length > 0 && push(() => this._unpublishPrev(selfRes));
|
|
8693
|
+
selfRes.length > 0 && push(() => this._unpublishPrev(selfRes), 'unpub-prev');
|
|
8683
8694
|
/**
|
|
8684
8695
|
* 观众升级为主播后不会收到全量 uri 消息,需直接触发人员、资源变更
|
|
8685
8696
|
*/
|
|
@@ -8798,29 +8809,20 @@
|
|
|
8798
8809
|
});
|
|
8799
8810
|
}
|
|
8800
8811
|
__parseInnerMessage(message) {
|
|
8801
|
-
|
|
8802
|
-
// 过滤非 RTC 消息
|
|
8803
|
-
if (conversationType !== engine.ConversationType.RTC_ROOM) {
|
|
8804
|
-
return false;
|
|
8805
|
-
}
|
|
8806
|
-
// 为 RTC 消息,但不属于当前房间,不处理
|
|
8807
|
-
if (roomId !== this._roomId) {
|
|
8808
|
-
return true;
|
|
8809
|
-
}
|
|
8810
|
-
logger.info(`recv inner msg -> message: ${JSON.stringify(message)} | roomid: ${this._roomId}`);
|
|
8812
|
+
logger.info(`room parse msg -> ${message.messageUId}`);
|
|
8811
8813
|
const content = message.content;
|
|
8812
8814
|
switch (message.messageType) {
|
|
8813
8815
|
case RCRTCMessageType.KICK:
|
|
8814
8816
|
this._kickoff(true, content);
|
|
8815
8817
|
break;
|
|
8816
8818
|
case RCRTCMessageType.STATE:
|
|
8817
|
-
this.msgTaskQueue.push(() => this._stateHandle(content));
|
|
8819
|
+
this.msgTaskQueue.push(() => this._stateHandle(content), `parse ${message.messageType}`);
|
|
8818
8820
|
break;
|
|
8819
8821
|
case RCRTCMessageType.MODIFY:
|
|
8820
8822
|
case RCRTCMessageType.PUBLISH:
|
|
8821
8823
|
case RCRTCMessageType.UNPUBLISH:
|
|
8822
8824
|
case RCRTCMessageType.TOTAL_CONTENT_RESOURCE:
|
|
8823
|
-
this.msgTaskQueue.push(() => this._resourceHandle(content, message.messageType, message.senderUserId));
|
|
8825
|
+
this.msgTaskQueue.push(() => this._resourceHandle(content, message.messageType, message.senderUserId), `parse ${message.messageType}`);
|
|
8824
8826
|
break;
|
|
8825
8827
|
case RCRTCMessageType.ROOM_NOTIFY:
|
|
8826
8828
|
this._callAppListener('onRoomAttributeChange', message.messageType, message.content);
|
|
@@ -8941,7 +8943,7 @@
|
|
|
8941
8943
|
if (subedTracks.length) {
|
|
8942
8944
|
const trackIds = subedTracks.map(item => item.getTrackId());
|
|
8943
8945
|
logger.info(`resub tracks -> ${JSON.stringify(trackIds)}`);
|
|
8944
|
-
const { code } = yield push(() => this.__subscribe(subedTracks, true));
|
|
8946
|
+
const { code } = yield push(() => this.__subscribe(subedTracks, true), 'resub');
|
|
8945
8947
|
if (code !== exports.RCRTCCode.SUCCESS) {
|
|
8946
8948
|
logger.error(`resub tracks failed -> code: ${code}, ids: ${JSON.stringify(trackIds)}`);
|
|
8947
8949
|
}
|
|
@@ -9293,7 +9295,7 @@
|
|
|
9293
9295
|
break;
|
|
9294
9296
|
}
|
|
9295
9297
|
}
|
|
9296
|
-
const code = yield push(() => this._context.setRTCTotalRes(this._roomId, buildPlusMessage(RCRTCMessageType.MODIFY, plusList), buildTotalURIMessageContent(publishedList), RCRTCMessageType.TOTAL_CONTENT_RESOURCE));
|
|
9298
|
+
const code = yield push(() => this._context.setRTCTotalRes(this._roomId, buildPlusMessage(RCRTCMessageType.MODIFY, plusList), buildTotalURIMessageContent(publishedList), RCRTCMessageType.TOTAL_CONTENT_RESOURCE), 'send-local-muted');
|
|
9297
9299
|
if (code !== engine.ErrorCode.SUCCESS) {
|
|
9298
9300
|
logger.error('notice `track.enabled` change failed -> code: ' + code);
|
|
9299
9301
|
}
|
|
@@ -9323,7 +9325,7 @@
|
|
|
9323
9325
|
*/
|
|
9324
9326
|
publish(tracks) {
|
|
9325
9327
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9326
|
-
return push(() => this.__publish(tracks));
|
|
9328
|
+
return push(() => this.__publish(tracks), 'pub');
|
|
9327
9329
|
});
|
|
9328
9330
|
}
|
|
9329
9331
|
__publish(tracks) {
|
|
@@ -9457,7 +9459,7 @@
|
|
|
9457
9459
|
if (resCode !== exports.RCRTCCode.SUCCESS) {
|
|
9458
9460
|
return { code: resCode };
|
|
9459
9461
|
}
|
|
9460
|
-
}));
|
|
9462
|
+
}), 'retry-exchange');
|
|
9461
9463
|
});
|
|
9462
9464
|
}
|
|
9463
9465
|
_exchangeHandle(body) {
|
|
@@ -9518,7 +9520,7 @@
|
|
|
9518
9520
|
*/
|
|
9519
9521
|
unpublish(tracks) {
|
|
9520
9522
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9521
|
-
return push(() => this.__unpublish(tracks));
|
|
9523
|
+
return push(() => this.__unpublish(tracks), 'unpub');
|
|
9522
9524
|
});
|
|
9523
9525
|
}
|
|
9524
9526
|
__unpublish(tracks) {
|
|
@@ -9605,7 +9607,7 @@
|
|
|
9605
9607
|
*/
|
|
9606
9608
|
subscribe(tracks) {
|
|
9607
9609
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9608
|
-
return push(() => this.__subscribe(tracks, false));
|
|
9610
|
+
return push(() => this.__subscribe(tracks, false), 'sub');
|
|
9609
9611
|
});
|
|
9610
9612
|
}
|
|
9611
9613
|
__subscribe(tracks, forceReq = false) {
|
|
@@ -9660,7 +9662,7 @@
|
|
|
9660
9662
|
*/
|
|
9661
9663
|
unsubscribe(tracks) {
|
|
9662
9664
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9663
|
-
return push(() => this.__unsubscribe(tracks));
|
|
9665
|
+
return push(() => this.__unsubscribe(tracks), 'unsub');
|
|
9664
9666
|
});
|
|
9665
9667
|
}
|
|
9666
9668
|
__unsubscribe(tracks) {
|
|
@@ -9721,7 +9723,7 @@
|
|
|
9721
9723
|
*/
|
|
9722
9724
|
updateSubList(tracks) {
|
|
9723
9725
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9724
|
-
return push(() => this._updateSubListHandle(tracks, false));
|
|
9726
|
+
return push(() => this._updateSubListHandle(tracks, false), 'update-sub-list');
|
|
9725
9727
|
});
|
|
9726
9728
|
}
|
|
9727
9729
|
_updateSubListHandle(tracks, forceReq = false) {
|
|
@@ -10570,7 +10572,7 @@
|
|
|
10570
10572
|
/**
|
|
10571
10573
|
* 扩散 cdn_uris
|
|
10572
10574
|
*/
|
|
10573
|
-
const { code: sendSingalCode } = yield push(() => __awaiter(this, void 0, void 0, function* () { return this._sendCDNInfoSignal(); }));
|
|
10575
|
+
const { code: sendSingalCode } = yield push(() => __awaiter(this, void 0, void 0, function* () { return this._sendCDNInfoSignal(); }), 'send-cdninfo');
|
|
10574
10576
|
if (sendSingalCode === exports.RCRTCCode.SUCCESS) {
|
|
10575
10577
|
logger.info('enableInnerCDN succeed');
|
|
10576
10578
|
return { code: exports.RCRTCCode.SUCCESS };
|
|
@@ -10771,7 +10773,7 @@
|
|
|
10771
10773
|
'Content-Type': 'application/json;charset=UTF-8',
|
|
10772
10774
|
'Cache-Control': 'no-cache',
|
|
10773
10775
|
ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
|
|
10774
|
-
ClientVersion: "5.2.4-beem.
|
|
10776
|
+
ClientVersion: "5.2.4-beem.9",
|
|
10775
10777
|
'Client-Session-Id': getUUID(),
|
|
10776
10778
|
'Request-Id': Date.now().toString()
|
|
10777
10779
|
});
|
|
@@ -11062,7 +11064,7 @@
|
|
|
11062
11064
|
*/
|
|
11063
11065
|
subscribe(liveUrl, livingType, mediaType, subTiny = false) {
|
|
11064
11066
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11065
|
-
return push(() => this.__subscribe(liveUrl, livingType, mediaType, subTiny));
|
|
11067
|
+
return push(() => this.__subscribe(liveUrl, livingType, mediaType, subTiny), 'audience-client-sub');
|
|
11066
11068
|
});
|
|
11067
11069
|
}
|
|
11068
11070
|
__subscribe(liveUrl, livingType, mediaType, subTiny = false) {
|
|
@@ -11157,7 +11159,7 @@
|
|
|
11157
11159
|
*/
|
|
11158
11160
|
unsubscribe() {
|
|
11159
11161
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11160
|
-
return push(() => this.__unsubscribe());
|
|
11162
|
+
return push(() => this.__unsubscribe(), 'audience-client-unsub');
|
|
11161
11163
|
});
|
|
11162
11164
|
}
|
|
11163
11165
|
__unsubscribe() {
|
|
@@ -11503,7 +11505,7 @@
|
|
|
11503
11505
|
if (subedTracks.length) {
|
|
11504
11506
|
const trackIds = subedTracks.map(item => item.getTrackId());
|
|
11505
11507
|
logger.debug(`resub tracks -> ${JSON.stringify(trackIds)}`);
|
|
11506
|
-
const { code } = yield push(() => this._subscribeHandle(subedTracks, true));
|
|
11508
|
+
const { code } = yield push(() => this._subscribeHandle(subedTracks, true), 'audience-resub');
|
|
11507
11509
|
if (code !== exports.RCRTCCode.SUCCESS) {
|
|
11508
11510
|
logger.error(`resub tracks failed -> code: ${code}, ids: ${JSON.stringify(trackIds)}`);
|
|
11509
11511
|
}
|
|
@@ -11603,7 +11605,7 @@
|
|
|
11603
11605
|
if (resCode !== exports.RCRTCCode.SUCCESS) {
|
|
11604
11606
|
return { code: resCode };
|
|
11605
11607
|
}
|
|
11606
|
-
}));
|
|
11608
|
+
}), 'audience-retry-exchange');
|
|
11607
11609
|
});
|
|
11608
11610
|
}
|
|
11609
11611
|
/**
|
|
@@ -11948,7 +11950,7 @@
|
|
|
11948
11950
|
*/
|
|
11949
11951
|
subscribe(tracks) {
|
|
11950
11952
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11951
|
-
return push(() => this._subscribeHandle(tracks, false));
|
|
11953
|
+
return push(() => this._subscribeHandle(tracks, false), 'audience-sub');
|
|
11952
11954
|
});
|
|
11953
11955
|
}
|
|
11954
11956
|
__unsubscribe(tracks) {
|
|
@@ -11974,7 +11976,7 @@
|
|
|
11974
11976
|
*/
|
|
11975
11977
|
unsubscribe(tracks) {
|
|
11976
11978
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11977
|
-
return push(() => this.__unsubscribe(tracks));
|
|
11979
|
+
return push(() => this.__unsubscribe(tracks), 'audience-unsub');
|
|
11978
11980
|
});
|
|
11979
11981
|
}
|
|
11980
11982
|
/**
|
|
@@ -12199,7 +12201,16 @@
|
|
|
12199
12201
|
if (message.conversationType !== engine.ConversationType.RTC_ROOM) {
|
|
12200
12202
|
return false;
|
|
12201
12203
|
}
|
|
12202
|
-
(
|
|
12204
|
+
logger.info(`recv inner msg -> message: ${JSON.stringify(message)}`);
|
|
12205
|
+
if (!this._crtRoom) {
|
|
12206
|
+
logger.warn(`ignore msg, crt room does not exist -> messageUId: ${message.messageUId}`);
|
|
12207
|
+
}
|
|
12208
|
+
else if (message.targetId !== this._crtRoom.getRoomId()) {
|
|
12209
|
+
logger.warn(`ignore msg, roomId mismatch -> crtRoomId: ${this._crtRoom.getRoomId()}, msgTargetId: ${message.targetId}`);
|
|
12210
|
+
}
|
|
12211
|
+
else {
|
|
12212
|
+
(_a = this._crtRoom) === null || _a === void 0 ? void 0 : _a.__parseInnerMessage(message);
|
|
12213
|
+
}
|
|
12203
12214
|
return true;
|
|
12204
12215
|
}
|
|
12205
12216
|
/**
|
|
@@ -12218,7 +12229,7 @@
|
|
|
12218
12229
|
* @param roomType 加入房间的类型 默认参数 RTCMode.RTC
|
|
12219
12230
|
*/
|
|
12220
12231
|
joinRTCRoom(roomId, joinType, outerUserDatas, useMutilPeerC, roomType = engine.RTCMode.RTC) {
|
|
12221
|
-
return push(() => this._joinRTCRoom(roomId, joinType, outerUserDatas, useMutilPeerC, roomType));
|
|
12232
|
+
return push(() => this._joinRTCRoom(roomId, joinType, outerUserDatas, useMutilPeerC, roomType), 'join-rtcroom');
|
|
12222
12233
|
}
|
|
12223
12234
|
_joinRTCRoom(roomId, joinType, outerUserDatas, useMutilPeerC, roomType = engine.RTCMode.RTC) {
|
|
12224
12235
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -12260,7 +12271,7 @@
|
|
|
12260
12271
|
* @param livingType 直播间类型,`RCLivingType.AUDIO` 为音频直播,`RCLivingType.VIDEO` 为音视频直播
|
|
12261
12272
|
*/
|
|
12262
12273
|
joinLivingRoom(roomId, livingType) {
|
|
12263
|
-
return push(() => this._joinLivingRoom(roomId, livingType));
|
|
12274
|
+
return push(() => this._joinLivingRoom(roomId, livingType), 'join-livingroom');
|
|
12264
12275
|
}
|
|
12265
12276
|
_joinLivingRoom(roomId, livingType) {
|
|
12266
12277
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -12328,7 +12339,7 @@
|
|
|
12328
12339
|
* 退出并销毁当前房间实例,退出后该房间的所有方法将不可用
|
|
12329
12340
|
*/
|
|
12330
12341
|
leaveRoom(room) {
|
|
12331
|
-
return push(() => this._leaveRoom(room));
|
|
12342
|
+
return push(() => this._leaveRoom(room), 'leave-room');
|
|
12332
12343
|
}
|
|
12333
12344
|
_leaveRoom(room) {
|
|
12334
12345
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -12804,9 +12815,9 @@
|
|
|
12804
12815
|
logger.error('Please use the https protocol or use `http://localhost` to open the page!');
|
|
12805
12816
|
return false;
|
|
12806
12817
|
}
|
|
12807
|
-
engine.VersionManage.add('plugin-rtc', "5.2.4-beem.
|
|
12808
|
-
if (!engine.VersionManage.validEngine("4.6.0-beem.
|
|
12809
|
-
logger.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"4.6.0-beem.
|
|
12818
|
+
engine.VersionManage.add('plugin-rtc', "5.2.4-beem.9");
|
|
12819
|
+
if (!engine.VersionManage.validEngine("4.6.0-beem.9")) {
|
|
12820
|
+
logger.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"4.6.0-beem.9"}'.`);
|
|
12810
12821
|
return false;
|
|
12811
12822
|
}
|
|
12812
12823
|
return true;
|
|
@@ -12814,7 +12825,7 @@
|
|
|
12814
12825
|
setup(context, runtime, options = {}) {
|
|
12815
12826
|
logger.setLogLevel(options.logLevel);
|
|
12816
12827
|
logger.setLogStdout(options.logStdout);
|
|
12817
|
-
logger.warn(`RCRTC Version: ${"5.2.4-beem.
|
|
12828
|
+
logger.warn(`RCRTC Version: ${"5.2.4-beem.9"}, Commit: ${"23137f0f952c4650554fb300ff96fc6c1485a834"}`);
|
|
12818
12829
|
logger.warn(`browserInfo.browser -> ${browserInfo.browser}`);
|
|
12819
12830
|
logger.warn(`browserInfo.supportsUnifiedPlan -> ${browserInfo.supportsUnifiedPlan}`);
|
|
12820
12831
|
logger.warn(`browserInfo.version -> ${browserInfo.version}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rongcloud/plugin-rtc",
|
|
3
|
-
"version": "5.2.4-beem.
|
|
3
|
+
"version": "5.2.4-beem.9",
|
|
4
4
|
"description": "@rongcloud/plugin-rtc",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"__attrs__": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"node": ">=10.0.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@rongcloud/engine": "4.6.0-beem.
|
|
34
|
+
"@rongcloud/engine": "4.6.0-beem.9"
|
|
35
35
|
},
|
|
36
|
-
"__commit__": "
|
|
36
|
+
"__commit__": "23137f0f952c4650554fb300ff96fc6c1485a834"
|
|
37
37
|
}
|