MCPcopy
hub / github.com/wavetermdev/waveterm / WritePing

Function WritePing

pkg/web/ws.go:167–177  ·  view source on GitHub ↗
(conn *websocket.Conn)

Source from the content-addressed store, hash-verified

165}
166
167func WritePing(conn *websocket.Conn) error {
168 now := time.Now()
169 pingMessage := map[string]interface{}{"type": "ping", "stime": now.UnixMilli()}
170 jsonVal, _ := json.Marshal(pingMessage)
171 _ = conn.SetWriteDeadline(time.Now().Add(wsWriteWaitTimeout)) // no error
172 err := conn.WriteMessage(websocket.TextMessage, jsonVal)
173 if err != nil {
174 return err
175 }
176 return nil
177}
178
179func WriteLoop(conn *websocket.Conn, outputCh chan any, closeCh chan any, routeId string) {
180 ticker := time.NewTicker(wsInitialPingTime)

Callers 1

WriteLoopFunction · 0.85

Calls 1

SetWriteDeadlineMethod · 0.80

Tested by

no test coverage detected