I'm trying to figure out the best way to utilize Server Sent Event channels and such. Most of the examples I've found just use "home" or "*", but I'm wondering if it would be best for each specific DTO to have it's own channel based on this comment in the docs:
As Request DTO names are unique in ServiceStack they also make good channel names which benefit from providing a typed API for free, e.g: typeof(Request).Name.
Or if the channel should be left as "home" or "*" and just handle different types of messages with NotifyUserId
The ways we plan on using SSE:
Server to Single User (for Browser Notifications, Alerts, Etc...)
User to User (various dispatcher to police officer updates / communications)
Server to entire Agency (an Agency has many users - for agency-wide global alerts)
Server to entire State (Texas, Louisiana, etc... for Amber Alerts, APB / All-Points Bulletin, etc...)
My initial thoughts are to subscribe each user to each channel via channel names like so:
["BrowserNotification", "DispatcherNotification", "AgencyNotification", "StateNotification"]
Maybe the StateNotification channel would simple be the state name, "Texas"
The AgencyNotification channel could be combined: "AgencyNotification:7323" for AgencyId 7323.
I feel like there may be a better way. Am I utilizing this correctly? What might be a good channel / selector structure given these various scenarios?
Channel selection is very app-specific and completely up to you. Channels are effectively a logical grouping where users in the same channel will be able to see any message sent to that channel. Selectors are used to specify which handler the message will be sent to.
If you would like to be able to send a notification to all users subscribed to "BrowserNotification" then that would be a good indication it should be its own channel, if you're never going to send messages to all users in the "BrowserNotification" channel then there's not really a reason for it to exist.
If you're only ever sending targeted messages to users or sessions then your not actually sending to users in a channel so you may as well just have a single "home" channel.