SetCloseHandler sets the handler for close messages received from the peer. The code argument to h is the received close code or CloseNoStatusReceived if the close message is empty. The default close handler sends a close message back to the peer. The handler function is called from the NextReader,
(h func(code int, text string) error)
| 1133 | // application must perform some action before sending a close message back to |
| 1134 | // the peer. |
| 1135 | func (c *Conn) SetCloseHandler(h func(code int, text string) error) { |
| 1136 | if h == nil { |
| 1137 | h = func(code int, text string) error { |
| 1138 | message := FormatCloseMessage(code, "") |
| 1139 | c.WriteControl(CloseMessage, message, time.Now().Add(writeWait)) |
| 1140 | return nil |
| 1141 | } |
| 1142 | } |
| 1143 | c.handleClose = h |
| 1144 | } |
| 1145 | |
| 1146 | // PingHandler returns the current ping handler |
| 1147 | func (c *Conn) PingHandler() func(appData string) error { |
no test coverage detected