Hello everyone,

I have a websocket handler like this:

func motionEventsServer(ws *websocket.Conn) {
    var id string
    websocket.Message.Receive(ws, &id)


    for {
        data := motion{}
        websocket.JSON.Receive(ws, &data)
        deviceMap.Store(id, data)
        websocket.Message.Send(ws, fmt.Sprintf("%#v", deviceMap))
    }
}

It receives and responds correctly, however I noticed that my CPU got 
loaded quite high.
I looked at the sources and discovered an infinite loop "goto again":
https://github.com/golang/net/blob/master/websocket/websocket.go#L337

What is the proper way to wait for new websocket frames without loading CPU 
with useless checks?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to