Fixed TestControl subscription requests

This commit is contained in:
Cooldude2606 committed 2023-09-06 01:09:02 +01:00
1 parent da25196830
commit 71166af75b
3 files changed
+15 -12

No files matched your search

+5 -5
View File
@@ -241,12 +241,12 @@ export default class Controller {
} }
// Handle subscriptions for all internal properties // Handle subscriptions for all internal properties
this.subscriptions.handle<lib.HostUpdateEvent>(lib.HostUpdateEvent, undefined, event => event.update.id); this.subscriptions.handle<lib.HostUpdateEvent>(lib.HostUpdateEvent, event => event.update.id);
this.subscriptions.handle<lib.InstanceDetailsUpdateEvent>(lib.InstanceDetailsUpdateEvent, undefined, event => event.details.id); this.subscriptions.handle<lib.InstanceDetailsUpdateEvent>(lib.InstanceDetailsUpdateEvent, event => event.details.id);
this.subscriptions.handle<lib.InstanceSaveListUpdateEvent>(lib.InstanceSaveListUpdateEvent, undefined, event => event.instanceId); this.subscriptions.handle<lib.InstanceSaveListUpdateEvent>(lib.InstanceSaveListUpdateEvent, event => event.instanceId);
this.subscriptions.handle<lib.ModPackUpdateEvent>(lib.ModPackUpdateEvent, undefined, event => event.modPack.id!); this.subscriptions.handle<lib.ModPackUpdateEvent>(lib.ModPackUpdateEvent, event => event.modPack.id!);
this.subscriptions.handle<lib.ModUpdateEvent>(lib.ModUpdateEvent); this.subscriptions.handle<lib.ModUpdateEvent>(lib.ModUpdateEvent);
this.subscriptions.handle<lib.UserUpdateEvent>(lib.UserUpdateEvent, undefined, event => event.user.name); this.subscriptions.handle<lib.UserUpdateEvent>(lib.UserUpdateEvent, event => event.user.name);
// Load plugins // Load plugins
await this.loadPlugins(); await this.loadPlugins();
+2 -2
View File
@@ -121,11 +121,11 @@ export class SubscriptionController {
* Allow clients to subscribe to an event by telling the subscription controller to accept them * Allow clients to subscribe to an event by telling the subscription controller to accept them
* Has an optional subscription update handler which is called when any client updates their subscription * Has an optional subscription update handler which is called when any client updates their subscription
*/ */
handle<T>(Event: EventClass<T>, subscriptionUpdate?: SubscriptionRequestHandler<T>, channelCategoriser?: SubscriptionChannelCategoriser<T>): void; handle<T>(Event: EventClass<T>, channelCategoriser?: SubscriptionChannelCategoriser<T>, subscriptionUpdate?: SubscriptionRequestHandler<T>,): void;
handle( handle(
Event: EventClass<unknown>, Event: EventClass<unknown>,
subscriptionUpdate?: SubscriptionRequestHandler<unknown>,
channelCategoriser?: SubscriptionChannelCategoriser<unknown>, channelCategoriser?: SubscriptionChannelCategoriser<unknown>,
subscriptionUpdate?: SubscriptionRequestHandler<unknown>,
) { ) {
const entry = Link._eventsByClass.get(Event); const entry = Link._eventsByClass.get(Event);
if (!entry) { if (!entry) {
+8 -5
View File
@@ -34,19 +34,22 @@ class TestControl extends lib.Link {
return; return;
} }
this.send( this.send(
new lib.HostSetSubscriptionsRequest(true, []) new lib.SubscriptionRequest(lib.HostUpdateEvent.name, true)
).catch(err => logger.error(`Error setting host subscriptions:\n${err.stack}`)); ).catch(err => logger.error(`Error setting host subscriptions:\n${err.stack}`));
this.send( this.send(
new lib.InstanceDetailsSetSubscriptionsRequest(true, []) new lib.SubscriptionRequest(lib.InstanceDetailsUpdateEvent.name, true)
).catch(err => logger.error(`Error setting instance subscriptions:\n${err.stack}`)); ).catch(err => logger.error(`Error setting instance subscriptions:\n${err.stack}`));
this.send( this.send(
new lib.InstanceSetSaveListSubscriptionsRequest(true, []) new lib.SubscriptionRequest(lib.InstanceSaveListUpdateEvent.name, true)
).catch(err => logger.error(`Error setting save list subscriptions:\n${err.stack}`)); ).catch(err => logger.error(`Error setting save list subscriptions:\n${err.stack}`));
this.send( this.send(
new lib.ModSetSubscriptionsRequest(true, []) new lib.SubscriptionRequest(lib.ModUpdateEvent.name, true)
).catch(err => logger.error(`Error setting mod subscriptions:\n${err.stack}`)); ).catch(err => logger.error(`Error setting mod subscriptions:\n${err.stack}`));
this.send( this.send(
new lib.UserSetSubscriptionsRequest(true, []) new lib.SubscriptionRequest(lib.ModPackUpdateEvent.name, true)
).catch(err => logger.error(`Error setting mod pack subscriptions:\n${err.stack}`));
this.send(
new lib.SubscriptionRequest(lib.UserUpdateEvent.name, true)
).catch(err => logger.error(`Error setting user subscriptions:\n${err.stack}`)); ).catch(err => logger.error(`Error setting user subscriptions:\n${err.stack}`));
}); });