@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.
@@ -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
  */
@@ -50636,23 +50653,6 @@
50636
50653
  }
50637
50654
  }
50638
50655
 
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
50656
  function appendUri(uri, query) {
50657
50657
  const hasQuery = uri.indexOf('?') !== -1;
50658
50658
  const newQuery = Object.keys(query).reduce((accu, curr, idx) => `${accu}${(idx === 0 && !hasQuery) ? '?' : '&'}${curr}=${query[curr]}`, '');
@@ -51094,7 +51094,7 @@
51094
51094
  /**
51095
51095
  * 带看连接状态
51096
51096
  */
51097
- this._state = LiveState.NOTINITIALIZED;
51097
+ this._state = exports.LiveState.NOTINITIALIZED;
51098
51098
  /**
51099
51099
  * 添加事件监听
51100
51100
  */
@@ -51123,7 +51123,7 @@
51123
51123
  */
51124
51124
  this._handleCloseEvent = (event) => {
51125
51125
  logger$1.info(`live room closed bacause of ${event.code}-${event.reason || parseWSClsErr(event.code)}`);
51126
- this.state = LiveState.CLOSED;
51126
+ this.state = exports.LiveState.CLOSED;
51127
51127
  };
51128
51128
  /**
51129
51129
  * 连接中
@@ -51131,7 +51131,7 @@
51131
51131
  */
51132
51132
  this._handleConnectingEvent = (event) => {
51133
51133
  logger$1.info(`live room is connecting`, event.detail);
51134
- this.state = LiveState.CONNECTING;
51134
+ this.state = exports.LiveState.CONNECTING;
51135
51135
  };
51136
51136
  /**
51137
51137
  * 连接发送异常
@@ -51139,7 +51139,7 @@
51139
51139
  */
51140
51140
  this._handleErrorEvent = (event) => {
51141
51141
  logger$1.error(`live room error`, event);
51142
- this.state = LiveState.CLOSED;
51142
+ this.state = exports.LiveState.CLOSED;
51143
51143
  };
51144
51144
  /**
51145
51145
  * 接收到消息
@@ -51163,7 +51163,7 @@
51163
51163
  */
51164
51164
  this._handleOpenEvent = (event) => {
51165
51165
  logger$1.info('live room open', event.detail);
51166
- this.state = LiveState.OPEN;
51166
+ this.state = exports.LiveState.OPEN;
51167
51167
  };
51168
51168
  /**
51169
51169
  * 处理超时
@@ -51171,7 +51171,7 @@
51171
51171
  */
51172
51172
  this._handleTimeoutEvent = (event) => {
51173
51173
  logger$1.error('live room connect timeout!', event.detail);
51174
- this.state = LiveState.CLOSED;
51174
+ this.state = exports.LiveState.CLOSED;
51175
51175
  };
51176
51176
  /**
51177
51177
  * 释放资源,释放之后需要重新实例化
@@ -51214,7 +51214,7 @@
51214
51214
  if (data === undefined || data === null || data === '') {
51215
51215
  throw new Error('live message is empty!');
51216
51216
  }
51217
- if (this.state === LiveState.OPEN) {
51217
+ if (this.state === exports.LiveState.OPEN) {
51218
51218
  return this._ws.send(JSON.stringify(data));
51219
51219
  }
51220
51220
  else {
@@ -51267,7 +51267,7 @@
51267
51267
  * @returns
51268
51268
  */
51269
51269
  this.sendKeyframe = (key, frame) => {
51270
- if (this.state !== LiveState.OPEN)
51270
+ if (this.state !== exports.LiveState.OPEN)
51271
51271
  return false;
51272
51272
  this._buildInData.keyframes = Object.assign(Object.assign({}, this._buildInData.keyframes), { [key]: frame });
51273
51273
  const liveMsg = createLiveMsg(exports.Command.KeyframeSync, this.snapshot);
@@ -51477,8 +51477,8 @@
51477
51477
  const { force = false } = options;
51478
51478
  // 检查是否已有实例在使用
51479
51479
  const currentState = this.state;
51480
- if (currentState === LiveState.CONNECTING ||
51481
- currentState === LiveState.OPEN) {
51480
+ if (currentState === exports.LiveState.CONNECTING ||
51481
+ currentState === exports.LiveState.OPEN) {
51482
51482
  if (force) {
51483
51483
  try {
51484
51484
  yield this._controller.close('force close by connect');
@@ -51764,7 +51764,7 @@
51764
51764
  */
51765
51765
  updateStatus(evtType, atnType, status, toUserIds) {
51766
51766
  return __awaiter$$(this, void 0, void 0, function* () {
51767
- if (this.state !== LiveState.OPEN)
51767
+ if (this.state !== exports.LiveState.OPEN)
51768
51768
  return false;
51769
51769
  const data = Object.assign({ event_type: evtType, action: atnType }, { data: status });
51770
51770
  const liveMsg = createLiveMsg(exports.Command.BuiltinMsg, data, toUserIds);
@@ -51786,7 +51786,7 @@
51786
51786
  * @returns
51787
51787
  */
51788
51788
  broadcast(request, toUserIds, timeout) {
51789
- if (this.state !== LiveState.OPEN)
51789
+ if (this.state !== exports.LiveState.OPEN)
51790
51790
  return false;
51791
51791
  return new Promise((resolve, reject) => {
51792
51792
  const customEvent = createLiveMsg(exports.Command.CustomEvent, request, toUserIds);