Improve control message handling documentation

Closes #299
This commit is contained in:
Gary Burd 2017-11-19 13:55:18 -08:00
parent 7ca4275b84
commit aa5ed01c91
1 changed files with 17 additions and 11 deletions

28
doc.go
View File

@ -86,20 +86,26 @@
// and pong. Call the connection WriteControl, WriteMessage or NextWriter // and pong. Call the connection WriteControl, WriteMessage or NextWriter
// methods to send a control message to the peer. // methods to send a control message to the peer.
// //
// Connections handle received close messages by sending a close message to the // Connections handle received close messages by calling the handler function
// peer and returning a *CloseError from the the NextReader, ReadMessage or the // set with the SetCloseHandler method and by returning a *CloseError from the
// message Read method. // NextReader, ReadMessage or the message Read method. The default close
// handler sends a close message to the peer.
// //
// Connections handle received ping and pong messages by invoking callback // Connections handle received ping messages by calling the handler function
// functions set with SetPingHandler and SetPongHandler methods. The callback // set with the SetPingHandler method. The default ping handler sends a pong
// functions are called from the NextReader, ReadMessage and the message Read // message to the peer.
// methods.
// //
// The default ping handler sends a pong to the peer. The application's reading // Connections handle received pong messages by calling the handler function
// goroutine can block for a short time while the handler writes the pong data // set with the SetPongHandler method. The default pong handler does nothing.
// to the connection. // If an application sends ping messages, then the application should set a
// pong handler to receive the corresponding pong.
// //
// The application must read the connection to process ping, pong and close // The control message handler functions are called from the NextReader,
// ReadMessage and message reader Read methods. The default close and ping
// handlers can block these methods for a short time when the handler writes to
// the connection.
//
// The application must read the connection to process close, ping and pong
// messages sent from the peer. If the application is not otherwise interested // messages sent from the peer. If the application is not otherwise interested
// in messages from the peer, then the application should start a goroutine to // in messages from the peer, then the application should start a goroutine to
// read and discard messages from the peer. A simple example is: // read and discard messages from the peer. A simple example is: