@realsee/live 0.5.0-alpha.1 → 0.5.0-alpha.12
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 +6 -0
- package/dist/live/createLiveReact.d.ts +2 -2
- package/dist/live/live.d.ts +9 -1
- package/dist/realsee-live.cjs.development.js +172 -72
- 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 +162 -62
- package/dist/realsee-live.esm.js.map +1 -1
- package/dist/realsee-live.umd.development.js +189 -73
- 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/typings/live/index.d.ts +1 -0
- package/dist/utils/RobustWebSocket.d.ts +23 -0
- package/docs/assets/search.js +1 -1
- package/docs/classes/VRWebViewRTC.html +5 -5
- package/docs/enums/LiveState.html +7 -0
- package/docs/index.html +1 -1
- package/docs/modules.html +14 -8
- package/package.json +2 -2
|
@@ -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');
|
|
@@ -48525,25 +48528,37 @@
|
|
|
48525
48528
|
}
|
|
48526
48529
|
join(options) {
|
|
48527
48530
|
return __awaiter$$(this, void 0, void 0, function* () {
|
|
48528
|
-
|
|
48529
|
-
|
|
48530
|
-
|
|
48531
|
-
|
|
48532
|
-
|
|
48533
|
-
|
|
48534
|
-
|
|
48535
|
-
}
|
|
48536
|
-
else {
|
|
48537
|
-
if (res.code === exports.RTCJoinedInfoCodeEnum.Success) {
|
|
48538
|
-
this.emit('joined');
|
|
48539
|
-
this.joined = true;
|
|
48531
|
+
try {
|
|
48532
|
+
this.emit('joinWillStart');
|
|
48533
|
+
const { sdkAppId, userId, userSig } = yield this.options.getVoiceSign(options);
|
|
48534
|
+
if (!(Boolean(sdkAppId) && Boolean(userId) && Boolean(userSig))) {
|
|
48535
|
+
this.emit('error', new Error('加入房间失败:rtc 签名请求异常'));
|
|
48536
|
+
this.joined = false;
|
|
48537
|
+
return this.joined;
|
|
48540
48538
|
}
|
|
48541
|
-
|
|
48542
|
-
|
|
48539
|
+
this.type = options.type;
|
|
48540
|
+
const [res, error] = yield this.jsBridge.callAndBackfeed(`live/join?sdkAppID=${sdkAppId}&userID=${userId}&roomID=${Number(options.voiceId)}&userSig=${userSig}`);
|
|
48541
|
+
if (!res) {
|
|
48542
|
+
this.emit('error', error ? error : new Error('加入房间失败:未知异常。'));
|
|
48543
48543
|
this.joined = false;
|
|
48544
48544
|
}
|
|
48545
|
+
else {
|
|
48546
|
+
if (res.code === exports.RTCJoinedInfoCodeEnum.Success) {
|
|
48547
|
+
this.emit('joined');
|
|
48548
|
+
this.joined = true;
|
|
48549
|
+
}
|
|
48550
|
+
else {
|
|
48551
|
+
this.emit('error', res);
|
|
48552
|
+
this.joined = false;
|
|
48553
|
+
}
|
|
48554
|
+
}
|
|
48555
|
+
return this.joined;
|
|
48556
|
+
}
|
|
48557
|
+
catch (e) {
|
|
48558
|
+
this.emit('error', new Error('加入房间失败:' + e.message));
|
|
48559
|
+
this.joined = false;
|
|
48560
|
+
return this.joined;
|
|
48545
48561
|
}
|
|
48546
|
-
return this.joined;
|
|
48547
48562
|
});
|
|
48548
48563
|
}
|
|
48549
48564
|
quit() {
|
|
@@ -48689,6 +48704,23 @@
|
|
|
48689
48704
|
}
|
|
48690
48705
|
}
|
|
48691
48706
|
|
|
48707
|
+
exports.LiveState = void 0;
|
|
48708
|
+
(function (LiveState) {
|
|
48709
|
+
LiveState[LiveState["NOTINITIALIZED"] = -1] = "NOTINITIALIZED";
|
|
48710
|
+
/**
|
|
48711
|
+
* 正在链接中
|
|
48712
|
+
*/
|
|
48713
|
+
LiveState[LiveState["CONNECTING"] = 0] = "CONNECTING";
|
|
48714
|
+
/**
|
|
48715
|
+
* 已经链接并且可以通讯
|
|
48716
|
+
*/
|
|
48717
|
+
LiveState[LiveState["OPEN"] = 1] = "OPEN";
|
|
48718
|
+
/**
|
|
48719
|
+
* 连接已关闭或者链接失败
|
|
48720
|
+
*/
|
|
48721
|
+
LiveState[LiveState["CLOSED"] = 3] = "CLOSED";
|
|
48722
|
+
})(exports.LiveState || (exports.LiveState = {}));
|
|
48723
|
+
|
|
48692
48724
|
/**
|
|
48693
48725
|
* 用户当前状态枚举。
|
|
48694
48726
|
*/
|
|
@@ -49435,7 +49467,12 @@
|
|
|
49435
49467
|
* @param data
|
|
49436
49468
|
* @returns
|
|
49437
49469
|
*/
|
|
49438
|
-
this.send = (data) => {
|
|
49470
|
+
this.send = (data) => {
|
|
49471
|
+
var _a, _b, _c;
|
|
49472
|
+
if (((_a = this._realWebSocket) === null || _a === void 0 ? void 0 : _a.readyState) === ((_b = this._realWebSocket) === null || _b === void 0 ? void 0 : _b.OPEN)) {
|
|
49473
|
+
(_c = this._realWebSocket) === null || _c === void 0 ? void 0 : _c.send(data);
|
|
49474
|
+
}
|
|
49475
|
+
};
|
|
49439
49476
|
/**
|
|
49440
49477
|
* 关闭连接
|
|
49441
49478
|
* @param code 代码
|
|
@@ -49479,6 +49516,7 @@
|
|
|
49479
49516
|
if (!newUrl)
|
|
49480
49517
|
return;
|
|
49481
49518
|
this._pendingReconnect = undefined;
|
|
49519
|
+
this._removeWebSocketEvent();
|
|
49482
49520
|
this._realWebSocket = new WebSocket(newUrl, this._protocols || undefined);
|
|
49483
49521
|
this._attempts = this._attempts + 1;
|
|
49484
49522
|
this.emit('connecting', new CustomEvent('connecting', {
|
|
@@ -49500,6 +49538,16 @@
|
|
|
49500
49538
|
this._attachConnectivityEvents();
|
|
49501
49539
|
}
|
|
49502
49540
|
};
|
|
49541
|
+
/**
|
|
49542
|
+
* 断开ws事件
|
|
49543
|
+
*/
|
|
49544
|
+
this._removeWebSocketEvent = () => {
|
|
49545
|
+
var _a, _b, _c, _d;
|
|
49546
|
+
(_a = this._realWebSocket) === null || _a === void 0 ? void 0 : _a.removeEventListener('open', this._webSocketOpenHandler);
|
|
49547
|
+
(_b = this._realWebSocket) === null || _b === void 0 ? void 0 : _b.removeEventListener('close', this._webSocketCloseHandler);
|
|
49548
|
+
(_c = this._realWebSocket) === null || _c === void 0 ? void 0 : _c.removeEventListener('error', this._webSocketErrorHandler);
|
|
49549
|
+
(_d = this._realWebSocket) === null || _d === void 0 ? void 0 : _d.removeEventListener('message', this._webSocketMessageHandler);
|
|
49550
|
+
};
|
|
49503
49551
|
/**
|
|
49504
49552
|
* 分发ws事件
|
|
49505
49553
|
*/
|
|
@@ -50636,23 +50684,6 @@
|
|
|
50636
50684
|
}
|
|
50637
50685
|
}
|
|
50638
50686
|
|
|
50639
|
-
var LiveState;
|
|
50640
|
-
(function (LiveState) {
|
|
50641
|
-
LiveState[LiveState["NOTINITIALIZED"] = -1] = "NOTINITIALIZED";
|
|
50642
|
-
/**
|
|
50643
|
-
* 正在链接中
|
|
50644
|
-
*/
|
|
50645
|
-
LiveState[LiveState["CONNECTING"] = 0] = "CONNECTING";
|
|
50646
|
-
/**
|
|
50647
|
-
* 已经链接并且可以通讯
|
|
50648
|
-
*/
|
|
50649
|
-
LiveState[LiveState["OPEN"] = 1] = "OPEN";
|
|
50650
|
-
/**
|
|
50651
|
-
* 连接已关闭或者链接失败
|
|
50652
|
-
*/
|
|
50653
|
-
LiveState[LiveState["CLOSED"] = 3] = "CLOSED";
|
|
50654
|
-
})(LiveState || (LiveState = {}));
|
|
50655
|
-
|
|
50656
50687
|
function appendUri(uri, query) {
|
|
50657
50688
|
const hasQuery = uri.indexOf('?') !== -1;
|
|
50658
50689
|
const newQuery = Object.keys(query).reduce((accu, curr, idx) => `${accu}${(idx === 0 && !hasQuery) ? '?' : '&'}${curr}=${query[curr]}`, '');
|
|
@@ -50854,6 +50885,7 @@
|
|
|
50854
50885
|
constructor(options) {
|
|
50855
50886
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
50856
50887
|
super();
|
|
50888
|
+
this._readyState = exports.WebSocketState.NOTINITIALIZED;
|
|
50857
50889
|
this._options = {
|
|
50858
50890
|
timeout: 10000,
|
|
50859
50891
|
shouldReconnect: (event, ws) => {
|
|
@@ -50870,6 +50902,43 @@
|
|
|
50870
50902
|
this._reconnectWhenOnlineAgain = false;
|
|
50871
50903
|
this._explicitlyClosed = false;
|
|
50872
50904
|
this._connectivityEventsAttached = false;
|
|
50905
|
+
/**
|
|
50906
|
+
* 做一个健康检查
|
|
50907
|
+
*/
|
|
50908
|
+
this._healthCheck = () => __awaiter$$(this, void 0, void 0, function* () {
|
|
50909
|
+
if (this._realWebSocket &&
|
|
50910
|
+
this._realWebSocket.readyState !== this._readyState) {
|
|
50911
|
+
this._readyState = this._realWebSocket.readyState;
|
|
50912
|
+
// 太惨了,断网的时候,ws不会直接closed,而是处于closing的状态
|
|
50913
|
+
if (this._readyState === exports.WebSocketState.CLOSING) {
|
|
50914
|
+
this.emit('closing');
|
|
50915
|
+
}
|
|
50916
|
+
}
|
|
50917
|
+
yield new Promise((resolve) => setTimeout(resolve, 2000));
|
|
50918
|
+
this._heathCheckTimer = requestAnimationFrame(this._healthCheck);
|
|
50919
|
+
});
|
|
50920
|
+
/**
|
|
50921
|
+
* 清理健康检查
|
|
50922
|
+
*/
|
|
50923
|
+
this._clearHeathCheckIfNeed = () => {
|
|
50924
|
+
if (this._heathCheckTimer) {
|
|
50925
|
+
cancelAnimationFrame(this._heathCheckTimer);
|
|
50926
|
+
this._heathCheckTimer = undefined;
|
|
50927
|
+
}
|
|
50928
|
+
};
|
|
50929
|
+
/**
|
|
50930
|
+
* 开启健康检查
|
|
50931
|
+
*/
|
|
50932
|
+
this._startHealthCheck = () => {
|
|
50933
|
+
this._clearHeathCheckIfNeed();
|
|
50934
|
+
this._heathCheckTimer = requestAnimationFrame(this._healthCheck);
|
|
50935
|
+
};
|
|
50936
|
+
/**
|
|
50937
|
+
* 停止健康检查
|
|
50938
|
+
*/
|
|
50939
|
+
this._stopHealthCheck = () => {
|
|
50940
|
+
this._clearHeathCheckIfNeed();
|
|
50941
|
+
};
|
|
50873
50942
|
/**
|
|
50874
50943
|
* 清理连接中的请求
|
|
50875
50944
|
*/
|
|
@@ -50895,7 +50964,7 @@
|
|
|
50895
50964
|
this._offline = () => {
|
|
50896
50965
|
var _a;
|
|
50897
50966
|
this._reconnectWhenOnlineAgain = true;
|
|
50898
|
-
(_a = this._realWebSocket) === null || _a === void 0 ? void 0 : _a.close(1000);
|
|
50967
|
+
(_a = this._realWebSocket) === null || _a === void 0 ? void 0 : _a.close(1000, 'offline');
|
|
50899
50968
|
};
|
|
50900
50969
|
/**
|
|
50901
50970
|
* 解除网络监听事件
|
|
@@ -50922,7 +50991,12 @@
|
|
|
50922
50991
|
* @param data
|
|
50923
50992
|
* @returns
|
|
50924
50993
|
*/
|
|
50925
|
-
this.send = (data) => {
|
|
50994
|
+
this.send = (data) => {
|
|
50995
|
+
var _a, _b, _c;
|
|
50996
|
+
if (((_a = this._realWebSocket) === null || _a === void 0 ? void 0 : _a.readyState) === ((_b = this._realWebSocket) === null || _b === void 0 ? void 0 : _b.OPEN)) {
|
|
50997
|
+
(_c = this._realWebSocket) === null || _c === void 0 ? void 0 : _c.send(data);
|
|
50998
|
+
}
|
|
50999
|
+
};
|
|
50926
51000
|
/**
|
|
50927
51001
|
* 关闭连接
|
|
50928
51002
|
* @param code 代码
|
|
@@ -50966,6 +51040,7 @@
|
|
|
50966
51040
|
if (!newUrl)
|
|
50967
51041
|
return;
|
|
50968
51042
|
this._pendingReconnect = undefined;
|
|
51043
|
+
this._removeWebSocketEvent();
|
|
50969
51044
|
this._realWebSocket = new WebSocket(newUrl, this._protocols || undefined);
|
|
50970
51045
|
this._attempts = this._attempts + 1;
|
|
50971
51046
|
this.emit('connecting', new CustomEvent('connecting', {
|
|
@@ -50987,6 +51062,16 @@
|
|
|
50987
51062
|
this._attachConnectivityEvents();
|
|
50988
51063
|
}
|
|
50989
51064
|
};
|
|
51065
|
+
/**
|
|
51066
|
+
* 断开ws事件
|
|
51067
|
+
*/
|
|
51068
|
+
this._removeWebSocketEvent = () => {
|
|
51069
|
+
var _a, _b, _c, _d;
|
|
51070
|
+
(_a = this._realWebSocket) === null || _a === void 0 ? void 0 : _a.removeEventListener('open', this._webSocketOpenHandler);
|
|
51071
|
+
(_b = this._realWebSocket) === null || _b === void 0 ? void 0 : _b.removeEventListener('close', this._webSocketCloseHandler);
|
|
51072
|
+
(_c = this._realWebSocket) === null || _c === void 0 ? void 0 : _c.removeEventListener('error', this._webSocketErrorHandler);
|
|
51073
|
+
(_d = this._realWebSocket) === null || _d === void 0 ? void 0 : _d.removeEventListener('message', this._webSocketMessageHandler);
|
|
51074
|
+
};
|
|
50990
51075
|
/**
|
|
50991
51076
|
* 分发ws事件
|
|
50992
51077
|
*/
|
|
@@ -51010,6 +51095,7 @@
|
|
|
51010
51095
|
const attempts = this._attempts;
|
|
51011
51096
|
this._attempts = 0;
|
|
51012
51097
|
this._reconnectWhenOnlineAgain = false;
|
|
51098
|
+
this._startHealthCheck();
|
|
51013
51099
|
return this.emit('open', Object.assign(event, { detail: { reconnects, attempts } }));
|
|
51014
51100
|
};
|
|
51015
51101
|
/**
|
|
@@ -51019,6 +51105,7 @@
|
|
|
51019
51105
|
*/
|
|
51020
51106
|
this._webSocketCloseHandler = (event) => {
|
|
51021
51107
|
this._reconnect(event);
|
|
51108
|
+
this._stopHealthCheck();
|
|
51022
51109
|
return this.emit('close', event);
|
|
51023
51110
|
};
|
|
51024
51111
|
/**
|
|
@@ -51040,6 +51127,7 @@
|
|
|
51040
51127
|
if (options) {
|
|
51041
51128
|
this.setOptions(options);
|
|
51042
51129
|
}
|
|
51130
|
+
this._startHealthCheck();
|
|
51043
51131
|
}
|
|
51044
51132
|
get attempts() {
|
|
51045
51133
|
return this._attempts;
|
|
@@ -51090,16 +51178,20 @@
|
|
|
51090
51178
|
/**
|
|
51091
51179
|
* ws代理器
|
|
51092
51180
|
*/
|
|
51093
|
-
this._ws = new RobustWebSocket(
|
|
51181
|
+
this._ws = new RobustWebSocket({
|
|
51182
|
+
url: '',
|
|
51183
|
+
robustOptions: { timeout: 180000 },
|
|
51184
|
+
});
|
|
51094
51185
|
/**
|
|
51095
51186
|
* 带看连接状态
|
|
51096
51187
|
*/
|
|
51097
|
-
this._state = LiveState.NOTINITIALIZED;
|
|
51188
|
+
this._state = exports.LiveState.NOTINITIALIZED;
|
|
51098
51189
|
/**
|
|
51099
51190
|
* 添加事件监听
|
|
51100
51191
|
*/
|
|
51101
51192
|
this._addWebSocketEventListeners = () => {
|
|
51102
51193
|
this._ws.on('close', this._handleCloseEvent);
|
|
51194
|
+
this._ws.on('closing', this._handleClosingEvent);
|
|
51103
51195
|
this._ws.on('connecting', this._handleConnectingEvent);
|
|
51104
51196
|
this._ws.on('error', this._handleErrorEvent);
|
|
51105
51197
|
this._ws.on('message', this._handleMessageEvent);
|
|
@@ -51111,6 +51203,7 @@
|
|
|
51111
51203
|
*/
|
|
51112
51204
|
this._removeWebSocketEventListeners = () => {
|
|
51113
51205
|
this._ws.off('close', this._handleCloseEvent);
|
|
51206
|
+
this._ws.off('closing', this._handleClosingEvent);
|
|
51114
51207
|
this._ws.off('connecting', this._handleConnectingEvent);
|
|
51115
51208
|
this._ws.off('error', this._handleErrorEvent);
|
|
51116
51209
|
this._ws.off('message', this._handleMessageEvent);
|
|
@@ -51123,15 +51216,23 @@
|
|
|
51123
51216
|
*/
|
|
51124
51217
|
this._handleCloseEvent = (event) => {
|
|
51125
51218
|
logger$1.info(`live room closed bacause of ${event.code}-${event.reason || parseWSClsErr(event.code)}`);
|
|
51126
|
-
this.state = LiveState.CLOSED;
|
|
51219
|
+
this.state = exports.LiveState.CLOSED;
|
|
51220
|
+
};
|
|
51221
|
+
/**
|
|
51222
|
+
* 处理房间正在关闭事件(这个时候可能是断网了)
|
|
51223
|
+
*/
|
|
51224
|
+
this._handleClosingEvent = () => {
|
|
51225
|
+
var _a;
|
|
51226
|
+
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);
|
|
51227
|
+
this.state = exports.LiveState.CLOSED;
|
|
51127
51228
|
};
|
|
51128
51229
|
/**
|
|
51129
51230
|
* 连接中
|
|
51130
51231
|
* @param event
|
|
51131
51232
|
*/
|
|
51132
|
-
this._handleConnectingEvent = (
|
|
51133
|
-
logger$1.info(`live room is connecting
|
|
51134
|
-
this.state = LiveState.CONNECTING;
|
|
51233
|
+
this._handleConnectingEvent = () => {
|
|
51234
|
+
logger$1.info(`live room is connecting`);
|
|
51235
|
+
this.state = exports.LiveState.CONNECTING;
|
|
51135
51236
|
};
|
|
51136
51237
|
/**
|
|
51137
51238
|
* 连接发送异常
|
|
@@ -51139,7 +51240,7 @@
|
|
|
51139
51240
|
*/
|
|
51140
51241
|
this._handleErrorEvent = (event) => {
|
|
51141
51242
|
logger$1.error(`live room error`, event);
|
|
51142
|
-
this.state = LiveState.CLOSED;
|
|
51243
|
+
this.state = exports.LiveState.CLOSED;
|
|
51143
51244
|
};
|
|
51144
51245
|
/**
|
|
51145
51246
|
* 接收到消息
|
|
@@ -51163,7 +51264,10 @@
|
|
|
51163
51264
|
*/
|
|
51164
51265
|
this._handleOpenEvent = (event) => {
|
|
51165
51266
|
logger$1.info('live room open', event.detail);
|
|
51166
|
-
this.state = LiveState.OPEN;
|
|
51267
|
+
this.state = exports.LiveState.OPEN;
|
|
51268
|
+
if (event.detail.reconnects > 0) {
|
|
51269
|
+
this.emit('reconnected', event.detail);
|
|
51270
|
+
}
|
|
51167
51271
|
};
|
|
51168
51272
|
/**
|
|
51169
51273
|
* 处理超时
|
|
@@ -51171,7 +51275,7 @@
|
|
|
51171
51275
|
*/
|
|
51172
51276
|
this._handleTimeoutEvent = (event) => {
|
|
51173
51277
|
logger$1.error('live room connect timeout!', event.detail);
|
|
51174
|
-
this.state = LiveState.CLOSED;
|
|
51278
|
+
this.state = exports.LiveState.CLOSED;
|
|
51175
51279
|
};
|
|
51176
51280
|
/**
|
|
51177
51281
|
* 释放资源,释放之后需要重新实例化
|
|
@@ -51214,7 +51318,7 @@
|
|
|
51214
51318
|
if (data === undefined || data === null || data === '') {
|
|
51215
51319
|
throw new Error('live message is empty!');
|
|
51216
51320
|
}
|
|
51217
|
-
if (this.state === LiveState.OPEN) {
|
|
51321
|
+
if (this.state === exports.LiveState.OPEN) {
|
|
51218
51322
|
return this._ws.send(JSON.stringify(data));
|
|
51219
51323
|
}
|
|
51220
51324
|
else {
|
|
@@ -51267,7 +51371,7 @@
|
|
|
51267
51371
|
* @returns
|
|
51268
51372
|
*/
|
|
51269
51373
|
this.sendKeyframe = (key, frame) => {
|
|
51270
|
-
if (this.state !== LiveState.OPEN)
|
|
51374
|
+
if (this.state !== exports.LiveState.OPEN)
|
|
51271
51375
|
return false;
|
|
51272
51376
|
this._buildInData.keyframes = Object.assign(Object.assign({}, this._buildInData.keyframes), { [key]: frame });
|
|
51273
51377
|
const liveMsg = createLiveMsg(exports.Command.KeyframeSync, this.snapshot);
|
|
@@ -51304,6 +51408,10 @@
|
|
|
51304
51408
|
* @returns
|
|
51305
51409
|
*/
|
|
51306
51410
|
this._handleStateChange = (state, prevState) => this.emit('stateChange', state, prevState);
|
|
51411
|
+
/**
|
|
51412
|
+
* 消息接收
|
|
51413
|
+
* @param liveMsg
|
|
51414
|
+
*/
|
|
51307
51415
|
this._handleMessage = (liveMsg) => __awaiter$$(this, void 0, void 0, function* () {
|
|
51308
51416
|
var _b, _c, _d, _e, _f, _g;
|
|
51309
51417
|
if (typeof liveMsg === 'object') {
|
|
@@ -51335,6 +51443,7 @@
|
|
|
51335
51443
|
*/
|
|
51336
51444
|
case exports.Command.RTCInfo: {
|
|
51337
51445
|
const { voice_id: voiceId, type } = data;
|
|
51446
|
+
this._buildInData.rtcInfo = { voiceId, type };
|
|
51338
51447
|
if (!((_b = this.$RTC) === null || _b === void 0 ? void 0 : _b.joined)) {
|
|
51339
51448
|
const result = yield ((_c = this.$RTC) === null || _c === void 0 ? void 0 : _c.join({
|
|
51340
51449
|
voiceId,
|
|
@@ -51475,10 +51584,17 @@
|
|
|
51475
51584
|
return false;
|
|
51476
51585
|
}
|
|
51477
51586
|
const { force = false } = options;
|
|
51587
|
+
// 检测一下麦克风权限,hack
|
|
51588
|
+
if (this._options.rtc && this._options.jsBridge) {
|
|
51589
|
+
const res = yield this._options.jsBridge.detectMicro();
|
|
51590
|
+
if (!res) {
|
|
51591
|
+
return new Error('Failed to obtain microphone authorization');
|
|
51592
|
+
}
|
|
51593
|
+
}
|
|
51478
51594
|
// 检查是否已有实例在使用
|
|
51479
51595
|
const currentState = this.state;
|
|
51480
|
-
if (currentState === LiveState.CONNECTING ||
|
|
51481
|
-
currentState === LiveState.OPEN) {
|
|
51596
|
+
if (currentState === exports.LiveState.CONNECTING ||
|
|
51597
|
+
currentState === exports.LiveState.OPEN) {
|
|
51482
51598
|
if (force) {
|
|
51483
51599
|
try {
|
|
51484
51600
|
yield this._controller.close('force close by connect');
|
|
@@ -51764,7 +51880,7 @@
|
|
|
51764
51880
|
*/
|
|
51765
51881
|
updateStatus(evtType, atnType, status, toUserIds) {
|
|
51766
51882
|
return __awaiter$$(this, void 0, void 0, function* () {
|
|
51767
|
-
if (this.state !== LiveState.OPEN)
|
|
51883
|
+
if (this.state !== exports.LiveState.OPEN)
|
|
51768
51884
|
return false;
|
|
51769
51885
|
const data = Object.assign({ event_type: evtType, action: atnType }, { data: status });
|
|
51770
51886
|
const liveMsg = createLiveMsg(exports.Command.BuiltinMsg, data, toUserIds);
|
|
@@ -51786,7 +51902,7 @@
|
|
|
51786
51902
|
* @returns
|
|
51787
51903
|
*/
|
|
51788
51904
|
broadcast(request, toUserIds, timeout) {
|
|
51789
|
-
if (this.state !== LiveState.OPEN)
|
|
51905
|
+
if (this.state !== exports.LiveState.OPEN)
|
|
51790
51906
|
return false;
|
|
51791
51907
|
return new Promise((resolve, reject) => {
|
|
51792
51908
|
const customEvent = createLiveMsg(exports.Command.CustomEvent, request, toUserIds);
|
|
@@ -54276,21 +54392,21 @@
|
|
|
54276
54392
|
* @deprecated
|
|
54277
54393
|
* @returns
|
|
54278
54394
|
*/
|
|
54279
|
-
const unsafe__useLiveInstance =
|
|
54395
|
+
const unsafe__useLiveInstance = () => useLiveInstance();
|
|
54280
54396
|
/**
|
|
54281
54397
|
* 使用rtc实例
|
|
54282
54398
|
*/
|
|
54283
|
-
const useRTCInstance =
|
|
54399
|
+
const useRTCInstance = () => useLiveInstance().$RTC;
|
|
54284
54400
|
/**
|
|
54285
54401
|
* 不建议这样使用
|
|
54286
54402
|
* @deprecated
|
|
54287
54403
|
* @returns
|
|
54288
54404
|
*/
|
|
54289
|
-
const unsafe__useRTCInstance =
|
|
54405
|
+
const unsafe__useRTCInstance = () => useRTCInstance();
|
|
54290
54406
|
/**
|
|
54291
54407
|
* 带看连接操作
|
|
54292
54408
|
*/
|
|
54293
|
-
const useConnect =
|
|
54409
|
+
const useConnect = () => (options) => __awaiter$$(this, void 0, void 0, function* () { return yield useLiveInstance().connect(options); });
|
|
54294
54410
|
/**
|
|
54295
54411
|
*
|
|
54296
54412
|
* @param name
|
|
@@ -54314,17 +54430,17 @@
|
|
|
54314
54430
|
*/
|
|
54315
54431
|
function useLiveAction() {
|
|
54316
54432
|
const live = useLiveInstance();
|
|
54317
|
-
const connect =
|
|
54318
|
-
const toggleMicro =
|
|
54319
|
-
const broadcast =
|
|
54320
|
-
const exit =
|
|
54321
|
-
const kick =
|
|
54322
|
-
const forbidMicro =
|
|
54323
|
-
const forbidSync =
|
|
54324
|
-
const getFramesByKey =
|
|
54325
|
-
const sendKeyframe =
|
|
54326
|
-
const setSelfInfo =
|
|
54327
|
-
const updateStatus =
|
|
54433
|
+
const connect = (options) => __awaiter$$(this, void 0, void 0, function* () { return yield live.connect(options); });
|
|
54434
|
+
const toggleMicro = (microStatus) => live.toggleMicro(microStatus);
|
|
54435
|
+
const broadcast = (data, toUserIds, timeout = 0) => __awaiter$$(this, void 0, void 0, function* () { return yield live.broadcast(data, toUserIds, timeout); });
|
|
54436
|
+
const exit = () => __awaiter$$(this, void 0, void 0, function* () { return yield live.exit(); });
|
|
54437
|
+
const kick = (toUserIds) => __awaiter$$(this, void 0, void 0, function* () { return yield live.kick(toUserIds); });
|
|
54438
|
+
const forbidMicro = (micro, toUserIds = []) => __awaiter$$(this, void 0, void 0, function* () { return yield live.forbidMicro(micro, toUserIds); });
|
|
54439
|
+
const forbidSync = (sync, toUserIds = []) => live.forbidSync(sync, toUserIds);
|
|
54440
|
+
const getFramesByKey = (key) => live.getFramesByKey(key);
|
|
54441
|
+
const sendKeyframe = (key, frame) => live.sendKeyframe(key, frame);
|
|
54442
|
+
const setSelfInfo = (userInfo) => live.setSelfInfo(userInfo);
|
|
54443
|
+
const updateStatus = (evtType, atnType, status, toUserIds) => live.updateStatus(evtType, atnType, status, toUserIds);
|
|
54328
54444
|
return {
|
|
54329
54445
|
connect,
|
|
54330
54446
|
broadcast,
|
|
@@ -54378,11 +54494,11 @@
|
|
|
54378
54494
|
}
|
|
54379
54495
|
function useRTCAction() {
|
|
54380
54496
|
const live = useLiveInstance();
|
|
54381
|
-
const join =
|
|
54382
|
-
const quit =
|
|
54383
|
-
const shock =
|
|
54384
|
-
const toggleMicro =
|
|
54385
|
-
const detectMicro =
|
|
54497
|
+
const join = (options) => live.$RTC.join(options);
|
|
54498
|
+
const quit = () => live.$RTC.quit();
|
|
54499
|
+
const shock = () => { var _a, _b; return (_b = (_a = live.$RTC).shock) === null || _b === void 0 ? void 0 : _b.call(_a); };
|
|
54500
|
+
const toggleMicro = (flag) => live.$RTC.toggleMicro(flag);
|
|
54501
|
+
const detectMicro = () => live.$RTC.detectMicro();
|
|
54386
54502
|
return {
|
|
54387
54503
|
join,
|
|
54388
54504
|
quit,
|