tryRecvJSON reads a JSON message with a timeout, returns ok=false on timeout.
(ws *websocket.Conn, timeout time.Duration)
| 111 | |
| 112 | // tryRecvJSON reads a JSON message with a timeout, returns ok=false on timeout. |
| 113 | func tryRecvJSON(ws *websocket.Conn, timeout time.Duration) (resource.WsOutMessage, bool) { |
| 114 | ws.SetReadDeadline(time.Now().Add(timeout)) |
| 115 | var msg resource.WsOutMessage |
| 116 | if err := websocket.JSON.Receive(ws, &msg); err != nil { |
| 117 | return msg, false |
| 118 | } |
| 119 | return msg, true |
| 120 | } |
| 121 | |
| 122 | var wsTokenOnce sync.Once |
| 123 | var wsToken string |
no test coverage detected