Documentation
¶
Index ¶
- type BackoffType
- type Event
- type EventType
- type Logger
- type Resws
- func (r *Resws) Close()
- func (r *Resws) CloseAndReconnect()
- func (r *Resws) Dial(url string)
- func (r *Resws) GetHTTPResponse() *http.Response
- func (r *Resws) IsConnected() bool
- func (r *Resws) LastConnectTime() time.Time
- func (r *Resws) LastError() error
- func (r *Resws) OnConnected(fn func(url string))
- func (r *Resws) OnError(fn func(err error))
- func (r *Resws) OnReconnecting(fn func(time.Duration))
- func (r *Resws) ReadJSON(v any) (err error)
- func (r *Resws) ReadMessage() (msgType int, msg []byte, err error)
- func (r *Resws) Send(msg []byte) error
- func (r *Resws) SendJSON(v any) (err error)
- func (r *Resws) WriteJSON(v any) (err error)
- func (r *Resws) WriteMessage(msgType int, msg []byte) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackoffType ¶ added in v0.1.1
type BackoffType int
const ( BackoffTypeJitter BackoffType = iota BackoffTypeFixed )
type Resws ¶
type Resws struct {
// RecBackoffMin is the minimum backoff duration between reconnection attempts
RecBackoffMin time.Duration
// RecBackoffMax is the maximum backoff duration between reconnection attempts
RecBackoffMax time.Duration
// RecBackoffFactor is the factor by which the backoff duration is multiplied
RecBackoffFactor float64
// BackoffType is the type of backoff to use
BackoffType BackoffType
// StableConnectionDuration is the duration a connection must be stable before resetting backoff
StableConnectionDuration time.Duration
// Handshake timeout
HandshakeTimeout time.Duration
// Headers to be sent with the connection
Headers http.Header
// Ping interval
PingInterval time.Duration
// Pong timeout
PongTimeout time.Duration
// Read deadline
ReadDeadline time.Duration
// Write deadline
WriteDeadline time.Duration
// Message queue size
MessageQueueSize int
// TLS configuration
TLSConfig *tls.Config
// Proxy configuration
Proxy func(*http.Request) (*url.URL, error)
// Logger
Logger Logger
// Non-verbose mode
NonVerbose bool
// Subscribe handler
SubscribeHandler func() error
// Message handler
MessageHandler func(int, []byte)
// Ping handler
PingHandler func()
*websocket.Conn
// contains filtered or unexported fields
}
func (*Resws) CloseAndReconnect ¶
func (r *Resws) CloseAndReconnect()
CloseAndReconnect closes the connection and starts a reconnection attempt with backoff
func (*Resws) GetHTTPResponse ¶
GetHTTPResponse returns the HTTP response
func (*Resws) IsConnected ¶
IsConnected returns the connection state
func (*Resws) LastConnectTime ¶
LastConnectTime returns the last connection time
func (*Resws) OnConnected ¶
OnConnected sets the connected handler
func (*Resws) OnReconnecting ¶
OnReconnecting sets the reconnection handler
func (*Resws) ReadMessage ¶
ReadMessage manually reads a message from the websocket connection
Directories
¶
| Path | Synopsis |
|---|---|
|
example
|
|
|
auth_header
command
|
|
|
basic
command
|
|
|
dynamic_subscriptions
command
|
|
|
subscribe
command
|
Click to show internal directories.
Click to hide internal directories.