1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2025-02-10 21:43:16 +00:00

wsutil: Make wsutil.GracefulCloser part of wsutil.Connection

This commit is contained in:
Maximilian von Lindern 2021-05-29 21:40:14 +02:00 committed by diamondburned
parent d2b70ebfa7
commit a3a3f5a1b8
2 changed files with 2 additions and 11 deletions

View file

@ -50,11 +50,6 @@ type Connection interface {
// may be reused, but this Connection instance will be reused with Dial. The
// Connection must still be reusable even if Close returns an error.
Close() error
}
// GracefulCloser is an interface used by Connections that support graceful
// closure of their websocket connection.
type GracefulCloser interface {
// CloseGracefully sends a close frame and then closes the websocket
// connection.
CloseGracefully() error

View file

@ -179,12 +179,8 @@ func (ws *Websocket) close(graceful bool) error {
ws.closed = true
if graceful {
if gc, ok := ws.conn.(GracefulCloser); ok {
WSDebug("Conn: Closing gracefully")
return gc.CloseGracefully()
}
WSDebug("Conn: The Websocket's Connection does not support graceful closure.")
WSDebug("Conn: Closing gracefully")
return ws.conn.CloseGracefully()
}
WSDebug("Conn: Closing")