@realsee/live 0.5.0-alpha.1 → 0.5.0-alpha.2

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.
@@ -795,6 +795,23 @@ function parseLiveMsg(jsonTxt) {
795
795
  }
796
796
  }
797
797
 
798
+ exports.LiveState = void 0;
799
+ (function (LiveState) {
800
+ LiveState[LiveState["NOTINITIALIZED"] = -1] = "NOTINITIALIZED";
801
+ /**
802
+ * 正在链接中
803
+ */
804
+ LiveState[LiveState["CONNECTING"] = 0] = "CONNECTING";
805
+ /**
806
+ * 已经链接并且可以通讯
807
+ */
808
+ LiveState[LiveState["OPEN"] = 1] = "OPEN";
809
+ /**
810
+ * 连接已关闭或者链接失败
811
+ */
812
+ LiveState[LiveState["CLOSED"] = 3] = "CLOSED";
813
+ })(exports.LiveState || (exports.LiveState = {}));
814
+
798
815
  /**
799
816
  * 用户当前状态枚举。
800
817
  */
@@ -952,23 +969,6 @@ exports.default = LogLevel;
952
969
 
953
970
  var LogLevel = /*@__PURE__*/getDefaultExportFromCjs(LogLevel_1);
954
971
 
955
- var LiveState;
956
- (function (LiveState) {
957
- LiveState[LiveState["NOTINITIALIZED"] = -1] = "NOTINITIALIZED";
958
- /**
959
- * 正在链接中
960
- */
961
- LiveState[LiveState["CONNECTING"] = 0] = "CONNECTING";
962
- /**
963
- * 已经链接并且可以通讯
964
- */
965
- LiveState[LiveState["OPEN"] = 1] = "OPEN";
966
- /**
967
- * 连接已关闭或者链接失败
968
- */
969
- LiveState[LiveState["CLOSED"] = 3] = "CLOSED";
970
- })(LiveState || (LiveState = {}));
971
-
972
972
  function appendUri(uri, query) {
973
973
  const hasQuery = uri.indexOf('?') !== -1;
974
974
  const newQuery = Object.keys(query).reduce((accu, curr, idx) => `${accu}${(idx === 0 && !hasQuery) ? '?' : '&'}${curr}=${query[curr]}`, '');
@@ -1410,7 +1410,7 @@ class LiveController extends Subscribe {
1410
1410
  /**
1411
1411
  * 带看连接状态
1412
1412
  */
1413
- this._state = LiveState.NOTINITIALIZED;
1413
+ this._state = exports.LiveState.NOTINITIALIZED;
1414
1414
  /**
1415
1415
  * 添加事件监听
1416
1416
  */
@@ -1439,7 +1439,7 @@ class LiveController extends Subscribe {
1439
1439
  */
1440
1440
  this._handleCloseEvent = (event) => {
1441
1441
  logger$1.info(`live room closed bacause of ${event.code}-${event.reason || parseWSClsErr(event.code)}`);
1442
- this.state = LiveState.CLOSED;
1442
+ this.state = exports.LiveState.CLOSED;
1443
1443
  };
1444
1444
  /**
1445
1445
  * 连接中
@@ -1447,7 +1447,7 @@ class LiveController extends Subscribe {
1447
1447
  */
1448
1448
  this._handleConnectingEvent = (event) => {
1449
1449
  logger$1.info(`live room is connecting`, event.detail);
1450
- this.state = LiveState.CONNECTING;
1450
+ this.state = exports.LiveState.CONNECTING;
1451
1451
  };
1452
1452
  /**
1453
1453
  * 连接发送异常
@@ -1455,7 +1455,7 @@ class LiveController extends Subscribe {
1455
1455
  */
1456
1456
  this._handleErrorEvent = (event) => {
1457
1457
  logger$1.error(`live room error`, event);
1458
- this.state = LiveState.CLOSED;
1458
+ this.state = exports.LiveState.CLOSED;
1459
1459
  };
1460
1460
  /**
1461
1461
  * 接收到消息
@@ -1479,7 +1479,7 @@ class LiveController extends Subscribe {
1479
1479
  */
1480
1480
  this._handleOpenEvent = (event) => {
1481
1481
  logger$1.info('live room open', event.detail);
1482
- this.state = LiveState.OPEN;
1482
+ this.state = exports.LiveState.OPEN;
1483
1483
  };
1484
1484
  /**
1485
1485
  * 处理超时
@@ -1487,7 +1487,7 @@ class LiveController extends Subscribe {
1487
1487
  */
1488
1488
  this._handleTimeoutEvent = (event) => {
1489
1489
  logger$1.error('live room connect timeout!', event.detail);
1490
- this.state = LiveState.CLOSED;
1490
+ this.state = exports.LiveState.CLOSED;
1491
1491
  };
1492
1492
  /**
1493
1493
  * 释放资源,释放之后需要重新实例化
@@ -1530,7 +1530,7 @@ class LiveController extends Subscribe {
1530
1530
  if (data === undefined || data === null || data === '') {
1531
1531
  throw new Error('live message is empty!');
1532
1532
  }
1533
- if (this.state === LiveState.OPEN) {
1533
+ if (this.state === exports.LiveState.OPEN) {
1534
1534
  return this._ws.send(JSON.stringify(data));
1535
1535
  }
1536
1536
  else {
@@ -1583,7 +1583,7 @@ class Live extends Subscribe {
1583
1583
  * @returns
1584
1584
  */
1585
1585
  this.sendKeyframe = (key, frame) => {
1586
- if (this.state !== LiveState.OPEN)
1586
+ if (this.state !== exports.LiveState.OPEN)
1587
1587
  return false;
1588
1588
  this._buildInData.keyframes = Object.assign(Object.assign({}, this._buildInData.keyframes), { [key]: frame });
1589
1589
  const liveMsg = createLiveMsg(exports.Command.KeyframeSync, this.snapshot);
@@ -1793,8 +1793,8 @@ class Live extends Subscribe {
1793
1793
  const { force = false } = options;
1794
1794
  // 检查是否已有实例在使用
1795
1795
  const currentState = this.state;
1796
- if (currentState === LiveState.CONNECTING ||
1797
- currentState === LiveState.OPEN) {
1796
+ if (currentState === exports.LiveState.CONNECTING ||
1797
+ currentState === exports.LiveState.OPEN) {
1798
1798
  if (force) {
1799
1799
  try {
1800
1800
  yield this._controller.close('force close by connect');
@@ -2080,7 +2080,7 @@ class Live extends Subscribe {
2080
2080
  */
2081
2081
  updateStatus(evtType, atnType, status, toUserIds) {
2082
2082
  return __awaiter(this, void 0, void 0, function* () {
2083
- if (this.state !== LiveState.OPEN)
2083
+ if (this.state !== exports.LiveState.OPEN)
2084
2084
  return false;
2085
2085
  const data = Object.assign({ event_type: evtType, action: atnType }, { data: status });
2086
2086
  const liveMsg = createLiveMsg(exports.Command.BuiltinMsg, data, toUserIds);
@@ -2102,7 +2102,7 @@ class Live extends Subscribe {
2102
2102
  * @returns
2103
2103
  */
2104
2104
  broadcast(request, toUserIds, timeout) {
2105
- if (this.state !== LiveState.OPEN)
2105
+ if (this.state !== exports.LiveState.OPEN)
2106
2106
  return false;
2107
2107
  return new Promise((resolve, reject) => {
2108
2108
  const customEvent = createLiveMsg(exports.Command.CustomEvent, request, toUserIds);