Before diving into the code to try to understand how the full system works, I want to know how hard it would be to make websockets & channels work with multiple pubsub servers.
Basically, the idea is to allow different clients to use their own channel names. Currently we have the client ID as a prefix to the channel name : "jwp:<client_id>:<name>" so we can direct connexions to our channel implementation (matching "jwp:*"). As the channel name is unique, it works well and different app do not have other apps messages. This is with the default Phoenix 1.5 setup.
Now, with multiple pubsub servers, it would be easyier to provide different channel implementations like "public:*", "private:*", "presence:*", "state:*".
I guess I can hack it some way, but is there a good way of doing it ? And how would it behave with distribution ?
Yes, this is why I made my second post, there is a simple way to use different channel modules based on the prefix. But still we need to have the client_id in the channel name, which requires additional checks for authentication in the server and adds some indirection for the clients, as they can’t just call socket.channel('true_name').
The second post isn’t clicking for me. If the topic has the client_id in it, you can authorize that they are allowed to join/3 the channel, based on the socket state and the channel topic name. You authenticate in the socket connect function, and authorize in the channel join function based on the topic and assigns state.