MCPcopy
hub / github.com/olahol/melody / Close

Method Close

melody.go:266–274  ·  view source on GitHub ↗

Close closes the melody instance and all connected sessions.

()

Source from the content-addressed store, hash-verified

264
265// Close closes the melody instance and all connected sessions.
266func (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.

Callers 15

exitMethod · 0.45
TestEchoFunction · 0.45
TestEchoBinaryFunction · 0.45
TestWriteClosedServerFunction · 0.45
TestWriteClosedClientFunction · 0.45
TestUpgraderFunction · 0.45
TestBroadcastFunction · 0.45
TestCloseFunction · 0.45
TestLenFunction · 0.45
TestSessionsFunction · 0.45
TestPingPongFunction · 0.45
TestHandleCloseFunction · 0.45

Calls 2

exitMethod · 0.80
closedMethod · 0.45

Tested by 15

TestEchoFunction · 0.36
TestEchoBinaryFunction · 0.36
TestWriteClosedServerFunction · 0.36
TestWriteClosedClientFunction · 0.36
TestUpgraderFunction · 0.36
TestBroadcastFunction · 0.36
TestCloseFunction · 0.36
TestLenFunction · 0.36
TestSessionsFunction · 0.36
TestPingPongFunction · 0.36
TestHandleCloseFunction · 0.36
TestHandleErrorFunction · 0.36