Close closes the WebSocket with the given code and reason. It will wait until the peer responds with a close frame or the connection is closed. It thus performs the full WebSocket close handshake.
(code StatusCode, reason string)
| 229 | // or the connection is closed. |
| 230 | // It thus performs the full WebSocket close handshake. |
| 231 | func (c *Conn) Close(code StatusCode, reason string) error { |
| 232 | err := c.exportedClose(code, reason) |
| 233 | if err != nil { |
| 234 | return fmt.Errorf("failed to close WebSocket: %w", err) |
| 235 | } |
| 236 | return nil |
| 237 | } |
| 238 | |
| 239 | // CloseNow closes the WebSocket connection without attempting a close handshake. |
| 240 | // Use when you do not want the overhead of the close handshake. |
no test coverage detected