One on One chat (Direct Message)

Continuing the discussion from Implement direct messages (no chat room) using phoenix channels:

Has anyone tried this Implement direct messages (no chat room) using phoenix channels the chrismccord way of communicating one on one conversation? I am trying to achieve this. Blogs and docs talk only about rooms chat
and is live view possible here?

A very common approach to implementing direct messages, is to see a private communication between two people as “a (private) room chat with only two people”. When you do that, all knowledge and techniques of implementing normal room chats carries over.


This approach is particularly a good idea because just that a conversation is 1 on 1 between two individuals does not mean that is 1 to 1 between two channels. If Bob is talking directly to Larry, Bob may still have 2 tabs open, and so Larry’s messages need to be sent to two different channels.


Yeah, thought about it, broadcasting to two different channels.
when i visited twitter, i noticed that it sends msgs on messages/sender-receiver =>
then i tried the same, to get both the users to be connected on a single socket,
“localhost/chat/sender-receiver” it worked fine, Later i thought to know it could be bit less performant when urls are created dynamically.
so planning to create a table private_chats with these columns with unique constraints (initiator_id, receiver_id, room, active). This way two people can chat on the specific room.
Hope it works, anybody has any suggestion on this. is this is a good way.