floating-live 0.8.0 → 0.8.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.
package/package.json
CHANGED
package/src/controller/Room.js
CHANGED
package/src/controller/index.js
CHANGED
|
@@ -22,13 +22,13 @@ class Controller {
|
|
|
22
22
|
start() {
|
|
23
23
|
this.started = true;
|
|
24
24
|
this.timestamp = new Date().valueOf();
|
|
25
|
-
this.main.emit("start");
|
|
25
|
+
this.main.emit("start", this.timestamp);
|
|
26
26
|
}
|
|
27
27
|
/** 结束 */
|
|
28
28
|
end() {
|
|
29
29
|
this.closeAllRooms();
|
|
30
30
|
this.started = false;
|
|
31
|
-
this.main.emit("end");
|
|
31
|
+
this.main.emit("end", this.timestamp);
|
|
32
32
|
this.timestamp = 0;
|
|
33
33
|
}
|
|
34
34
|
/** 添加房间 */
|
package/src/index.js
CHANGED
|
@@ -21,10 +21,14 @@ class FloatingLive extends events_1.EventEmitter {
|
|
|
21
21
|
}
|
|
22
22
|
/** 添加插件 */
|
|
23
23
|
registerPlugin(name, pluginFunc) {
|
|
24
|
+
if (this.plugin.has(name)) {
|
|
25
|
+
this.emit("plugin_duplicate");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
24
28
|
Registerable_1.Registerable.currentPlugin = name;
|
|
25
29
|
let pluginObject = pluginFunc(this); // 获取插件操作对象
|
|
26
30
|
this.plugin.set(name, pluginObject);
|
|
27
|
-
this.emit("
|
|
31
|
+
this.emit("plugin_add", name);
|
|
28
32
|
console.log(`已添加插件: ${name}`);
|
|
29
33
|
Registerable_1.Registerable.currentPlugin = null;
|
|
30
34
|
return pluginObject;
|
|
@@ -36,7 +40,7 @@ class FloatingLive extends events_1.EventEmitter {
|
|
|
36
40
|
/** 移除插件 */
|
|
37
41
|
removePlugin(name) {
|
|
38
42
|
if (!this.plugin.has(name)) {
|
|
39
|
-
this.emit("
|
|
43
|
+
this.emit("plugin_unexist", name);
|
|
40
44
|
return;
|
|
41
45
|
}
|
|
42
46
|
let pluginObject = this.plugin.get(name);
|
|
@@ -44,7 +48,7 @@ class FloatingLive extends events_1.EventEmitter {
|
|
|
44
48
|
this.helper.roomGenerator.unregister(name);
|
|
45
49
|
this.helper.messageHandler.unregister(name);
|
|
46
50
|
pluginObject?.destory && pluginObject.destory();
|
|
47
|
-
this.emit("
|
|
51
|
+
this.emit("plugin_remove", name);
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
exports.default = FloatingLive;
|