Add CloseWithReason to agent SignalConn interface (#4492)
This commit is contained in:
@@ -32,8 +32,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
pingFrequency = 10 * time.Second
|
||||
pingTimeout = 2 * time.Second
|
||||
pingFrequency = 10 * time.Second
|
||||
pingTimeout = 2 * time.Second
|
||||
closeWriteTimeout = 5 * time.Second
|
||||
)
|
||||
|
||||
type WSSignalConnection struct {
|
||||
@@ -56,6 +57,12 @@ func (c *WSSignalConnection) Close() error {
|
||||
return c.conn.Close()
|
||||
}
|
||||
|
||||
func (c *WSSignalConnection) CloseWithReason(reason string) error {
|
||||
msg := websocket.FormatCloseMessage(websocket.CloseNormalClosure, reason)
|
||||
_ = c.conn.WriteControl(websocket.CloseMessage, msg, time.Now().Add(closeWriteTimeout))
|
||||
return c.conn.Close()
|
||||
}
|
||||
|
||||
func (c *WSSignalConnection) SetReadDeadline(deadline time.Time) error {
|
||||
return c.conn.SetReadDeadline(deadline)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user