MCPcopy
hub / github.com/gorilla/websocket / ping

Function ping

examples/command/main.go:81–94  ·  view source on GitHub ↗
(ws *websocket.Conn, done chan struct{})

Source from the content-addressed store, hash-verified

79}
80
81func ping(ws *websocket.Conn, done chan struct{}) {
82 ticker := time.NewTicker(pingPeriod)
83 defer ticker.Stop()
84 for {
85 select {
86 case <-ticker.C:
87 if err := ws.WriteControl(websocket.PingMessage, []byte{}, time.Now().Add(writeWait)); err != nil {
88 log.Println("ping:", err)
89 }
90 case <-done:
91 return
92 }
93 }
94}
95
96func internalError(ws *websocket.Conn, msg string, err error) {
97 log.Println(msg, err)

Callers 1

serveWsFunction · 0.85

Calls 1

WriteControlMethod · 0.80

Tested by

no test coverage detected