mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
Add option for events to define get filters
This commit is contained in:
1 file changed
+2
-2
@@ -265,7 +265,7 @@ export class SubscriptionController {
|
||||
* Broadcast an event to all subscribers of that event
|
||||
* @param event - Event to broadcast.
|
||||
*/
|
||||
broadcast<T>(event: Event<T> & { filters?: string | string[] }, filters?: string | string[]) {
|
||||
broadcast<T extends Event<T>>(event: T & { filters?: string | string[] }, filters?: string | string[]) {
|
||||
const entry = Link._eventsByClass.get(event.constructor);
|
||||
if (!entry) {
|
||||
throw new Error(`Unregistered Event class ${event.constructor.name}`);
|
||||
@@ -275,7 +275,7 @@ export class SubscriptionController {
|
||||
throw new Error(`Event ${entry.name} is not a registered as subscribable`);
|
||||
}
|
||||
|
||||
const broadcastFilters = SubscriptionFilters.fromShorthand(filters);
|
||||
const broadcastFilters = SubscriptionFilters.fromShorthand(filters ?? event.filters);
|
||||
for (const [addressIndex, subscriber] of eventData.subscriptions) {
|
||||
if ((subscriber.link.connector as WebSocketBaseConnector).closing) {
|
||||
eventData.subscriptions.delete(addressIndex);
|
||||
|
||||
Reference in new issue
Block a user