floating-live 0.8.7 → 0.9.0

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.
Files changed (56) hide show
  1. package/README.md +6 -4
  2. package/index.d.ts +7 -2
  3. package/index.js +23 -4
  4. package/package.json +1 -1
  5. package/plugin/acfun/acfunLive.d.ts +5 -10
  6. package/plugin/acfun/acfunLive.js +18 -35
  7. package/plugin/acfun/index.d.ts +1 -1
  8. package/plugin/acfun/index.js +1 -3
  9. package/plugin/bilibili/bilibiliLive.d.ts +7 -15
  10. package/plugin/bilibili/bilibiliLive.js +67 -114
  11. package/plugin/bilibili/index.d.ts +1 -1
  12. package/plugin/bilibili/index.js +1 -3
  13. package/plugin/chatPrint/chatPrint.d.ts +6 -7
  14. package/plugin/chatPrint/chatPrint.js +11 -17
  15. package/plugin/chatPrint/index.d.ts +2 -2
  16. package/plugin/chatPrint/index.js +2 -5
  17. package/plugin/consoleEvent/index.d.ts +1 -1
  18. package/plugin/consoleEvent/index.js +14 -2
  19. package/plugin/msgSave/index.d.ts +1 -1
  20. package/plugin/msgSave/index.js +6 -6
  21. package/plugin/msgSave/msgSave.d.ts +3 -3
  22. package/src/index.d.ts +51 -25
  23. package/src/index.js +98 -41
  24. package/src/lib/LiveRoom.d.ts +88 -0
  25. package/src/lib/LiveRoom.js +72 -0
  26. package/src/lib/{Registerable.d.ts → Reglist.d.ts} +6 -8
  27. package/src/lib/{Registerable.js → Reglist.js} +13 -19
  28. package/src/module/Command.d.ts +2 -0
  29. package/src/{types/room/RoomInfo.js → module/Command.js} +4 -0
  30. package/src/module/Plugin.d.ts +24 -0
  31. package/src/module/Plugin.js +74 -0
  32. package/src/{controller → module}/Room.d.ts +7 -13
  33. package/src/{controller → module}/Room.js +24 -16
  34. package/src/types/message/AttributeInfo.d.ts +4 -4
  35. package/src/types/message/MessageData.d.ts +125 -43
  36. package/src/types/plugin/Plugin.d.ts +4 -2
  37. package/src/types/room/PlatformInfo.d.ts +1 -1
  38. package/plugin/chat/ChatCommand.d.ts +0 -9
  39. package/plugin/chat/ChatCommand.js +0 -39
  40. package/plugin/chat/ChatFilter.d.ts +0 -9
  41. package/plugin/chat/ChatFilter.js +0 -44
  42. package/plugin/chat/chatProcessor.d.ts +0 -12
  43. package/plugin/chat/chatProcessor.js +0 -24
  44. package/src/controller/Message.d.ts +0 -9
  45. package/src/controller/Message.js +0 -15
  46. package/src/controller/index.d.ts +0 -39
  47. package/src/controller/index.js +0 -74
  48. package/src/types/message/MessageInfo.d.ts +0 -123
  49. package/src/types/message/MessageInfo.js +0 -2
  50. package/src/types/room/LiveInfo.d.ts +0 -24
  51. package/src/types/room/LiveInfo.js +0 -2
  52. package/src/types/room/LiveRoom.d.ts +0 -20
  53. package/src/types/room/LiveRoom.js +0 -2
  54. package/src/types/room/RoomInfo.d.ts +0 -16
  55. package/src/utils/getRoomInfo.d.ts +0 -4
  56. package/src/utils/getRoomInfo.js +0 -25
@@ -1,15 +1,11 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const getRoomInfo_1 = __importDefault(require("../utils/getRoomInfo"));
3
+ exports.RoomController = void 0;
7
4
  /** 直播间监听实例控制器 */
8
- class Room {
9
- constructor(controller) {
5
+ class RoomController {
6
+ constructor(main) {
10
7
  this.roomMap = new Map();
11
- this.controller = controller;
12
- this.main = controller.main;
8
+ this.main = main;
13
9
  }
14
10
  generate(r, open) {
15
11
  let platform;
@@ -25,7 +21,8 @@ class Room {
25
21
  }
26
22
  }
27
23
  /** 添加房间监听对象 */
28
- add(key, room, open) {
24
+ add(room, open) {
25
+ let key = room.key;
29
26
  if (this.roomMap.has(key)) {
30
27
  this.main.emit("room_exist", key);
31
28
  return;
@@ -34,7 +31,10 @@ class Room {
34
31
  // 添加监听事件
35
32
  // 直播消息
36
33
  room.on("msg", (data) => {
37
- this.controller.message.send(data);
34
+ this.main.helper.messageHandler.getList().forEach((handler) => {
35
+ handler(data);
36
+ });
37
+ this.main.emit("live_message", data);
38
38
  });
39
39
  // 直播消息源数据
40
40
  room.on("origin", (data) => {
@@ -50,24 +50,32 @@ class Room {
50
50
  });
51
51
  // 获取房间信息
52
52
  room.on("info", () => {
53
- this.main.emit("room_info", key, (0, getRoomInfo_1.default)(room));
53
+ this.main.emit("room_info", key, room.info);
54
54
  });
55
55
  // 直播信息更改
56
56
  room.on("change", (data) => {
57
57
  this.main.emit("room_change", key, data);
58
58
  });
59
+ // 直播状态更改
60
+ room.on("status", (status, timestamp) => {
61
+ this.main.emit("room_status", key, status, timestamp);
62
+ });
63
+ // 统计数据更新
64
+ room.on("stats", (data) => {
65
+ this.main.emit("room_stats", key, data);
66
+ });
59
67
  // 房间被打开
60
68
  room.on("open", () => {
61
- this.main.emit("room_open", key, (0, getRoomInfo_1.default)(room));
69
+ this.main.emit("room_open", key, room.info);
62
70
  });
63
71
  // 房间被关闭
64
72
  room.on("close", () => {
65
- this.main.emit("room_close", key, (0, getRoomInfo_1.default)(room));
73
+ this.main.emit("room_close", key, room.info);
66
74
  });
67
75
  if (open) {
68
76
  room.open();
69
77
  }
70
- this.main.emit("room_add", key, (0, getRoomInfo_1.default)(room));
78
+ this.main.emit("room_add", key, room.info);
71
79
  }
72
80
  /** 移除房间 */
73
81
  remove(roomKey) {
@@ -87,7 +95,7 @@ class Room {
87
95
  /** 获取房间信息 */
88
96
  info(roomKey) {
89
97
  let room = this.roomMap.get(roomKey);
90
- return room ? (0, getRoomInfo_1.default)(room) : undefined;
98
+ return room ? room.info : undefined;
91
99
  }
92
100
  /** 更新房间信息 */
93
101
  update(roomKey) {
@@ -107,4 +115,4 @@ class Room {
107
115
  room?.opening && room.close();
108
116
  }
109
117
  }
110
- exports.default = Room;
118
+ exports.RoomController = RoomController;
@@ -8,10 +8,10 @@ export interface UserInfo {
8
8
  avatar?: string;
9
9
  /** 粉丝勋章 */
10
10
  medal?: MedalInfo | null;
11
- /** 房管等级(1为主播, 2为管理员) */
12
- admin?: number;
11
+ /** 身份 */
12
+ identity?: "anchor" | "admin" | null;
13
13
  /** 粉丝vip等级 */
14
- privilege?: boolean | number;
14
+ membership?: boolean | number;
15
15
  /** vip等级 */
16
16
  vip?: boolean | number;
17
17
  /** 用户等级 */
@@ -26,7 +26,7 @@ export interface MedalInfo {
26
26
  /** 粉丝牌等级 */
27
27
  level?: number;
28
28
  /** 粉丝vip等级 */
29
- privilege?: number;
29
+ membership?: number;
30
30
  }
31
31
  /** 图像信息 */
32
32
  export interface ImageInfo {
@@ -1,6 +1,6 @@
1
- import { MessageInfo, MsgInfoBlock, MsgInfoGift, MsgInfoImage, MsgInfoInteract, MsgInfoPrivilege, MsgInfoSuperchat, MsgInfoText } from "./MessageInfo";
2
- import { LiveStats } from "../room/LiveInfo";
3
- export interface MessageData {
1
+ import { RoomBaseInfo, RoomStatsInfo, RoomStatus } from "../../lib/LiveRoom";
2
+ import { UserInfo, GiftInfo, ImageInfo } from "./AttributeInfo";
3
+ export interface MessageInterface {
4
4
  /** 平台名称 */
5
5
  platform: string;
6
6
  /** 房间号 */
@@ -8,73 +8,155 @@ export interface MessageData {
8
8
  /** 信息类型 */
9
9
  type: string;
10
10
  /** 数据信息 */
11
- info: MessageInfo;
12
- /** 本地时间戳 */
13
- local_timestamp?: number;
11
+ info: {
12
+ [attr: string]: any;
13
+ };
14
+ /** 记录时间 */
15
+ record_time: number;
14
16
  /** 其他属性 */
15
17
  [attr: string]: any;
16
18
  }
17
- export interface MessageText extends MessageData {
18
- type: "text";
19
- info: MsgInfoText;
20
- }
21
- /** 图片聊天消息 */
22
- export interface MessageImage extends MessageData {
23
- type: "image";
24
- info: MsgInfoImage;
25
- }
19
+ export declare type MessageExt<T extends MessageInterface, E extends {
20
+ [attr: string]: any;
21
+ } = {
22
+ [attr: string]: any;
23
+ }> = T & {
24
+ info: E;
25
+ };
26
+ /** 文本聊天消息 */
27
+ export declare type MessageChat = MessageInterface & {
28
+ type: "chat";
29
+ info: {
30
+ /** 用户信息 */
31
+ user: UserInfo;
32
+ /** 日期时间戳 */
33
+ timestamp: number;
34
+ /** 文本内容 */
35
+ content: string;
36
+ /** 文字颜色 */
37
+ color?: number | string;
38
+ /** 弹幕模式 */
39
+ mode?: number | string;
40
+ /** 文字大小 */
41
+ size?: number | string;
42
+ /** 图片信息 */
43
+ image?: ImageInfo;
44
+ /** 表情信息 */
45
+ emoticon?: ImageInfo;
46
+ };
47
+ };
26
48
  /** 礼物消息 */
27
- export interface MessageGift extends MessageData {
49
+ export declare type MessageGift = MessageInterface & {
28
50
  type: "gift";
29
- info: MsgInfoGift;
30
- }
51
+ info: {
52
+ /** 用户信息 */
53
+ user: UserInfo;
54
+ /** 日期时间戳 */
55
+ timestamp: number;
56
+ /** 礼物信息 */
57
+ gift: GiftInfo;
58
+ };
59
+ };
31
60
  /** 互动消息(进入直播间、点赞、关注、分享、加入粉丝团) */
32
- export interface MessageInteract extends MessageData {
61
+ export declare type MessageInteract = MessageInterface & {
33
62
  type: "entry" | "like" | "follow" | "share" | "join";
34
- info: MsgInfoInteract;
35
- }
63
+ info: {
64
+ /** 用户信息 */
65
+ user: UserInfo;
66
+ /** 日期时间戳 */
67
+ timestamp: number;
68
+ /** 信息标签 */
69
+ tag?: string | boolean;
70
+ };
71
+ };
36
72
  /** 粉丝vip开通消息 */
37
- export interface MessagePrivilege extends MessageData {
38
- type: "privilege";
39
- info: MsgInfoPrivilege;
40
- }
73
+ export declare type MessageMembership = MessageInterface & {
74
+ type: "membership";
75
+ info: {
76
+ /** 用户信息 */
77
+ user: UserInfo;
78
+ /** 日期时间戳 */
79
+ timestamp: number;
80
+ /** 礼物信息 */
81
+ gift: GiftInfo;
82
+ /** 开通vip名称 */
83
+ name: string;
84
+ /** 开通vip等级 */
85
+ level?: number;
86
+ /** 持续时间(天数) */
87
+ duration: number;
88
+ };
89
+ };
41
90
  /** 粉丝vip开通消息 */
42
- export interface MessageSuperchat extends MessageData {
91
+ export declare type MessageSuperchat = MessageInterface & {
43
92
  type: "superchat";
44
- info: MsgInfoSuperchat;
45
- }
93
+ info: {
94
+ /** 留言id */
95
+ id?: string;
96
+ /** 用户信息 */
97
+ user: UserInfo;
98
+ /** 日期时间戳 */
99
+ timestamp: number;
100
+ /** 文本内容 */
101
+ content: string;
102
+ /** 文字颜色 */
103
+ color?: number | string;
104
+ /** 礼物信息 */
105
+ gift: GiftInfo;
106
+ /** (SC)持续时间 */
107
+ duration: number;
108
+ };
109
+ };
46
110
  /** 禁言消息 */
47
- export interface MessageBlock extends MessageData {
111
+ export declare type MessageBlock = MessageInterface & {
48
112
  type: "block";
49
- info: MsgInfoBlock;
50
- }
113
+ info: {
114
+ /** 用户信息 */
115
+ user: UserInfo;
116
+ /** 日期时间戳 */
117
+ timestamp?: number;
118
+ /** 操作者 */
119
+ operator: UserInfo | {
120
+ identity: null | "admin" | "anchor";
121
+ };
122
+ };
123
+ };
51
124
  /** 直播开播消息 */
52
- export interface MessageLiveStart extends MessageData {
125
+ export declare type MessageLiveStart = MessageInterface & {
53
126
  type: "live_start";
54
127
  info: {
55
128
  /** 开播时间 */
56
- start_time: number;
129
+ timestamp: number;
57
130
  };
58
- }
131
+ };
59
132
  /** 直播切断消息 */
60
- export interface MessageLiveCut extends MessageData {
133
+ export declare type MessageLiveCut = MessageInterface & {
61
134
  type: "live_cut";
62
135
  info: {
63
136
  /** 切断消息 */
64
137
  message: string;
65
138
  };
66
- }
139
+ };
67
140
  /** 直播数据更新 */
68
- export interface MessageLiveStats extends MessageData {
141
+ export declare type MessageLiveStats = MessageInterface & {
69
142
  type: "live_stats";
70
- info: LiveStats;
71
- }
143
+ info: RoomStatsInfo;
144
+ };
145
+ /** 直播信息更新 */
146
+ export declare type MessageLiveChange = MessageInterface & {
147
+ type: "live_change";
148
+ info: RoomBaseInfo;
149
+ };
72
150
  /** 直播结束 */
73
- export interface MessageLiveEnd extends MessageData {
151
+ export declare type MessageLiveEnd = MessageInterface & {
74
152
  type: "live_end";
75
153
  info: {
76
154
  /** 直播状态 */
77
- status: "live" | "off" | "round" | "banned";
155
+ status: RoomStatus;
78
156
  };
79
- }
80
- export declare type MessageType = MessageText | MessageImage | MessageGift | MessageInteract | MessagePrivilege | MessageSuperchat | MessageBlock | MessageLiveStart | MessageLiveCut | MessageLiveStats | MessageLiveEnd;
157
+ };
158
+ declare type AllMessageType = MessageChat | MessageGift | MessageInteract | MessageMembership | MessageSuperchat | MessageBlock | MessageLiveStart | MessageLiveEnd | MessageLiveCut | MessageLiveChange | MessageLiveStats;
159
+ export declare type MessageData<T extends AllMessageType["type"] = AllMessageType["type"]> = AllMessageType & {
160
+ type: T;
161
+ };
162
+ export {};
@@ -1,3 +1,5 @@
1
- import FloatingLive from "../..";
1
+ import { FloatingLive } from "../..";
2
2
  /** 插件模块, 加载时调用 */
3
- export declare type FloatingLivePlugin<T = void> = (ctx: FloatingLive) => T;
3
+ export declare type FloatingLivePlugin<T extends FloatingLive = FloatingLive> = (ctx: T) => {
4
+ [key: string]: any;
5
+ } | void;
@@ -13,7 +13,7 @@ export interface PlatformInfo {
13
13
  level?: string[];
14
14
  };
15
15
  /** 粉丝vip信息 */
16
- privilege: {
16
+ membership: {
17
17
  /** 粉丝vip对应id */
18
18
  id: string;
19
19
  /** 粉丝vip名称 */
@@ -1,9 +0,0 @@
1
- import { MessageData } from "../../src/types/message/MessageData";
2
- import ChatProcessor from "./chatProcessor";
3
- declare class ChatCommand {
4
- chatProcessor: ChatProcessor;
5
- filterList: any[];
6
- constructor(chatProcessor: ChatProcessor, filterList: any[]);
7
- process(msg: MessageData): void;
8
- }
9
- export default ChatCommand;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class ChatCommand {
4
- constructor(chatProcessor, filterList) {
5
- this.chatProcessor = chatProcessor;
6
- this.filterList = filterList;
7
- }
8
- process(msg) {
9
- if (msg.type == "text" && !msg.block) {
10
- let text = msg.info.text;
11
- let filterList = this.filterList;
12
- for (let g = 0; g < filterList.length; g++) {
13
- let rule = filterList[g];
14
- if (rule.pattern.test(text)) {
15
- let command = {
16
- platform: msg.platform,
17
- type: "command",
18
- command: rule.command,
19
- timestamp: msg.local_timestamp,
20
- info: {
21
- type: "text",
22
- user: msg.info.user,
23
- },
24
- data: {},
25
- };
26
- if (rule.callback) {
27
- rule.callback(msg, command, rule.pattern);
28
- }
29
- msg.command = {
30
- command: command.command,
31
- data: command.data
32
- };
33
- this.chatProcessor.emit("command", command);
34
- }
35
- }
36
- }
37
- }
38
- }
39
- exports.default = ChatCommand;
@@ -1,9 +0,0 @@
1
- import { MessageData } from "../../src/types/message/MessageData";
2
- import ChatProcessor from "./ChatProcessor";
3
- declare class ChatFilter {
4
- chatProcessor: ChatProcessor;
5
- filterList: any[];
6
- constructor(chatProcessor: ChatProcessor, filterList: any[]);
7
- process(msg: MessageData): void;
8
- }
9
- export default ChatFilter;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class ChatFilter {
4
- constructor(chatProcessor, filterList) {
5
- this.chatProcessor = chatProcessor;
6
- this.filterList = filterList;
7
- }
8
- process(msg) {
9
- if (msg.type == "text" && msg.info.text) {
10
- let text = msg.info.text;
11
- let filterList = this.filterList;
12
- fgroup: for (let g = 0; g < filterList.length; g++) {
13
- let group = filterList[g];
14
- if (group.open) {
15
- for (let i = 0; i < group.keyword.length; i++) {
16
- if (text.includes(group.keyword[i])) {
17
- let keyword = group.keyword[i];
18
- msg.block = {
19
- type: group.type,
20
- name: group.name,
21
- keyword: keyword,
22
- mode: group.mode,
23
- };
24
- switch (group.mode) {
25
- case "hide": {
26
- msg.block.reason = group.reason;
27
- break;
28
- }
29
- case "replace": {
30
- msg.block.reason = group.reason;
31
- msg.block.replace = group.replace;
32
- break;
33
- }
34
- }
35
- this.chatProcessor.emit("filter", msg);
36
- break fgroup;
37
- }
38
- }
39
- }
40
- }
41
- }
42
- }
43
- }
44
- exports.default = ChatFilter;
@@ -1,12 +0,0 @@
1
- /// <reference types="node" />
2
- import ChatFilter from "./ChatFilter";
3
- import ChatCommand from "./ChatCommand";
4
- import { EventEmitter } from "events";
5
- import { MessageData } from "../../src/types/message/MessageData";
6
- declare class ChatProcessor extends EventEmitter {
7
- filter: ChatFilter;
8
- command: ChatCommand;
9
- constructor();
10
- process(msg: MessageData): void;
11
- }
12
- export default ChatProcessor;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const ChatFilter_1 = __importDefault(require("./ChatFilter"));
7
- const ChatCommand_1 = __importDefault(require("./ChatCommand"));
8
- const events_1 = require("events");
9
- let commandList = [];
10
- let filterList = [];
11
- class ChatProcessor extends events_1.EventEmitter {
12
- constructor() {
13
- super();
14
- this.filter = new ChatFilter_1.default(this, filterList);
15
- this.command = new ChatCommand_1.default(this, commandList);
16
- }
17
- process(msg) {
18
- if (this.filter)
19
- this.filter.process(msg);
20
- if (this.command)
21
- this.command.process(msg);
22
- }
23
- }
24
- exports.default = ChatProcessor;
@@ -1,9 +0,0 @@
1
- import Controller from ".";
2
- import FloatingLive from "..";
3
- import { MessageType } from "../types/message/MessageData";
4
- export default class Message {
5
- readonly controller: Controller;
6
- readonly main: FloatingLive;
7
- constructor(controller: Controller);
8
- send(msg: MessageType): void;
9
- }
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class Message {
4
- constructor(controller) {
5
- this.controller = controller;
6
- this.main = controller.main;
7
- }
8
- send(msg) {
9
- this.main.helper.messageHandler.getList().forEach((handler) => {
10
- handler(msg);
11
- });
12
- this.main.emit("live_message", msg);
13
- }
14
- }
15
- exports.default = Message;
@@ -1,39 +0,0 @@
1
- import FloatingLive from "..";
2
- import LiveRoom from "../types/room/LiveRoom";
3
- import Message from "./Message";
4
- import Room from "./Room";
5
- export default class Controller {
6
- readonly main: FloatingLive;
7
- /** room 控制模块 */
8
- readonly room: Room;
9
- /** message 控制模块 */
10
- readonly message: Message;
11
- /** 开始时间戳 */
12
- timestamp: number;
13
- /** 开始状态 */
14
- started: boolean;
15
- constructor(main: FloatingLive);
16
- /** 开始 */
17
- start(): void;
18
- /** 结束 */
19
- end(): void;
20
- /** 添加房间 */
21
- addRoom({ platform, id }: {
22
- platform: string;
23
- id: string | number;
24
- }, open?: boolean): void;
25
- /** 移除房间 */
26
- removeRoom(roomKey: string): void;
27
- /** 添加房间实例 */
28
- addLiveRoom(key: string, room: LiveRoom): void;
29
- /** 打开房间 */
30
- openRoom(roomKey: string): void;
31
- /** 关闭房间 */
32
- closeRoom(roomKey: string): void;
33
- /** 打开所有房间 */
34
- openAllRooms(): void;
35
- /** 关闭所有房间 */
36
- closeAllRooms(): void;
37
- /** 更新房间信息 */
38
- updateRoomInfo(roomKey: string): void;
39
- }
@@ -1,74 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const Message_1 = __importDefault(require("./Message"));
7
- const Room_1 = __importDefault(require("./Room"));
8
- class Controller {
9
- constructor(main) {
10
- /** 开始时间戳 */
11
- this.timestamp = 0;
12
- /** 开始状态 */
13
- this.started = false;
14
- this.main = main;
15
- this.room = new Room_1.default(this);
16
- this.message = new Message_1.default(this);
17
- this.main.on("room_open", () => {
18
- this.start();
19
- });
20
- }
21
- /** 开始 */
22
- start() {
23
- this.started = true;
24
- this.timestamp = new Date().valueOf();
25
- this.main.emit("start", this.timestamp);
26
- }
27
- /** 结束 */
28
- end() {
29
- this.closeAllRooms();
30
- this.started = false;
31
- this.main.emit("end", this.timestamp);
32
- this.timestamp = 0;
33
- }
34
- /** 添加房间 */
35
- addRoom({ platform, id }, open) {
36
- let generated = this.room.generate({ platform, id }, open);
37
- if (generated) {
38
- this.room.add(generated.key, generated.room);
39
- }
40
- }
41
- /** 移除房间 */
42
- removeRoom(roomKey) {
43
- this.room.remove(roomKey);
44
- }
45
- /** 添加房间实例 */
46
- addLiveRoom(key, room) {
47
- this.room.add(key, room);
48
- }
49
- /** 打开房间 */
50
- openRoom(roomKey) {
51
- this.room.open(roomKey);
52
- }
53
- /** 关闭房间 */
54
- closeRoom(roomKey) {
55
- this.room.close(roomKey);
56
- }
57
- /** 打开所有房间 */
58
- openAllRooms() {
59
- this.room.keyList.forEach((key) => {
60
- this.room.open(key);
61
- });
62
- }
63
- /** 关闭所有房间 */
64
- closeAllRooms() {
65
- this.room.keyList.forEach((key) => {
66
- this.room.close(key);
67
- });
68
- }
69
- /** 更新房间信息 */
70
- updateRoomInfo(roomKey) {
71
- this.room.update(roomKey);
72
- }
73
- }
74
- exports.default = Controller;