Websockets are mostly used for chatting apps / Live feeds - dashboards/ Multiplayer games / Real time editing tools that allow multiple users to edit at the same time (like figma).. You can basically use websockets for anything that requires real-time communication
@@AHMED-nd7zt Typically, you'd be logged in as a user and will possess a JWT token that you will send in the headers when connecting to the websockets server from your client. The backend will validate that JWT token from "socket.handshake.headers.authorization" (for example), and the token will include the userId when decoded.. You can then attach that userId on that specific socket using socket.data.userId = userId You can also store the socketId in your database if needed for the duration of that session. I am gonna make a video soon that will include users and authentication and rooms, etc.. So if you have any more confusions, they should be sorted in the video!
Very awesome and easy to understand, i hope you implement more features like creating a group, adding people to the group, and storing in database and more .... Thank you
That was actually a great start for a beginner like me
I'm glad!
your way is so great to approach and follow. many thanks
it could be better with sending messages to specific roomId/topicId
Can you please tell us how we can use it practically? What are situations we might need this in?
Websockets are mostly used for chatting apps / Live feeds - dashboards/ Multiplayer games / Real time editing tools that allow multiple users to edit at the same time (like figma).. You can basically use websockets for anything that requires real-time communication
so what if i want it happend in privet chat between just to user
You can send a message directly to one user by sending it to their socket Id, as such : socket.to(otherSocket.id).emit('event name', 'message')
@@Computerix
so if i have user in my data base with id of 1
how can i know which socket.id is related to him
@@AHMED-nd7zt Typically, you'd be logged in as a user and will possess a JWT token that you will send in the headers when connecting to the websockets server from your client.
The backend will validate that JWT token from "socket.handshake.headers.authorization" (for example), and the token will include the userId when decoded.. You can then attach that userId on that specific socket using socket.data.userId = userId
You can also store the socketId in your database if needed for the duration of that session.
I am gonna make a video soon that will include users and authentication and rooms, etc.. So if you have any more confusions, they should be sorted in the video!
Thanks a lot man, your content is amazing!
@@od1ez Appreciate it :)
We missed seeing content from you! So helpful and informative as usual. Keep up the good work 🤝🏻
Thank you !! :)
thank you very much. This is gold!
Very awesome and easy to understand, i hope you implement more features like creating a group, adding people to the group, and storing in database and more ....
Thank you
Thanks for the feedback! I'm planning on making a part 2, with authentication, rooms, and a database!
@Computerix That is very good, so i am waiting for part 2 🤩
@@Computerix waiting for part 2. subscribed. thanks for your content. your teaching style is great.
you are the best bro
Thank you for these helpful information
You are welcome!
awesome and helpfull thank you, if you could add more features like, sign in and authorize and usernames would be great.
Planning on doing so in a future video!
Thank you bro. subscribed
Super informative 💯
I'm glad!
Thanks bro! Well Explained ✅
Subscribed and looking forward to more of your videos. 💌
I'm glad if was helpful 🤝🏻
More coming soon !
Tks pro ❤❤
Rất hay
very nice thank
*grabs my notebook*
😂💪
Top!!!
Thank you for your continuous support! 😁