R
R
Roman Rakzin2015-03-21 22:53:58
go
Roman Rakzin, 2015-03-21 22:53:58

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

4 answer(s)
A
Andrey K, 2015-03-22
@mututunus

https://github.com/gorilla/websocket/tree/master/e...
hub.go file, line 40

T
theaidem, 2015-03-22
@theaidem

most primitive example using golem

U
uvelichitel, 2015-03-22
@uvelichitel

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.)

I
index0h, 2015-03-21
@index0h

google for "pub sub"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question