bradtraversy / chatcord

Realtime chat app with rooms
1.16k stars 1.15k forks source link

Prevent duplicate username in a chatroom #30

Open mrinmay7875 opened 3 years ago

mrinmay7875 commented 3 years ago

As of now we can have more than one user in a chat room. So if in a chat room if there is more than one users having the same username and then anyone of them sends a message then it becomes difficult/impossible to identify who among them sent the message.

It would be better if we could implement the feature which wont allow the user to join with a username that is already being used by one of the users in that chatroom.

RocketLauncher21 commented 2 years ago

A better idea would be giving a user ID to every user. If someone connects with a username for example "a" he will get a user ID. I will take the user id 123 for an example. Then , if he rejoins, with the same username, he should get the same ID. but if someone else joins, with the name "a" it should give him another user ID. For example 124. So thats a better way to do it.