Closed baronfel closed 5 years ago
SubscriberInfo
should probably hold the HttpContext
of the request that initially started the websocket. I know that's kind of dangerous but pulling off all the possible things a user would want might be tricky (Things like User if authenticated, IPAddress, etc). We could put some members on there to make apparent the user shouldn't access that HttpContext
directly but I wouldn't want to hide it entirely.
Yeah I was thinking we might want it, but deliberately leaning on being conservative for the first pass. Worst case you could make the subscriberinfo type user-defined/generic and let them pass a generation-function to make the subscriberinfo
Additionally this gets into dotnet websockets aren't threadsafe territory. We can either steal more from https://github.com/TheAngryByrd/FSharp.Control.WebSockets/tree/master/src or reference it. It needs a bit of love though.
Sorta-related: channel topics in Phoenix are somewhat used for routing. They can be of the following forms:
Is this something that we want to explicitly support? right now the wildcard matching isn't a thing from what I can read.
Fixed by #174
With channels merged, we have a nice way to trigger server-side changes based on client-sent websocket messages, but it would be really nice to also be able to send messages from the server to a particular channel easily. I'm going to lay out a simple wishlist here of what I'd like to be able to do and then a short design.
Needs:
'message
to all subscribers for a particular topic'message
to a specific subscriber for a particular topicI think a decent mechanism for this would be to wrap the current channel state dictionary in a type that can be used to provide these methods, then register that type with the AspNetCore DI system for use in the rest of the server.
Speclet:
And the
ChannelHub
would be injected into the DI context at startup, and be backed by the internalsockets
dictionary (or some derivative of that).So in a handler we could do:
An initially-untyped interface seems fine, because if a user wanted they could easily build a typed-hub on top of this: