@realsee/live 0.5.0-alpha.1 → 0.5.0-alpha.4
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/realsee-live.cjs.development.js +46 -30
- 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 +35 -19
- package/dist/realsee-live.esm.js.map +1 -1
- package/dist/realsee-live.umd.development.js +63 -31
- 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 +4 -0
- package/docs/assets/search.js +1 -1
- package/docs/enums/LiveState.html +7 -0
- package/docs/index.html +1 -1
- package/docs/modules.html +8 -8
- package/package.json +2 -2
|
@@ -48689,6 +48689,23 @@
|
|
|
48689
48689
|
}
|
|
48690
48690
|
}
|
|
48691
48691
|
|
|
48692
|
+
exports.LiveState = void 0;
|
|
48693
|
+
(function (LiveState) {
|
|
48694
|
+
LiveState[LiveState["NOTINITIALIZED"] = -1] = "NOTINITIALIZED";
|
|
48695
|
+
/**
|
|
48696
|
+
* 正在链接中
|
|
48697
|
+
*/
|
|
48698
|
+
LiveState[LiveState["CONNECTING"] = 0] = "CONNECTING";
|
|
48699
|
+
/**
|
|
48700
|
+
* 已经链接并且可以通讯
|
|
48701
|
+
*/
|
|
48702
|
+
LiveState[LiveState["OPEN"] = 1] = "OPEN";
|
|
48703
|
+
/**
|
|
48704
|
+
* 连接已关闭或者链接失败
|
|
48705
|
+
*/
|
|
48706
|
+
LiveState[LiveState["CLOSED"] = 3] = "CLOSED";
|
|
48707
|
+
})(exports.LiveState || (exports.LiveState = {}));
|
|
48708
|
+
|
|
48692
48709
|
/**
|
|
48693
48710
|
* 用户当前状态枚举。
|
|
48694
48711
|
*/
|
|
@@ -49435,7 +49452,12 @@
|
|
|
49435
49452
|
* @param data
|
|
49436
49453
|
* @returns
|
|
49437
49454
|
*/
|
|
49438
|
-
this.send = (data) => {
|
|
49455
|
+
this.send = (data) => {
|
|
49456
|
+
var _a, _b, _c;
|
|
49457
|
+
if (((_a = this._realWebSocket) === null || _a === void 0 ? void 0 : _a.readyState) === ((_b = this._realWebSocket) === null || _b === void 0 ? void 0 : _b.OPEN)) {
|
|
49458
|
+
(_c = this._realWebSocket) === null || _c === void 0 ? void 0 : _c.send(data);
|
|
49459
|
+
}
|
|
49460
|
+
};
|
|
49439
49461
|
/**
|
|
49440
49462
|
* 关闭连接
|
|
49441
49463
|
* @param code 代码
|
|
@@ -49479,6 +49501,7 @@
|
|
|
49479
49501
|
if (!newUrl)
|
|
49480
49502
|
return;
|
|
49481
49503
|
this._pendingReconnect = undefined;
|
|
49504
|
+
this._removeWebSocketEvent();
|
|
49482
49505
|
this._realWebSocket = new WebSocket(newUrl, this._protocols || undefined);
|
|
49483
49506
|
this._attempts = this._attempts + 1;
|
|
49484
49507
|
this.emit('connecting', new CustomEvent('connecting', {
|
|
@@ -49500,6 +49523,16 @@
|
|
|
49500
49523
|
this._attachConnectivityEvents();
|
|
49501
49524
|
}
|
|
49502
49525
|
};
|
|
49526
|
+
/**
|
|
49527
|
+
* 断开ws事件
|
|
49528
|
+
*/
|
|
49529
|
+
this._removeWebSocketEvent = () => {
|
|
49530
|
+
var _a, _b, _c, _d;
|
|
49531
|
+
(_a = this._realWebSocket) === null || _a === void 0 ? void 0 : _a.removeEventListener('open', this._webSocketOpenHandler);
|
|
49532
|
+
(_b = this._realWebSocket) === null || _b === void 0 ? void 0 : _b.removeEventListener('close', this._webSocketCloseHandler);
|
|
49533
|
+
(_c = this._realWebSocket) === null || _c === void 0 ? void 0 : _c.removeEventListener('error', this._webSocketErrorHandler);
|
|
49534
|
+
(_d = this._realWebSocket) === null || _d === void 0 ? void 0 : _d.removeEventListener('message', this._webSocketMessageHandler);
|
|
49535
|
+
};
|
|
49503
49536
|
/**
|
|
49504
49537
|
* 分发ws事件
|
|
49505
49538
|
*/
|
|
@@ -50636,23 +50669,6 @@
|
|
|
50636
50669
|
}
|
|
50637
50670
|
}
|
|
50638
50671
|
|
|
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
50672
|
function appendUri(uri, query) {
|
|
50657
50673
|
const hasQuery = uri.indexOf('?') !== -1;
|
|
50658
50674
|
const newQuery = Object.keys(query).reduce((accu, curr, idx) => `${accu}${(idx === 0 && !hasQuery) ? '?' : '&'}${curr}=${query[curr]}`, '');
|
|
@@ -50922,7 +50938,12 @@
|
|
|
50922
50938
|
* @param data
|
|
50923
50939
|
* @returns
|
|
50924
50940
|
*/
|
|
50925
|
-
this.send = (data) => {
|
|
50941
|
+
this.send = (data) => {
|
|
50942
|
+
var _a, _b, _c;
|
|
50943
|
+
if (((_a = this._realWebSocket) === null || _a === void 0 ? void 0 : _a.readyState) === ((_b = this._realWebSocket) === null || _b === void 0 ? void 0 : _b.OPEN)) {
|
|
50944
|
+
(_c = this._realWebSocket) === null || _c === void 0 ? void 0 : _c.send(data);
|
|
50945
|
+
}
|
|
50946
|
+
};
|
|
50926
50947
|
/**
|
|
50927
50948
|
* 关闭连接
|
|
50928
50949
|
* @param code 代码
|
|
@@ -50966,6 +50987,7 @@
|
|
|
50966
50987
|
if (!newUrl)
|
|
50967
50988
|
return;
|
|
50968
50989
|
this._pendingReconnect = undefined;
|
|
50990
|
+
this._removeWebSocketEvent();
|
|
50969
50991
|
this._realWebSocket = new WebSocket(newUrl, this._protocols || undefined);
|
|
50970
50992
|
this._attempts = this._attempts + 1;
|
|
50971
50993
|
this.emit('connecting', new CustomEvent('connecting', {
|
|
@@ -50987,6 +51009,16 @@
|
|
|
50987
51009
|
this._attachConnectivityEvents();
|
|
50988
51010
|
}
|
|
50989
51011
|
};
|
|
51012
|
+
/**
|
|
51013
|
+
* 断开ws事件
|
|
51014
|
+
*/
|
|
51015
|
+
this._removeWebSocketEvent = () => {
|
|
51016
|
+
var _a, _b, _c, _d;
|
|
51017
|
+
(_a = this._realWebSocket) === null || _a === void 0 ? void 0 : _a.removeEventListener('open', this._webSocketOpenHandler);
|
|
51018
|
+
(_b = this._realWebSocket) === null || _b === void 0 ? void 0 : _b.removeEventListener('close', this._webSocketCloseHandler);
|
|
51019
|
+
(_c = this._realWebSocket) === null || _c === void 0 ? void 0 : _c.removeEventListener('error', this._webSocketErrorHandler);
|
|
51020
|
+
(_d = this._realWebSocket) === null || _d === void 0 ? void 0 : _d.removeEventListener('message', this._webSocketMessageHandler);
|
|
51021
|
+
};
|
|
50990
51022
|
/**
|
|
50991
51023
|
* 分发ws事件
|
|
50992
51024
|
*/
|
|
@@ -51094,7 +51126,7 @@
|
|
|
51094
51126
|
/**
|
|
51095
51127
|
* 带看连接状态
|
|
51096
51128
|
*/
|
|
51097
|
-
this._state = LiveState.NOTINITIALIZED;
|
|
51129
|
+
this._state = exports.LiveState.NOTINITIALIZED;
|
|
51098
51130
|
/**
|
|
51099
51131
|
* 添加事件监听
|
|
51100
51132
|
*/
|
|
@@ -51123,7 +51155,7 @@
|
|
|
51123
51155
|
*/
|
|
51124
51156
|
this._handleCloseEvent = (event) => {
|
|
51125
51157
|
logger$1.info(`live room closed bacause of ${event.code}-${event.reason || parseWSClsErr(event.code)}`);
|
|
51126
|
-
this.state = LiveState.CLOSED;
|
|
51158
|
+
this.state = exports.LiveState.CLOSED;
|
|
51127
51159
|
};
|
|
51128
51160
|
/**
|
|
51129
51161
|
* 连接中
|
|
@@ -51131,7 +51163,7 @@
|
|
|
51131
51163
|
*/
|
|
51132
51164
|
this._handleConnectingEvent = (event) => {
|
|
51133
51165
|
logger$1.info(`live room is connecting`, event.detail);
|
|
51134
|
-
this.state = LiveState.CONNECTING;
|
|
51166
|
+
this.state = exports.LiveState.CONNECTING;
|
|
51135
51167
|
};
|
|
51136
51168
|
/**
|
|
51137
51169
|
* 连接发送异常
|
|
@@ -51139,7 +51171,7 @@
|
|
|
51139
51171
|
*/
|
|
51140
51172
|
this._handleErrorEvent = (event) => {
|
|
51141
51173
|
logger$1.error(`live room error`, event);
|
|
51142
|
-
this.state = LiveState.CLOSED;
|
|
51174
|
+
this.state = exports.LiveState.CLOSED;
|
|
51143
51175
|
};
|
|
51144
51176
|
/**
|
|
51145
51177
|
* 接收到消息
|
|
@@ -51163,7 +51195,7 @@
|
|
|
51163
51195
|
*/
|
|
51164
51196
|
this._handleOpenEvent = (event) => {
|
|
51165
51197
|
logger$1.info('live room open', event.detail);
|
|
51166
|
-
this.state = LiveState.OPEN;
|
|
51198
|
+
this.state = exports.LiveState.OPEN;
|
|
51167
51199
|
};
|
|
51168
51200
|
/**
|
|
51169
51201
|
* 处理超时
|
|
@@ -51171,7 +51203,7 @@
|
|
|
51171
51203
|
*/
|
|
51172
51204
|
this._handleTimeoutEvent = (event) => {
|
|
51173
51205
|
logger$1.error('live room connect timeout!', event.detail);
|
|
51174
|
-
this.state = LiveState.CLOSED;
|
|
51206
|
+
this.state = exports.LiveState.CLOSED;
|
|
51175
51207
|
};
|
|
51176
51208
|
/**
|
|
51177
51209
|
* 释放资源,释放之后需要重新实例化
|
|
@@ -51214,7 +51246,7 @@
|
|
|
51214
51246
|
if (data === undefined || data === null || data === '') {
|
|
51215
51247
|
throw new Error('live message is empty!');
|
|
51216
51248
|
}
|
|
51217
|
-
if (this.state === LiveState.OPEN) {
|
|
51249
|
+
if (this.state === exports.LiveState.OPEN) {
|
|
51218
51250
|
return this._ws.send(JSON.stringify(data));
|
|
51219
51251
|
}
|
|
51220
51252
|
else {
|
|
@@ -51267,7 +51299,7 @@
|
|
|
51267
51299
|
* @returns
|
|
51268
51300
|
*/
|
|
51269
51301
|
this.sendKeyframe = (key, frame) => {
|
|
51270
|
-
if (this.state !== LiveState.OPEN)
|
|
51302
|
+
if (this.state !== exports.LiveState.OPEN)
|
|
51271
51303
|
return false;
|
|
51272
51304
|
this._buildInData.keyframes = Object.assign(Object.assign({}, this._buildInData.keyframes), { [key]: frame });
|
|
51273
51305
|
const liveMsg = createLiveMsg(exports.Command.KeyframeSync, this.snapshot);
|
|
@@ -51477,8 +51509,8 @@
|
|
|
51477
51509
|
const { force = false } = options;
|
|
51478
51510
|
// 检查是否已有实例在使用
|
|
51479
51511
|
const currentState = this.state;
|
|
51480
|
-
if (currentState === LiveState.CONNECTING ||
|
|
51481
|
-
currentState === LiveState.OPEN) {
|
|
51512
|
+
if (currentState === exports.LiveState.CONNECTING ||
|
|
51513
|
+
currentState === exports.LiveState.OPEN) {
|
|
51482
51514
|
if (force) {
|
|
51483
51515
|
try {
|
|
51484
51516
|
yield this._controller.close('force close by connect');
|
|
@@ -51764,7 +51796,7 @@
|
|
|
51764
51796
|
*/
|
|
51765
51797
|
updateStatus(evtType, atnType, status, toUserIds) {
|
|
51766
51798
|
return __awaiter$$(this, void 0, void 0, function* () {
|
|
51767
|
-
if (this.state !== LiveState.OPEN)
|
|
51799
|
+
if (this.state !== exports.LiveState.OPEN)
|
|
51768
51800
|
return false;
|
|
51769
51801
|
const data = Object.assign({ event_type: evtType, action: atnType }, { data: status });
|
|
51770
51802
|
const liveMsg = createLiveMsg(exports.Command.BuiltinMsg, data, toUserIds);
|
|
@@ -51786,7 +51818,7 @@
|
|
|
51786
51818
|
* @returns
|
|
51787
51819
|
*/
|
|
51788
51820
|
broadcast(request, toUserIds, timeout) {
|
|
51789
|
-
if (this.state !== LiveState.OPEN)
|
|
51821
|
+
if (this.state !== exports.LiveState.OPEN)
|
|
51790
51822
|
return false;
|
|
51791
51823
|
return new Promise((resolve, reject) => {
|
|
51792
51824
|
const customEvent = createLiveMsg(exports.Command.CustomEvent, request, toUserIds);
|