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:
parent
d2b70ebfa7
commit
a3a3f5a1b8
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue