MCPcopy
hub / github.com/daptin/daptin / tryRecvJSON

Function tryRecvJSON

websocket_test.go:113–120  ·  view source on GitHub ↗

tryRecvJSON reads a JSON message with a timeout, returns ok=false on timeout.

(ws *websocket.Conn, timeout time.Duration)

Source from the content-addressed store, hash-verified

111
112// tryRecvJSON reads a JSON message with a timeout, returns ok=false on timeout.
113func 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
122var wsTokenOnce sync.Once
123var wsToken string

Calls 1

AddMethod · 0.80

Tested by

no test coverage detected