Answer the question
In order to leave comments, you need to log in
How to not send message to websocket sender in GO language?
Hello!
Here I took an example for creating a web socket (link below to github) and sending a message to all devices that are connected to the server.
The server sends everything well, but it sends a message even to the one who sent this message, but this is not necessary.
I can't figure out how to extract the sender and not send him a message of his own.
Can you help? Google has searched all over already :(
There is a sendall function, it is responsible for sending, apparently it needs to be corrected somehow...
https://github.com/jakecoffman/go-angular-tutorial...
Answer the question
In order to leave comments, you need to log in
I guess you need it
func sendAll(msg []byte, myconn *websocket.Conn) {
for conn := range connections {
if myconn != conn {
if err := conn.WriteMessage(websocket.TextMessage, msg); err != nil {
delete(connections, conn)
conn.Close()
}
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question