Answer the question
In order to leave comments, you need to log in
Socket chat on go?
Good afternoon, I'm trying to deal with sockets on go.
How to identify a specific connection.
For example, one user gives the server such a request {action:message,from_id:111,to_id:222,message:'Hi. How are you?'}
The server should answer {status:true} and go through all connected users, find user id 222 there and send this message specifically to him.
Using the example from here https://www.youtube.com/watch?v=ysAZ_oqPOo0
with packages from here github.com/gorilla/websocket .
But here is a general chat. It is necessary to somehow filter from whom and to whom to send data.
How to do it?
Thanks
Answer the question
In order to leave comments, you need to log in
https://github.com/gorilla/websocket/tree/master/e...
hub.go file, line 40
The pub-sub pattern is used. You can see the working prototype at https://github.com/uvelichitel/nezabu/ (Sorry for the light self-promotion, you can use the code at your discretion.)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question