fix(plugins) only broadcast plugins with actions
This commit is contained in:
@@ -69,15 +69,22 @@ export default class WetSock {
|
|||||||
handleOpen(ws) {
|
handleOpen(ws) {
|
||||||
const client = new SocketClient(ws.data.clientId, ws);
|
const client = new SocketClient(ws.data.clientId, ws);
|
||||||
this.#clients.set(client.id, client);
|
this.#clients.set(client.id, client);
|
||||||
client.send({
|
|
||||||
event: 'plugins',
|
const plugins = [...this.#plugins.keys()].filter(key => {
|
||||||
data: [...this.#plugins.keys()].map(key => {
|
return typeof(this.#plugins.get(key).plugin.actions) == 'function'
|
||||||
|
}).map(key => {
|
||||||
return {
|
return {
|
||||||
identifier: key,
|
identifier: key,
|
||||||
actions: this.#plugins.get(key).plugin.actions()
|
actions: this.#plugins.get(key).plugin.actions()
|
||||||
};
|
};
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(plugins.length > 0) {
|
||||||
|
client.send({
|
||||||
|
event: 'plugins',
|
||||||
|
data:
|
||||||
|
});
|
||||||
|
}
|
||||||
this.emit('open', client);
|
this.emit('open', client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user