Тёмный

Go Realtime Chat Part 2: websocket connection + chat rooms management 

david hwang
Подписаться 3 тыс.
Просмотров 18 тыс.
50% 1

Опубликовано:

 

6 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 29   
@dhij
@dhij Год назад
0:00 Demo 0:54 Overview of the hub architecture 2:25 Start working on createRoom 2:36 Define the hub, room, client, and the message structs + the hub constructor 5:30 Create the handler for/ws/createRoom endpoint 8:28 Call the hub and the handler in main.go and add the handler to the router 9:56 Start working on joinRoom 10:22 Instantiate the websocket connection in the joinRoom handler 15:35 Create the hub.Run() method and define the register, unregister, and broadcast channels 21:07 Call hub.Run() in main.go in a separate goroutine 21:29 Define the writeMessage() and readMessage() methods for the clients 26:17 Add the joinRoom handler to the /ws/joinRoom endpoint 26:50 Test the websocket connection on Postman 28:20 Create the /ws/getRooms endpoint and getRooms handler 30:15 Create the getClients handler and add the /ws/getClients endpoint 33:11 Test the endpoints
@chandraherdiputra1822
@chandraherdiputra1822 Год назад
thank you for sharing! I like the way you explain the architecture using diagram. It really helps me understand the code
@dhij
@dhij Год назад
yup glad that helped!
@mwnkt
@mwnkt Год назад
Keep it up man, there isn't a lot of go stuff on RU-vid
@dhij
@dhij Год назад
Appreciate it!
@0xivanov
@0xivanov 9 месяцев назад
golden video!
@AliAhmad-fx3dj
@AliAhmad-fx3dj Год назад
Very useful 👌 Thank you so much and keep it up 💯❤
@dhij
@dhij Год назад
thank you Ali! 🙂
@dewaindra8169
@dewaindra8169 Год назад
dude you are awsome , thanks for the vide
@dhij
@dhij Год назад
Thanks man!
@mikhailkalashnik0v
@mikhailkalashnik0v Год назад
Great series!! Can you please show how we can add optional password auth to each chat room please?
@kennt-yh5bm
@kennt-yh5bm Год назад
Great job! Really enjoy the video,. When will the next video on the frontend be up? hopefully it will be soon, looking forward to it:)
@dhij
@dhij Год назад
Appreciate it! Yup I will try to have it by this weekend :)
@yasinsaee5352
@yasinsaee5352 Год назад
When do you want publish next episodes ? 😭 Its very good course please publish next episode
@yasinsaee5352
@yasinsaee5352 Год назад
Bro you don’t want upload next part ?
@dhij
@dhij Год назад
@@yasinsaee5352 Appreciate it! It will be out in about a week or two!
@DesignerYeb
@DesignerYeb Год назад
👍🏻👍🏻
@dhij
@dhij Год назад
Thank you! :)
@335-arifdwinugroho2
@335-arifdwinugroho2 Месяц назад
very cool, but missing server validation I guess, because if I send an empty json file { } the service will still process it
@dhij
@dhij Месяц назад
yup the project is oriented towards learning and is nowhere perfect/production-ready 🙂
@jonathanLess
@jonathanLess Год назад
It will cause some problems when same user open multiple browsers? only one of the browser will get the message
@XfazXtudo
@XfazXtudo Год назад
Great tutorial! I've got a question, though... Why do you take the client id and the username from a query param instead of the JWT you always get from the cookies? Re: 13:01 By the way I'm in love with your channel, I'm watching it alllll!
@dhij
@dhij Год назад
Haha I appreciate it!! Well that could technically work too since I stored the user id and username as part of the cookie. But I am just leaving it up to the frontend to handle the user id & username. I would use the JWT to authenticate the user across pages on the frontend and not to be directly used on the server side.
@danmondy
@danmondy 7 месяцев назад
Is it ok for the CreateRoom handler to directly write to the Room map on the hub? Isn't there a concern about various routines writing to the same memory? Wasn't sure if I should create another channel for the hub to listen on for that.
@SwarajSingh-xs6dy
@SwarajSingh-xs6dy Год назад
what is the alternative of web sockets in production as they are not scalable in the product(monolith) and in serverless it is very complicated? Please reply
@skl9942
@skl9942 10 месяцев назад
You could do Server-Sent Events (SSE). SSE is simpler and more scalable in serverless environments, as it maintains a single unidirectional connection from the server to the client for streaming updates. But if you need it to be bi-directional theres no other alternative that I know of than websockets.
@NeraJima
@NeraJima Год назад
Could you please explain why writeMessage() was executed in a new go routine and readMessage() wasn't? Its at 26:11
@dhij
@dhij Год назад
You could definitely run readMessage() on a separate goroutine as well; I am just choosing to run it on the main goroutine :)
@0xivanov
@0xivanov 9 месяцев назад
golden video!
Далее
🍎 Apple Pie Cinnamon Roll Donut #Shorts
00:21
Просмотров 1,9 млн
Making Minimalist Chat Server in C on Linux
14:28
Просмотров 42 тыс.
WebSockets in 100 Seconds & Beyond with Socket.io
8:31