@realsee/live 0.5.0-alpha.5 → 0.5.0-alpha.6
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/live/controller.d.ts +4 -0
- package/dist/live/live.d.ts +0 -5
- package/dist/realsee-live.cjs.development.js +75 -49
- package/dist/realsee-live.cjs.development.js.map +1 -1
- package/dist/realsee-live.cjs.production.js +1 -1
- package/dist/realsee-live.cjs.production.js.map +1 -1
- package/dist/realsee-live.esm.js +75 -49
- package/dist/realsee-live.esm.js.map +1 -1
- package/dist/realsee-live.umd.development.js +75 -49
- package/dist/realsee-live.umd.development.js.map +1 -1
- package/dist/realsee-live.umd.production.js +1 -1
- package/dist/realsee-live.umd.production.js.map +1 -1
- package/dist/utils/RobustWebSocket.d.ts +19 -0
- package/docs/classes/VRWebViewRTC.html +5 -5
- package/package.json +1 -1
|
@@ -48512,9 +48512,12 @@
|
|
|
48512
48512
|
this.micro = false;
|
|
48513
48513
|
this.voiceId = '';
|
|
48514
48514
|
this.options = { jsBridge, getVoiceSign };
|
|
48515
|
-
|
|
48516
|
-
|
|
48517
|
-
|
|
48515
|
+
// TO-DO: 在微信小程序下有个音量上报的BUG会导致消息体过大从而jsbridge异常断开
|
|
48516
|
+
if (this.jsBridge.webViewType !== "WxMiniProgramWebView") {
|
|
48517
|
+
this.jsBridge.callAndListen('live/userVolumes', (userVolumes) => {
|
|
48518
|
+
this.emit('userVolumes', userVolumes);
|
|
48519
|
+
});
|
|
48520
|
+
}
|
|
48518
48521
|
this.jsBridge.callAndListen('live/weakNetwork', (weakNetwork) => {
|
|
48519
48522
|
if (weakNetwork)
|
|
48520
48523
|
this.emit('weakNetwork');
|
|
@@ -50870,6 +50873,7 @@
|
|
|
50870
50873
|
constructor(options) {
|
|
50871
50874
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
50872
50875
|
super();
|
|
50876
|
+
this._readyState = exports.WebSocketState.NOTINITIALIZED;
|
|
50873
50877
|
this._options = {
|
|
50874
50878
|
timeout: 10000,
|
|
50875
50879
|
shouldReconnect: (event, ws) => {
|
|
@@ -50886,6 +50890,43 @@
|
|
|
50886
50890
|
this._reconnectWhenOnlineAgain = false;
|
|
50887
50891
|
this._explicitlyClosed = false;
|
|
50888
50892
|
this._connectivityEventsAttached = false;
|
|
50893
|
+
/**
|
|
50894
|
+
* 做一个健康检查
|
|
50895
|
+
*/
|
|
50896
|
+
this._healthCheck = () => __awaiter$$(this, void 0, void 0, function* () {
|
|
50897
|
+
if (this._realWebSocket &&
|
|
50898
|
+
this._realWebSocket.readyState !== this._readyState) {
|
|
50899
|
+
this._readyState = this._realWebSocket.readyState;
|
|
50900
|
+
// 太惨了,断网的时候,ws不会直接closed,而是处于closing的状态
|
|
50901
|
+
if (this._readyState === exports.WebSocketState.CLOSING) {
|
|
50902
|
+
this.emit('closing');
|
|
50903
|
+
}
|
|
50904
|
+
}
|
|
50905
|
+
yield new Promise((resolve) => setTimeout(resolve, 2000));
|
|
50906
|
+
this._heathCheckTimer = requestAnimationFrame(this._healthCheck);
|
|
50907
|
+
});
|
|
50908
|
+
/**
|
|
50909
|
+
* 清理健康检查
|
|
50910
|
+
*/
|
|
50911
|
+
this._clearHeathCheckIfNeed = () => {
|
|
50912
|
+
if (this._heathCheckTimer) {
|
|
50913
|
+
cancelAnimationFrame(this._heathCheckTimer);
|
|
50914
|
+
this._heathCheckTimer = undefined;
|
|
50915
|
+
}
|
|
50916
|
+
};
|
|
50917
|
+
/**
|
|
50918
|
+
* 开启健康检查
|
|
50919
|
+
*/
|
|
50920
|
+
this._startHealthCheck = () => {
|
|
50921
|
+
this._clearHeathCheckIfNeed();
|
|
50922
|
+
this._heathCheckTimer = requestAnimationFrame(this._healthCheck);
|
|
50923
|
+
};
|
|
50924
|
+
/**
|
|
50925
|
+
* 停止健康检查
|
|
50926
|
+
*/
|
|
50927
|
+
this._stopHealthCheck = () => {
|
|
50928
|
+
this._clearHeathCheckIfNeed();
|
|
50929
|
+
};
|
|
50889
50930
|
/**
|
|
50890
50931
|
* 清理连接中的请求
|
|
50891
50932
|
*/
|
|
@@ -50911,7 +50952,7 @@
|
|
|
50911
50952
|
this._offline = () => {
|
|
50912
50953
|
var _a;
|
|
50913
50954
|
this._reconnectWhenOnlineAgain = true;
|
|
50914
|
-
(_a = this._realWebSocket) === null || _a === void 0 ? void 0 : _a.close(1000);
|
|
50955
|
+
(_a = this._realWebSocket) === null || _a === void 0 ? void 0 : _a.close(1000, 'offline');
|
|
50915
50956
|
};
|
|
50916
50957
|
/**
|
|
50917
50958
|
* 解除网络监听事件
|
|
@@ -51042,6 +51083,7 @@
|
|
|
51042
51083
|
const attempts = this._attempts;
|
|
51043
51084
|
this._attempts = 0;
|
|
51044
51085
|
this._reconnectWhenOnlineAgain = false;
|
|
51086
|
+
this._startHealthCheck();
|
|
51045
51087
|
return this.emit('open', Object.assign(event, { detail: { reconnects, attempts } }));
|
|
51046
51088
|
};
|
|
51047
51089
|
/**
|
|
@@ -51051,6 +51093,7 @@
|
|
|
51051
51093
|
*/
|
|
51052
51094
|
this._webSocketCloseHandler = (event) => {
|
|
51053
51095
|
this._reconnect(event);
|
|
51096
|
+
this._stopHealthCheck();
|
|
51054
51097
|
return this.emit('close', event);
|
|
51055
51098
|
};
|
|
51056
51099
|
/**
|
|
@@ -51072,6 +51115,7 @@
|
|
|
51072
51115
|
if (options) {
|
|
51073
51116
|
this.setOptions(options);
|
|
51074
51117
|
}
|
|
51118
|
+
this._startHealthCheck();
|
|
51075
51119
|
}
|
|
51076
51120
|
get attempts() {
|
|
51077
51121
|
return this._attempts;
|
|
@@ -51132,6 +51176,7 @@
|
|
|
51132
51176
|
*/
|
|
51133
51177
|
this._addWebSocketEventListeners = () => {
|
|
51134
51178
|
this._ws.on('close', this._handleCloseEvent);
|
|
51179
|
+
this._ws.on('closing', this._handleClosingEvent);
|
|
51135
51180
|
this._ws.on('connecting', this._handleConnectingEvent);
|
|
51136
51181
|
this._ws.on('error', this._handleErrorEvent);
|
|
51137
51182
|
this._ws.on('message', this._handleMessageEvent);
|
|
@@ -51143,6 +51188,7 @@
|
|
|
51143
51188
|
*/
|
|
51144
51189
|
this._removeWebSocketEventListeners = () => {
|
|
51145
51190
|
this._ws.off('close', this._handleCloseEvent);
|
|
51191
|
+
this._ws.off('closing', this._handleClosingEvent);
|
|
51146
51192
|
this._ws.off('connecting', this._handleConnectingEvent);
|
|
51147
51193
|
this._ws.off('error', this._handleErrorEvent);
|
|
51148
51194
|
this._ws.off('message', this._handleMessageEvent);
|
|
@@ -51157,12 +51203,20 @@
|
|
|
51157
51203
|
logger$1.info(`live room closed bacause of ${event.code}-${event.reason || parseWSClsErr(event.code)}`);
|
|
51158
51204
|
this.state = exports.LiveState.CLOSED;
|
|
51159
51205
|
};
|
|
51206
|
+
/**
|
|
51207
|
+
* 处理房间正在关闭事件(这个时候可能是断网了)
|
|
51208
|
+
*/
|
|
51209
|
+
this._handleClosingEvent = () => {
|
|
51210
|
+
var _a;
|
|
51211
|
+
logger$1.info(`live room is closing, onLine:`, (_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _a === void 0 ? void 0 : _a.onLine);
|
|
51212
|
+
this.state = exports.LiveState.CLOSED;
|
|
51213
|
+
};
|
|
51160
51214
|
/**
|
|
51161
51215
|
* 连接中
|
|
51162
51216
|
* @param event
|
|
51163
51217
|
*/
|
|
51164
|
-
this._handleConnectingEvent = (
|
|
51165
|
-
logger$1.info(`live room is connecting
|
|
51218
|
+
this._handleConnectingEvent = () => {
|
|
51219
|
+
logger$1.info(`live room is connecting`);
|
|
51166
51220
|
this.state = exports.LiveState.CONNECTING;
|
|
51167
51221
|
};
|
|
51168
51222
|
/**
|
|
@@ -51325,7 +51379,6 @@
|
|
|
51325
51379
|
this._addLiveControllerEventListeners = () => {
|
|
51326
51380
|
this._controller.on('stateChange', this._handleStateChange);
|
|
51327
51381
|
this._controller.on('message', this._handleMessage);
|
|
51328
|
-
this._controller.on('reconnected', this._handleReconnected);
|
|
51329
51382
|
};
|
|
51330
51383
|
/**
|
|
51331
51384
|
* 移除带看控制的事件监听
|
|
@@ -51333,7 +51386,6 @@
|
|
|
51333
51386
|
this._removeLiveControllerEventListeners = () => {
|
|
51334
51387
|
this._controller.off('stateChange', this._handleStateChange);
|
|
51335
51388
|
this._controller.off('message', this._handleMessage);
|
|
51336
|
-
this._controller.off('reconnected', this._handleReconnected);
|
|
51337
51389
|
};
|
|
51338
51390
|
/**
|
|
51339
51391
|
* 带看状态变化
|
|
@@ -51488,32 +51540,6 @@
|
|
|
51488
51540
|
}
|
|
51489
51541
|
}
|
|
51490
51542
|
});
|
|
51491
|
-
/**
|
|
51492
|
-
* 处理重连
|
|
51493
|
-
* @param detail
|
|
51494
|
-
*/
|
|
51495
|
-
this._handleReconnected = (detail) => __awaiter$$(this, void 0, void 0, function* () {
|
|
51496
|
-
var _h, _j, _k, _l, _m, _o, _p;
|
|
51497
|
-
// 已经重连上ws,尝试重连语音
|
|
51498
|
-
this.$RTC.joined = false;
|
|
51499
|
-
const { rtcInfo } = this._buildInData;
|
|
51500
|
-
if (rtcInfo) {
|
|
51501
|
-
const { voiceId, type } = rtcInfo;
|
|
51502
|
-
const result = yield ((_h = this.$RTC) === null || _h === void 0 ? void 0 : _h.join({
|
|
51503
|
-
voiceId,
|
|
51504
|
-
userId: ((_j = this.selfInfo) === null || _j === void 0 ? void 0 : _j.id) || '',
|
|
51505
|
-
roomId: (_k = this.roomInfo) === null || _k === void 0 ? void 0 : _k.info.room_code,
|
|
51506
|
-
type,
|
|
51507
|
-
}));
|
|
51508
|
-
if (result) {
|
|
51509
|
-
const status = (_o = (_m = (_l = this.selfInfo) === null || _l === void 0 ? void 0 : _l.micro_status) !== null && _m !== void 0 ? _m : this._options.initialMicroStatus) !== null && _o !== void 0 ? _o : exports.MicroStatus.OPEN;
|
|
51510
|
-
yield ((_p = this.$RTC) === null || _p === void 0 ? void 0 : _p.toggleMicro(status === exports.MicroStatus.OPEN));
|
|
51511
|
-
}
|
|
51512
|
-
else {
|
|
51513
|
-
logger$1.error('加入语音房间失败');
|
|
51514
|
-
}
|
|
51515
|
-
}
|
|
51516
|
-
});
|
|
51517
51543
|
/**
|
|
51518
51544
|
* 清理带看缓存的数据
|
|
51519
51545
|
*/
|
|
@@ -51526,12 +51552,12 @@
|
|
|
51526
51552
|
* @returns
|
|
51527
51553
|
*/
|
|
51528
51554
|
this.connect = (options = {}) => __awaiter$$(this, void 0, void 0, function* () {
|
|
51529
|
-
var
|
|
51555
|
+
var _h, _j, _k, _l;
|
|
51530
51556
|
// 检查 url 和 票据获取接口实现
|
|
51531
|
-
this._options.url = (
|
|
51532
|
-
this._options.getTicket = (
|
|
51557
|
+
this._options.url = (_j = (_h = options.url) !== null && _h !== void 0 ? _h : this._options.url) !== null && _j !== void 0 ? _j : '';
|
|
51558
|
+
this._options.getTicket = (_k = options.getTicket) !== null && _k !== void 0 ? _k : this._options.getTicket;
|
|
51533
51559
|
this._options.initialMicroStatus =
|
|
51534
|
-
(
|
|
51560
|
+
(_l = options.rtcMicStatus) !== null && _l !== void 0 ? _l : this._options.initialMicroStatus;
|
|
51535
51561
|
if (!/^ws(s):\/\//.test(this._options.url) ||
|
|
51536
51562
|
typeof this._options.getTicket !== 'function') {
|
|
51537
51563
|
if (!/^ws(s):\/\//.test(this._options.url)) {
|
|
@@ -51573,11 +51599,11 @@
|
|
|
51573
51599
|
* @returns
|
|
51574
51600
|
*/
|
|
51575
51601
|
this.exit = () => __awaiter$$(this, void 0, void 0, function* () {
|
|
51576
|
-
var
|
|
51602
|
+
var _m;
|
|
51577
51603
|
this._clearLiveData();
|
|
51578
51604
|
try {
|
|
51579
51605
|
/** 退出强制关闭语音 */
|
|
51580
|
-
(
|
|
51606
|
+
(_m = this.$RTC) === null || _m === void 0 ? void 0 : _m.quit();
|
|
51581
51607
|
yield this.updateStatus(exports.BuiltinEventType.RoomChange, exports.BuiltinActionType.RoomClose, {});
|
|
51582
51608
|
}
|
|
51583
51609
|
catch (e) {
|
|
@@ -51604,10 +51630,10 @@
|
|
|
51604
51630
|
});
|
|
51605
51631
|
// 仅用于用户自己的麦克风控制
|
|
51606
51632
|
this.toggleMicro = (microStatus) => __awaiter$$(this, void 0, void 0, function* () {
|
|
51607
|
-
var
|
|
51608
|
-
if (!((
|
|
51633
|
+
var _o, _p, _q;
|
|
51634
|
+
if (!((_p = (_o = this.selfInfo) === null || _o === void 0 ? void 0 : _o.permission) === null || _p === void 0 ? void 0 : _p.control_own_micro))
|
|
51609
51635
|
return false;
|
|
51610
|
-
const result = yield ((
|
|
51636
|
+
const result = yield ((_q = this.$RTC) === null || _q === void 0 ? void 0 : _q.toggleMicro(microStatus));
|
|
51611
51637
|
if (result) {
|
|
51612
51638
|
yield this.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserMicroStatus, {
|
|
51613
51639
|
status: microStatus ? exports.MicroStatus.OPEN : exports.MicroStatus.CLOSE,
|
|
@@ -51622,12 +51648,12 @@
|
|
|
51622
51648
|
* @returns
|
|
51623
51649
|
*/
|
|
51624
51650
|
this.forbidMicro = (microStatus, toUserIds) => __awaiter$$(this, void 0, void 0, function* () {
|
|
51625
|
-
var
|
|
51651
|
+
var _r, _s;
|
|
51626
51652
|
if (typeof this._options.canForbidUserMicro === 'function' &&
|
|
51627
51653
|
!this._options.canForbidUserMicro(toUserIds)) {
|
|
51628
51654
|
return false;
|
|
51629
51655
|
}
|
|
51630
|
-
if (!((
|
|
51656
|
+
if (!((_s = (_r = this.selfInfo) === null || _r === void 0 ? void 0 : _r.permission) === null || _s === void 0 ? void 0 : _s.control_other_micro)) {
|
|
51631
51657
|
return false;
|
|
51632
51658
|
}
|
|
51633
51659
|
return yield this.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserMicroStatus, {
|
|
@@ -51641,12 +51667,12 @@
|
|
|
51641
51667
|
* @returns
|
|
51642
51668
|
*/
|
|
51643
51669
|
this.forbidSync = (sync, toUserIds) => __awaiter$$(this, void 0, void 0, function* () {
|
|
51644
|
-
var
|
|
51670
|
+
var _t, _u;
|
|
51645
51671
|
if (typeof this._options.canForbidUserSync === 'function' &&
|
|
51646
51672
|
!this._options.canForbidUserSync(toUserIds)) {
|
|
51647
51673
|
return false;
|
|
51648
51674
|
}
|
|
51649
|
-
if (!((
|
|
51675
|
+
if (!((_u = (_t = this.selfInfo) === null || _t === void 0 ? void 0 : _t.permission) === null || _u === void 0 ? void 0 : _u.control_other_sync)) {
|
|
51650
51676
|
return false;
|
|
51651
51677
|
}
|
|
51652
51678
|
return yield this.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserPermission, { sync_frame: sync }, toUserIds);
|
|
@@ -51657,12 +51683,12 @@
|
|
|
51657
51683
|
* @returns
|
|
51658
51684
|
*/
|
|
51659
51685
|
this.kick = (toUserIds) => __awaiter$$(this, void 0, void 0, function* () {
|
|
51660
|
-
var
|
|
51686
|
+
var _v, _w;
|
|
51661
51687
|
if (typeof this._options.canForbidUserKick === 'function' &&
|
|
51662
51688
|
!this._options.canForbidUserKick(toUserIds)) {
|
|
51663
51689
|
return false;
|
|
51664
51690
|
}
|
|
51665
|
-
if (!((
|
|
51691
|
+
if (!((_w = (_v = this.selfInfo) === null || _v === void 0 ? void 0 : _v.permission) === null || _w === void 0 ? void 0 : _w.change_other_status)) {
|
|
51666
51692
|
return false;
|
|
51667
51693
|
}
|
|
51668
51694
|
return yield this.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserStatus, {
|