- Replaced the existing `github.com/coder/websocket` package with `github.com/gorilla/websocket` for improved functionality and compatibility. - Adjusted WebSocket connection handling, including message reading and writing, to align with the new library's API. - Enhanced error handling and logging for WebSocket operations. - Bumped version to v0.20.0 to reflect the changes made.
26 lines
519 B
Go
26 lines
519 B
Go
//go:build !js
|
|
|
|
package ws
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/gorilla/websocket"
|
|
)
|
|
|
|
func getConnectionOptions(
|
|
requestHeader http.Header, tlsConfig *tls.Config,
|
|
) *websocket.Dialer {
|
|
dialer := &websocket.Dialer{
|
|
ReadBufferSize: 1024,
|
|
WriteBufferSize: 1024,
|
|
TLSClientConfig: tlsConfig,
|
|
HandshakeTimeout: 10 * time.Second,
|
|
}
|
|
// Headers are passed directly to DialContext, not set on Dialer
|
|
// The User-Agent header will be set when calling DialContext if not present
|
|
return dialer
|
|
}
|