Skip to content

Commit aef42a8

Browse files
committed
Add note about reading the connection.
1 parent 0e7b5f8 commit aef42a8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

doc.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,19 @@
102102
// methods (NextReader, SetReadDeadline, ReadMessage). The Close and
103103
// WriteControl methods can be called concurrently with all other methods.
104104
//
105+
// Read is Required
106+
//
107+
// The application must read the connection to process ping and close messages
108+
// sent from the peer. If the application is not otherwise interested in
109+
// messages from the peer, then the application should start a goroutine to read
110+
// and discard messages from the peer. A simple example is:
111+
//
112+
// func readLoop(c *websocket.Conn) {
113+
// for {
114+
// if _, _, err := c.NextReader(); err != nil {
115+
// c.Close()
116+
// break
117+
// }
118+
// }
119+
// }
105120
package websocket

0 commit comments

Comments
 (0)