I want to store client websocket connection into wsList
, and send response in uniform. but it will return "use of closed network connection". How to fix it?
import {
"code.google.com/p/go.net/websocket"
...
}
var wsList []*websocket.Conn
func WShandler(ws *websocket.Conn) {
wsList = append(wsList, ws)
go sendmsg()
}
func sendmsg() {
for _, conn := range wsList {
if err := websocket.JSON.Send(conn, outmsg); err != nil {
fmt.Printf("%s", err) //"use of closed network connection"
}
}
}