Answer the question
In order to leave comments, you need to log in
What is the correct way to pass the chat room number?
Hello. Again a question, on a theoretical example.
There is a chat. Authorized users enter it. Each of them can create their own chat room. The list of rooms is displayed as Nickname-How many_persons-Enter.
As I understand it, when creating a room, in the button ID, assign the nickname of the person who created the room, and then send the ID via JS via sockets, check if there is one in the list of rooms on the server, and then connect the user to the selected room. And the question is, is this approach rational? Or is there some easier way?
Answer the question
In order to leave comments, you need to log in
If I understand correctly, this is more a question of the back data structure. And for all the seeming simplicity, the task of chatting with rooms for some backends turns out to be not so simple (for example, for Firebase this is a non-trivial task).
Offhand, I would make a structure like this:
db: {
users: {
id: 111,
name: 'Rostislav',
room: 8888,
},
rooms: {
id: 8888,
messages: [...],
owner: 111,
public: true
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question