Skip to content

Commit bb547c6

Browse files
committed
Improve SetXHandler documentation
1 parent 561ac01 commit bb547c6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

conn.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,15 @@ func (c *Conn) CloseHandler() func(code int, text string) error {
981981
// The code argument to h is the received close code or CloseNoStatusReceived
982982
// if the close message is empty. The default close handler sends a close frame
983983
// back to the peer.
984+
//
985+
// The application must read the connection to process close messages as
986+
// described in the section on Control Frames above.
987+
//
988+
// The connection read methods return a CloseError when a close frame is
989+
// received. Most applications should handle close messages as part of their
990+
// normal error handling. Applications should only set a close handler when the
991+
// application must perform some action before sending a close frame back to
992+
// the peer.
984993
func (c *Conn) SetCloseHandler(h func(code int, text string) error) {
985994
if h == nil {
986995
h = func(code int, text string) error {
@@ -1003,6 +1012,9 @@ func (c *Conn) PingHandler() func(appData string) error {
10031012
// SetPingHandler sets the handler for ping messages received from the peer.
10041013
// The appData argument to h is the PING frame application data. The default
10051014
// ping handler sends a pong to the peer.
1015+
//
1016+
// The application must read the connection to process ping messages as
1017+
// described in the section on Control Frames above.
10061018
func (c *Conn) SetPingHandler(h func(appData string) error) {
10071019
if h == nil {
10081020
h = func(message string) error {
@@ -1026,6 +1038,9 @@ func (c *Conn) PongHandler() func(appData string) error {
10261038
// SetPongHandler sets the handler for pong messages received from the peer.
10271039
// The appData argument to h is the PONG frame application data. The default
10281040
// pong handler does nothing.
1041+
//
1042+
// The application must read the connection to process ping messages as
1043+
// described in the section on Control Frames above.
10291044
func (c *Conn) SetPongHandler(h func(appData string) error) {
10301045
if h == nil {
10311046
h = func(string) error { return nil }

0 commit comments

Comments
 (0)