floating-live 0.16.0-alpha.16 → 0.16.0-alpha.17
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/room.d.ts +24 -10
- package/dist/live/room.js +23 -7
- package/dist/plugins/room/index.js +20 -4
- package/package.json +1 -1
package/dist/live/room.d.ts
CHANGED
|
@@ -21,12 +21,12 @@ export declare abstract class LiveRoom extends CustomEventEmitter implements Liv
|
|
|
21
21
|
timestamp: number;
|
|
22
22
|
/** 当前直播id */
|
|
23
23
|
liveId?: string;
|
|
24
|
-
/** 房间是否打开 */
|
|
25
|
-
opened: boolean;
|
|
26
24
|
/** 房间连接状态 */
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
|
|
25
|
+
connectionStatus: LiveConnectionStatus;
|
|
26
|
+
/** 房间开启状态 */
|
|
27
|
+
openStatus: LiveRoomOpenStatus;
|
|
28
|
+
get opened(): boolean;
|
|
29
|
+
get available(): boolean;
|
|
30
30
|
/** 打开连接 */
|
|
31
31
|
abstract open(): void;
|
|
32
32
|
/** 关闭连接 */
|
|
@@ -78,12 +78,14 @@ export interface LiveRoomData {
|
|
|
78
78
|
liveId?: string;
|
|
79
79
|
/** 直播状态 */
|
|
80
80
|
status: LiveRoomStatus;
|
|
81
|
-
/** 直播间是否可用 */
|
|
82
|
-
available: boolean;
|
|
83
|
-
/** 房间监听是否打开 */
|
|
84
|
-
opened: boolean;
|
|
85
81
|
/** 房间连接状态 */
|
|
86
|
-
|
|
82
|
+
connectionStatus: LiveConnectionStatus;
|
|
83
|
+
/** 房间监听状态 */
|
|
84
|
+
openStatus: LiveRoomOpenStatus;
|
|
85
|
+
/** 房间是否开启 */
|
|
86
|
+
opened: boolean;
|
|
87
|
+
/** 房间是否可用 */
|
|
88
|
+
available: boolean;
|
|
87
89
|
}
|
|
88
90
|
/** 房间展示信息 */
|
|
89
91
|
export interface LiveRoomDetailInfo {
|
|
@@ -133,6 +135,18 @@ export declare const LiveConnectionStatus: {
|
|
|
133
135
|
readonly disconnected: -1;
|
|
134
136
|
};
|
|
135
137
|
export type LiveConnectionStatus = EnumValue<typeof LiveConnectionStatus>;
|
|
138
|
+
/** 直播间开启状态 */
|
|
139
|
+
export declare const LiveRoomOpenStatus: {
|
|
140
|
+
/** 已关闭 */
|
|
141
|
+
readonly closed: 0;
|
|
142
|
+
/** 正在开启 */
|
|
143
|
+
readonly opening: 1;
|
|
144
|
+
/** 已开启 */
|
|
145
|
+
readonly opened: 2;
|
|
146
|
+
/** 不可用 */
|
|
147
|
+
readonly unavailable: -1;
|
|
148
|
+
};
|
|
149
|
+
export type LiveRoomOpenStatus = EnumValue<typeof LiveRoomOpenStatus>;
|
|
136
150
|
export interface LiveRoomEventMap {
|
|
137
151
|
/** */
|
|
138
152
|
status: {
|
package/dist/live/room.js
CHANGED
|
@@ -7,12 +7,16 @@ export class LiveRoom extends CustomEventEmitter {
|
|
|
7
7
|
this.status = LiveRoomStatus.off;
|
|
8
8
|
/** 时间戳 */
|
|
9
9
|
this.timestamp = 0;
|
|
10
|
-
/** 房间是否打开 */
|
|
11
|
-
this.opened = false;
|
|
12
10
|
/** 房间连接状态 */
|
|
13
|
-
this.
|
|
14
|
-
/**
|
|
15
|
-
this.
|
|
11
|
+
this.connectionStatus = LiveConnectionStatus.off;
|
|
12
|
+
/** 房间开启状态 */
|
|
13
|
+
this.openStatus = -1;
|
|
14
|
+
}
|
|
15
|
+
get opened() {
|
|
16
|
+
return this.openStatus == 2;
|
|
17
|
+
}
|
|
18
|
+
get available() {
|
|
19
|
+
return this.openStatus > -1;
|
|
16
20
|
}
|
|
17
21
|
/** 销毁 */
|
|
18
22
|
destroy() {
|
|
@@ -70,9 +74,10 @@ export class LiveRoom extends CustomEventEmitter {
|
|
|
70
74
|
timestamp: this.timestamp,
|
|
71
75
|
status: this.status,
|
|
72
76
|
liveId: this.liveId,
|
|
73
|
-
|
|
77
|
+
openStatus: this.openStatus,
|
|
74
78
|
opened: this.opened,
|
|
75
|
-
|
|
79
|
+
available: this.available,
|
|
80
|
+
connectionStatus: this.connectionStatus,
|
|
76
81
|
key: this.key,
|
|
77
82
|
};
|
|
78
83
|
}
|
|
@@ -106,3 +111,14 @@ export const LiveConnectionStatus = {
|
|
|
106
111
|
/** 连接失败或断开 */
|
|
107
112
|
disconnected: -1,
|
|
108
113
|
};
|
|
114
|
+
/** 直播间开启状态 */
|
|
115
|
+
export const LiveRoomOpenStatus = {
|
|
116
|
+
/** 已关闭 */
|
|
117
|
+
closed: 0,
|
|
118
|
+
/** 正在开启 */
|
|
119
|
+
opening: 1,
|
|
120
|
+
/** 已开启 */
|
|
121
|
+
opened: 2,
|
|
122
|
+
/** 不可用 */
|
|
123
|
+
unavailable: -1,
|
|
124
|
+
};
|
|
@@ -168,19 +168,35 @@ export class Room extends BasePlugin {
|
|
|
168
168
|
/** 打开房间连接 */
|
|
169
169
|
open(key) {
|
|
170
170
|
let room = this.map.get(key);
|
|
171
|
-
|
|
171
|
+
if (!room) {
|
|
172
|
+
this.throw(new this.Error("room:open_unexist", {
|
|
173
|
+
message: "打开的房间不存在",
|
|
174
|
+
target: `room/${key}`,
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
room.open();
|
|
172
178
|
}
|
|
173
179
|
/** 关闭房间连接 */
|
|
174
180
|
close(key) {
|
|
175
181
|
let room = this.map.get(key);
|
|
176
|
-
|
|
182
|
+
if (!room) {
|
|
183
|
+
this.throw(new this.Error("room:close_unexist", {
|
|
184
|
+
message: "关闭的房间不存在",
|
|
185
|
+
target: `room/${key}`,
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
room.close();
|
|
177
189
|
}
|
|
178
190
|
/** 更改某个房间的顺序 */
|
|
179
191
|
move(key, position) {
|
|
180
192
|
const arr = [...this.map];
|
|
181
193
|
const index = arr.findIndex(([k]) => k == key);
|
|
182
|
-
if (index == -1)
|
|
183
|
-
|
|
194
|
+
if (index == -1) {
|
|
195
|
+
this.throw(new this.Error("room:move_unexist", {
|
|
196
|
+
message: "要移动的房间不存在",
|
|
197
|
+
target: `room/${key}`,
|
|
198
|
+
}));
|
|
199
|
+
}
|
|
184
200
|
const [item] = arr.splice(index, 1);
|
|
185
201
|
arr.splice(position, 0, item);
|
|
186
202
|
this.map = new Map(arr);
|