MCPcopy
hub / github.com/benbjohnson/wtf / ignoreWebSocketReaders

Function ignoreWebSocketReaders

http/event.go:96–103  ·  view source on GitHub ↗

ignoreWebSocketReaders ignores all incoming WS messages on conn. This is required by the underlying library if we don't care about sent messages. This implementation was borrowed from gorilla's docs: https://godoc.org/github.com/gorilla/websocket#hdr-Control_Messages

(conn *websocket.Conn)

Source from the content-addressed store, hash-verified

94// This implementation was borrowed from gorilla's docs:
95// https://godoc.org/github.com/gorilla/websocket#hdr-Control_Messages
96func ignoreWebSocketReaders(conn *websocket.Conn) {
97 for {
98 if _, _, err := conn.NextReader(); err != nil {
99 conn.Close()
100 return
101 }
102 }
103}
104
105// upgrader is used to upgrade an HTTP connection to a Websocket connection.
106var upgrader = websocket.Upgrader{

Callers 1

handleEventsMethod · 0.85

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected