@realsee/live 0.5.0-alpha.4 → 0.5.0-alpha.5
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 +2 -0
- package/dist/live/live.d.ts +14 -1
- package/dist/realsee-live.cjs.development.js +51 -15
- 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 +51 -15
- package/dist/realsee-live.esm.js.map +1 -1
- package/dist/realsee-live.umd.development.js +51 -15
- 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/package.json +1 -1
package/dist/realsee-live.esm.js
CHANGED
|
@@ -1486,6 +1486,9 @@ class LiveController extends Subscribe {
|
|
|
1486
1486
|
this._handleOpenEvent = (event) => {
|
|
1487
1487
|
logger$1.info('live room open', event.detail);
|
|
1488
1488
|
this.state = LiveState.OPEN;
|
|
1489
|
+
if (event.detail.reconnects > 0) {
|
|
1490
|
+
this.emit('reconnected', event.detail);
|
|
1491
|
+
}
|
|
1489
1492
|
};
|
|
1490
1493
|
/**
|
|
1491
1494
|
* 处理超时
|
|
@@ -1612,6 +1615,7 @@ class Live extends Subscribe {
|
|
|
1612
1615
|
this._addLiveControllerEventListeners = () => {
|
|
1613
1616
|
this._controller.on('stateChange', this._handleStateChange);
|
|
1614
1617
|
this._controller.on('message', this._handleMessage);
|
|
1618
|
+
this._controller.on('reconnected', this._handleReconnected);
|
|
1615
1619
|
};
|
|
1616
1620
|
/**
|
|
1617
1621
|
* 移除带看控制的事件监听
|
|
@@ -1619,6 +1623,7 @@ class Live extends Subscribe {
|
|
|
1619
1623
|
this._removeLiveControllerEventListeners = () => {
|
|
1620
1624
|
this._controller.off('stateChange', this._handleStateChange);
|
|
1621
1625
|
this._controller.off('message', this._handleMessage);
|
|
1626
|
+
this._controller.off('reconnected', this._handleReconnected);
|
|
1622
1627
|
};
|
|
1623
1628
|
/**
|
|
1624
1629
|
* 带看状态变化
|
|
@@ -1626,6 +1631,10 @@ class Live extends Subscribe {
|
|
|
1626
1631
|
* @returns
|
|
1627
1632
|
*/
|
|
1628
1633
|
this._handleStateChange = (state, prevState) => this.emit('stateChange', state, prevState);
|
|
1634
|
+
/**
|
|
1635
|
+
* 消息接收
|
|
1636
|
+
* @param liveMsg
|
|
1637
|
+
*/
|
|
1629
1638
|
this._handleMessage = (liveMsg) => __awaiter(this, void 0, void 0, function* () {
|
|
1630
1639
|
var _b, _c, _d, _e, _f, _g;
|
|
1631
1640
|
if (typeof liveMsg === 'object') {
|
|
@@ -1657,6 +1666,7 @@ class Live extends Subscribe {
|
|
|
1657
1666
|
*/
|
|
1658
1667
|
case Command.RTCInfo: {
|
|
1659
1668
|
const { voice_id: voiceId, type } = data;
|
|
1669
|
+
this._buildInData.rtcInfo = { voiceId, type };
|
|
1660
1670
|
if (!((_b = this.$RTC) === null || _b === void 0 ? void 0 : _b.joined)) {
|
|
1661
1671
|
const result = yield ((_c = this.$RTC) === null || _c === void 0 ? void 0 : _c.join({
|
|
1662
1672
|
voiceId,
|
|
@@ -1768,6 +1778,32 @@ class Live extends Subscribe {
|
|
|
1768
1778
|
}
|
|
1769
1779
|
}
|
|
1770
1780
|
});
|
|
1781
|
+
/**
|
|
1782
|
+
* 处理重连
|
|
1783
|
+
* @param detail
|
|
1784
|
+
*/
|
|
1785
|
+
this._handleReconnected = (detail) => __awaiter(this, void 0, void 0, function* () {
|
|
1786
|
+
var _h, _j, _k, _l, _m, _o, _p;
|
|
1787
|
+
// 已经重连上ws,尝试重连语音
|
|
1788
|
+
this.$RTC.joined = false;
|
|
1789
|
+
const { rtcInfo } = this._buildInData;
|
|
1790
|
+
if (rtcInfo) {
|
|
1791
|
+
const { voiceId, type } = rtcInfo;
|
|
1792
|
+
const result = yield ((_h = this.$RTC) === null || _h === void 0 ? void 0 : _h.join({
|
|
1793
|
+
voiceId,
|
|
1794
|
+
userId: ((_j = this.selfInfo) === null || _j === void 0 ? void 0 : _j.id) || '',
|
|
1795
|
+
roomId: (_k = this.roomInfo) === null || _k === void 0 ? void 0 : _k.info.room_code,
|
|
1796
|
+
type,
|
|
1797
|
+
}));
|
|
1798
|
+
if (result) {
|
|
1799
|
+
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 : MicroStatus.OPEN;
|
|
1800
|
+
yield ((_p = this.$RTC) === null || _p === void 0 ? void 0 : _p.toggleMicro(status === MicroStatus.OPEN));
|
|
1801
|
+
}
|
|
1802
|
+
else {
|
|
1803
|
+
logger$1.error('加入语音房间失败');
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
});
|
|
1771
1807
|
/**
|
|
1772
1808
|
* 清理带看缓存的数据
|
|
1773
1809
|
*/
|
|
@@ -1780,12 +1816,12 @@ class Live extends Subscribe {
|
|
|
1780
1816
|
* @returns
|
|
1781
1817
|
*/
|
|
1782
1818
|
this.connect = (options = {}) => __awaiter(this, void 0, void 0, function* () {
|
|
1783
|
-
var
|
|
1819
|
+
var _q, _r, _s, _t;
|
|
1784
1820
|
// 检查 url 和 票据获取接口实现
|
|
1785
|
-
this._options.url = (
|
|
1786
|
-
this._options.getTicket = (
|
|
1821
|
+
this._options.url = (_r = (_q = options.url) !== null && _q !== void 0 ? _q : this._options.url) !== null && _r !== void 0 ? _r : '';
|
|
1822
|
+
this._options.getTicket = (_s = options.getTicket) !== null && _s !== void 0 ? _s : this._options.getTicket;
|
|
1787
1823
|
this._options.initialMicroStatus =
|
|
1788
|
-
(
|
|
1824
|
+
(_t = options.rtcMicStatus) !== null && _t !== void 0 ? _t : this._options.initialMicroStatus;
|
|
1789
1825
|
if (!/^ws(s):\/\//.test(this._options.url) ||
|
|
1790
1826
|
typeof this._options.getTicket !== 'function') {
|
|
1791
1827
|
if (!/^ws(s):\/\//.test(this._options.url)) {
|
|
@@ -1827,11 +1863,11 @@ class Live extends Subscribe {
|
|
|
1827
1863
|
* @returns
|
|
1828
1864
|
*/
|
|
1829
1865
|
this.exit = () => __awaiter(this, void 0, void 0, function* () {
|
|
1830
|
-
var
|
|
1866
|
+
var _u;
|
|
1831
1867
|
this._clearLiveData();
|
|
1832
1868
|
try {
|
|
1833
1869
|
/** 退出强制关闭语音 */
|
|
1834
|
-
(
|
|
1870
|
+
(_u = this.$RTC) === null || _u === void 0 ? void 0 : _u.quit();
|
|
1835
1871
|
yield this.updateStatus(BuiltinEventType.RoomChange, BuiltinActionType.RoomClose, {});
|
|
1836
1872
|
}
|
|
1837
1873
|
catch (e) {
|
|
@@ -1858,10 +1894,10 @@ class Live extends Subscribe {
|
|
|
1858
1894
|
});
|
|
1859
1895
|
// 仅用于用户自己的麦克风控制
|
|
1860
1896
|
this.toggleMicro = (microStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
1861
|
-
var
|
|
1862
|
-
if (!((
|
|
1897
|
+
var _v, _w, _x;
|
|
1898
|
+
if (!((_w = (_v = this.selfInfo) === null || _v === void 0 ? void 0 : _v.permission) === null || _w === void 0 ? void 0 : _w.control_own_micro))
|
|
1863
1899
|
return false;
|
|
1864
|
-
const result = yield ((
|
|
1900
|
+
const result = yield ((_x = this.$RTC) === null || _x === void 0 ? void 0 : _x.toggleMicro(microStatus));
|
|
1865
1901
|
if (result) {
|
|
1866
1902
|
yield this.updateStatus(BuiltinEventType.UserChange, BuiltinActionType.UserMicroStatus, {
|
|
1867
1903
|
status: microStatus ? MicroStatus.OPEN : MicroStatus.CLOSE,
|
|
@@ -1876,12 +1912,12 @@ class Live extends Subscribe {
|
|
|
1876
1912
|
* @returns
|
|
1877
1913
|
*/
|
|
1878
1914
|
this.forbidMicro = (microStatus, toUserIds) => __awaiter(this, void 0, void 0, function* () {
|
|
1879
|
-
var
|
|
1915
|
+
var _y, _z;
|
|
1880
1916
|
if (typeof this._options.canForbidUserMicro === 'function' &&
|
|
1881
1917
|
!this._options.canForbidUserMicro(toUserIds)) {
|
|
1882
1918
|
return false;
|
|
1883
1919
|
}
|
|
1884
|
-
if (!((
|
|
1920
|
+
if (!((_z = (_y = this.selfInfo) === null || _y === void 0 ? void 0 : _y.permission) === null || _z === void 0 ? void 0 : _z.control_other_micro)) {
|
|
1885
1921
|
return false;
|
|
1886
1922
|
}
|
|
1887
1923
|
return yield this.updateStatus(BuiltinEventType.UserChange, BuiltinActionType.UserMicroStatus, {
|
|
@@ -1895,12 +1931,12 @@ class Live extends Subscribe {
|
|
|
1895
1931
|
* @returns
|
|
1896
1932
|
*/
|
|
1897
1933
|
this.forbidSync = (sync, toUserIds) => __awaiter(this, void 0, void 0, function* () {
|
|
1898
|
-
var
|
|
1934
|
+
var _0, _1;
|
|
1899
1935
|
if (typeof this._options.canForbidUserSync === 'function' &&
|
|
1900
1936
|
!this._options.canForbidUserSync(toUserIds)) {
|
|
1901
1937
|
return false;
|
|
1902
1938
|
}
|
|
1903
|
-
if (!((
|
|
1939
|
+
if (!((_1 = (_0 = this.selfInfo) === null || _0 === void 0 ? void 0 : _0.permission) === null || _1 === void 0 ? void 0 : _1.control_other_sync)) {
|
|
1904
1940
|
return false;
|
|
1905
1941
|
}
|
|
1906
1942
|
return yield this.updateStatus(BuiltinEventType.UserChange, BuiltinActionType.UserPermission, { sync_frame: sync }, toUserIds);
|
|
@@ -1911,12 +1947,12 @@ class Live extends Subscribe {
|
|
|
1911
1947
|
* @returns
|
|
1912
1948
|
*/
|
|
1913
1949
|
this.kick = (toUserIds) => __awaiter(this, void 0, void 0, function* () {
|
|
1914
|
-
var
|
|
1950
|
+
var _2, _3;
|
|
1915
1951
|
if (typeof this._options.canForbidUserKick === 'function' &&
|
|
1916
1952
|
!this._options.canForbidUserKick(toUserIds)) {
|
|
1917
1953
|
return false;
|
|
1918
1954
|
}
|
|
1919
|
-
if (!((
|
|
1955
|
+
if (!((_3 = (_2 = this.selfInfo) === null || _2 === void 0 ? void 0 : _2.permission) === null || _3 === void 0 ? void 0 : _3.change_other_status)) {
|
|
1920
1956
|
return false;
|
|
1921
1957
|
}
|
|
1922
1958
|
return yield this.updateStatus(BuiltinEventType.UserChange, BuiltinActionType.UserStatus, {
|