2
0

Replace writeWait constant with param writeWait on the Shutdown method itself

This commit is contained in:
Stephan Knauer
2021-12-13 20:47:50 +01:00
parent d31f6143c1
commit 559c5a8d90
+2 -3
View File
@@ -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 {