mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-30 18:53:30 +00:00
session,bot: Remove references to CloseGracefully and use Close instead
This commit is contained in:
parent
6c2fb008eb
commit
8a7c6c48a7
|
@ -385,12 +385,6 @@ func (ctx *Context) Start() func() {
|
|||
})
|
||||
}
|
||||
|
||||
// Close closes the gateway gracefully. Bots that need to preserve the session
|
||||
// ID after closing should NOT use this method.
|
||||
func (ctx *Context) Close() error {
|
||||
return ctx.Session.CloseGracefully()
|
||||
}
|
||||
|
||||
// Call should only be used if you know what you're doing.
|
||||
func (ctx *Context) Call(event interface{}) error {
|
||||
return ctx.callCmd(event)
|
||||
|
|
|
@ -135,24 +135,22 @@ func (s *Session) WithContext(ctx context.Context) *Session {
|
|||
return &cpy
|
||||
}
|
||||
|
||||
// Close closes the gateway. The connection is still resumable with the given
|
||||
// session ID.
|
||||
// Close closes the underlying Websocket connection, invalidating the session
|
||||
// ID.
|
||||
//
|
||||
// It will send a closing frame before ending the connection, closing it
|
||||
// gracefully. This will cause the bot to appear as offline instantly.
|
||||
func (s *Session) Close() error {
|
||||
return s.close(false)
|
||||
}
|
||||
|
||||
// CloseGracefully permanently closes the gateway. The session ID is invalidated
|
||||
// afterwards.
|
||||
func (s *Session) CloseGracefully() error {
|
||||
return s.close(true)
|
||||
}
|
||||
|
||||
func (s *Session) close(gracefully bool) error {
|
||||
// Stop the event handler
|
||||
s.looper.Stop()
|
||||
// Close the websocket
|
||||
if gracefully {
|
||||
return s.Gateway.CloseGracefully()
|
||||
}
|
||||
return s.Gateway.Close()
|
||||
}
|
||||
|
||||
// Pause pauses the Gateway connection, by ending the connection without
|
||||
// sending a closing frame. This allows the connection to be resumed at a later
|
||||
// point.
|
||||
func (s *Session) Pause() error {
|
||||
// Stop the event handler
|
||||
s.looper.Stop()
|
||||
return s.Gateway.Pause()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue