I am building a web-chat application using django and django-channels. I have figured out the actual chat part, however I was trying to implement a random chat pairing feature which would allow to pair any two user who choose to chat randomly. I cannnot figure out how to implement this in the backend to create a sort of list which would update automatically and from which I can take two user, pair them and thus remove them from the list. I hope, my question is clear.
Asked
Active
Viewed 53 times
1 Answers
0
Keep a model in which you track all logged in users that are not in a chat. When 2 people enter a chat, remove them from the model same for log-out/disconnecting from the websocket in the waiting room. To match 2 people, you can select 2 random people from the model, remove them and send them to the correct chatroom

Leeuwtje
- 345
- 1
- 7