Close closes the melody instance and all connected sessions.
()
| 264 | |
| 265 | // Close closes the melody instance and all connected sessions. |
| 266 | func (m *Melody) Close() error { |
| 267 | if m.hub.closed() { |
| 268 | return ErrClosed |
| 269 | } |
| 270 | |
| 271 | m.hub.exit(envelope{t: websocket.CloseMessage, msg: []byte{}}) |
| 272 | |
| 273 | return nil |
| 274 | } |
| 275 | |
| 276 | // CloseWithMsg closes the melody instance with the given close payload and all connected sessions. |
| 277 | // Use the FormatCloseMessage function to format a proper close message payload. |