Websockets in NestJs (Real-Time Chat App)

  Рет қаралды 2,357

Computerix

Computerix

Күн бұрын

We learn how to setup a websocket gateway in Nesjts, to subscribe to events, and emit messages. We learn different ways to broadcast messages, and consume them from a client, while building a simple chatting app
Donations: buymeacoffee.com/computerix
Timestamps:
--------------------
0:00- Creating the Websocket Gateway
2:38- Listening to events
5:37- Emitting Messages to the client
7:55- Brodcasting messages + Websocket Server Instance
10:45- Handling Socket Connections / Disconnect
14:10- Chat App Client Side + Enhancements
17:35- Testing the Real time Chat App
19:50- Side Notes
20:45- Recap

Пікірлер: 24
@mjavadhasanzade3478
@mjavadhasanzade3478 4 күн бұрын
awesome and helpfull thank you, if you could add more features like, sign in and authorize and usernames would be great.
@Naya-ss7vs
@Naya-ss7vs 2 ай бұрын
We missed seeing content from you! So helpful and informative as usual. Keep up the good work 🤝🏻
@Computerix
@Computerix 2 ай бұрын
Thank you !! :)
@piyumalchandrarathna5169
@piyumalchandrarathna5169 29 күн бұрын
Thank you bro. subscribed
@codexamofficial
@codexamofficial 2 ай бұрын
Thanks bro! Well Explained ✅ Subscribed and looking forward to more of your videos. 💌
@Computerix
@Computerix 2 ай бұрын
I'm glad if was helpful 🤝🏻 More coming soon !
@joeatallah338
@joeatallah338 2 ай бұрын
Super informative 💯
@Computerix
@Computerix 2 ай бұрын
I'm glad!
@abdulrahmanarmashi6954
@abdulrahmanarmashi6954 2 ай бұрын
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
@Computerix
@Computerix 2 ай бұрын
Thanks for the feedback! I'm planning on making a part 2, with authentication, rooms, and a database!
@abdulrahmanarmashi6954
@abdulrahmanarmashi6954 2 ай бұрын
@Computerix That is very good, so i am waiting for part 2 🤩
@dreamsachiever212
@dreamsachiever212 Ай бұрын
@@Computerix waiting for part 2. subscribed. thanks for your content. your teaching style is great.
@smileVideos-mb1yy
@smileVideos-mb1yy 2 ай бұрын
very nice thank
@Naya-ss7vs
@Naya-ss7vs 2 ай бұрын
Can you please tell us how we can use it practically? What are situations we might need this in?
@Computerix
@Computerix 2 ай бұрын
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
@quang.luu.179
@quang.luu.179 2 ай бұрын
Top!!!
@Computerix
@Computerix 2 ай бұрын
Thank you for your continuous support! 😁
@AHMED-nd7zt
@AHMED-nd7zt 2 ай бұрын
so what if i want it happend in privet chat between just to user
@Computerix
@Computerix 2 ай бұрын
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')
@AHMED-nd7zt
@AHMED-nd7zt 2 ай бұрын
@@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
@Computerix
@Computerix 2 ай бұрын
@@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!
@Naya-ss7vs
@Naya-ss7vs 2 ай бұрын
*grabs my notebook*
@Computerix
@Computerix 2 ай бұрын
😂💪
NestJs Authentication : Login, Signup, Refresh Tokens, JWT, Guards
58:19
Want to make a chat app? Get Real-time With WebSockets & Socket.io!
1:31:40
Good Morning Developers
Рет қаралды 5 М.
THEY WANTED TO TAKE ALL HIS GOODIES 🍫🥤🍟😂
00:17
OKUNJATA
Рет қаралды 24 МЛН
Smart Sigma Kid #funny #sigma #comedy
00:25
CRAZY GREAPA
Рет қаралды 28 МЛН
孩子多的烦恼?#火影忍者 #家庭 #佐助
00:31
火影忍者一家
Рет қаралды 51 МЛН
Easiest way to build real-time web apps? WEBSOCKETS with NestJS
38:24
Multitenancy in NestJS + Mongoose
41:48
Computerix
Рет қаралды 4,7 М.
I Discovered a Better Approach to NestJS Configuration
3:41
Tech Vision
Рет қаралды 273
Creating a Chat App With Flask-SocketIO (2023)
24:31
Pretty Printed
Рет қаралды 27 М.
NestJS Websockets Tutorial #1 - Creating a Websocket Gateway Server
20:37
Anson the Developer
Рет қаралды 53 М.
When RESTful architecture isn't enough...
21:02
Dreams of Code
Рет қаралды 247 М.
Real Time Chat Room Made Easy! | FastAPI Tutorial
11:32
Eric Roby
Рет қаралды 13 М.
JavaScript Visualized - Event Loop, Web APIs, (Micro)task Queue
12:35
THEY WANTED TO TAKE ALL HIS GOODIES 🍫🥤🍟😂
00:17
OKUNJATA
Рет қаралды 24 МЛН