CloseOnError closes the connection.
(code int, reason string)
| 70 | |
| 71 | // CloseOnError closes the connection. |
| 72 | func (c *Client) CloseOnError(code int, reason string) { |
| 73 | c.once.Do(func() { |
| 74 | go func() { |
| 75 | c.read <- ClientMessage{ |
| 76 | Info: c.info, |
| 77 | Incoming: &Disconnected{ |
| 78 | Code: code, |
| 79 | Reason: reason, |
| 80 | }, |
| 81 | } |
| 82 | }() |
| 83 | c.writeCloseMessage(code, reason) |
| 84 | }) |
| 85 | } |
| 86 | |
| 87 | func (c *Client) CloseOnDone(code int, reason string) { |
| 88 | c.once.Do(func() { |
no test coverage detected