Answer the question
In order to leave comments, you need to log in
How to implement rooms for private messages like in VK?
I would be grateful if you could help me how to implement unique message rooms, now I made it so that if the user enters /dialog/user id, then I create a room with my id + user id, and so that there is no problem of two different rooms, I created an entry in db for each priority it has the form Math.random () * 100, I did this in order to compare the priority and who has a higher priority goes to the first position, and who has less, his id becomes at the end,
example if(my.priority > user.priority) room = my.id + user.id, then I save the room record in db, but the problem is that I have to duplicate the code, that is, after if I write else user.id + my.id, everything works fine, but I have to duplicate the code in if and else , I would like not to write this shit code, and I want to ask how can I do something similar to a chat in VK, you enter the chat and the link becomes im? sel? and here is the id of a person, and when they come to you there is already my id
Answer the question
In order to leave comments, you need to log in
A private chat has 2 parameters sender and recipient and up to a bunch of names. Actually, you need to bring all this into one line, select it, check the user and give the chat
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question