Gorilla Websocket-读取错误:在失败的Websocket连接上重复读取

Using the gorilla websocket api for go, how do i know if a client is still connected?

What Im trying with now is:

func Listen(ws *websocket.Conn) {
    connTimeout := 3
    timeLastSent := time.Now().Second()

    for ((timeLastSent + connTimeout) % 60) != time.Now().Second() {

        msg := Message{}
        err := ws.ReadJSON(&msg)

        if err == websocket.ErrCloseSent {
            break
        } else if err != nil {
            continue
        }

        //Message recived
        EventMessage <- msg

        timeLastSent = time.Now().Second()
    }
  //Connection timed out.
    return
}

But this results in the error repeated read on failed websocket connection.

Ive been looking into using ws.SetReadDeadline(t), but Ive no idea of either how to use it nor if its even the thing Im looking for.

How should i go about this?