From 559c5a8d900dd70e423c8be18f0b2792367fd73a Mon Sep 17 00:00:00 2001 From: Stephan Knauer Date: Mon, 13 Dec 2021 20:47:50 +0100 Subject: [PATCH] Replace writeWait constant with param writeWait on the Shutdown method itself --- recws.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/recws.go b/recws.go index d572630..4faa7af 100644 --- a/recws.go +++ b/recws.go @@ -16,8 +16,6 @@ import ( "github.com/jpillora/backoff" ) -const writeWait = time.Second - // ErrNotConnected is returned when the application read/writes // a message and the connection is closed var ErrNotConnected = errors.New("websocket: not connected") @@ -94,7 +92,8 @@ func (rc *RecConn) Close() { } // Shutdown gracefully closes the connection by sending the websocket.CloseMessage. -func (rc *RecConn) Shutdown() { +// The writeWait param defines the duration before the deadline of the write operation is hit. +func (rc *RecConn) Shutdown(writeWait time.Duration) { msg := websocket.FormatCloseMessage(websocket.CloseNormalClosure, "") err := rc.WriteControl(websocket.CloseMessage, msg, time.Now().Add(writeWait)) if err != nil && err != websocket.ErrCloseSent {