studying websocket phoenix channels, pubsub, transport
easy for broadcasting, but for 1:1 websocket messaging?
In C or in Pascal I will use an hash table, or dictionary, to associate the handle of the socket to a username, then when someone send to another simply will lookup the username to retrieve the socket then sending
In elixir/phoenix what is the most direct mode to achieve this one to one communication? (as example associating pid of the process/socket to a username?)
also I want to access at lower level to the websocket json packet, both read and write, eg. to put a json value before send, or to retrieve all the passed headers/infos into the socket/pid/descriptor map/struct
But keep in mind that phoenix channels are an abstraction on top of multiple transports and not just websockets. If you want low level websocket handling you’re likely better of integrating directly with cowboy.
You still want to use phoenix channels and pubsub. If I’m messaging you, and open two tabs, that’s no longer 1:1. There are two subscribed channels for me, you need pubsub.