How to use OnUpdateAsync

I feel stupid but I have to ask. How do we use the OnUpdateAsync hook on the ServerEventsFeature?
I know how to handle the OnConnect or OnCreated, but I can’t figure out how to get notified and react when a subscription’s channels are updated.

In my class, I can handle the OnCreated like this:

HostContext.GetPlugin<ServerEventsFeature>().OnCreated = (subscription, req) =>
            {
                HandleNewSub(subscription);
            };

but after that…how to ensure my HandleSubChannelsUpdate is called when the OnUpdateAsync is fired?

These are static event handlers that should be configured on Startup, i.e. they shouldn’t be modified at runtime.

The property definitions are available on ServerEventsFeature.cs.

It’s an async Func so it requires a Task return type or an async delegate, e.g:

Plugins.Add(new ServerEventsFeature {
    OnCreated = (sub,req) => {...},
    OnUpdateAsync = async sub => {...},
});
1 Like