This commit is contained in:
2025-12-21 19:29:34 +08:00
parent 61f89e8250
commit caaec4d870

View File

@@ -179,14 +179,15 @@ export class ServerBase implements ServerType {
}
on(listener: OnListener) {
this.listeners = [];
const randomId = Math.random().toString(36).substring(2, 15);
if (typeof listener === 'function') {
this.listeners.push({ func: listener });
this.listeners.push({ func: listener, id: 'all-' + randomId });
return;
}
if (Array.isArray(listener)) {
for (const item of listener) {
if (typeof item === 'function') {
this.listeners.push({ func: item });
this.listeners.push({ func: item, id: 'all-' + randomId });
} else {
this.listeners.push(item);
}