Documentation
¶
Overview ¶
that will automatically reconnect if the connection is dropped.
Index ¶
- Variables
- type ReSocket
- func (rc *ReSocket) Close()
- func (rc *ReSocket) CloseAndReconnect()
- func (rc *ReSocket) Dial(ipAddress string)
- func (rc *ReSocket) GetConn() net.Conn
- func (rc *ReSocket) GetDialError() error
- func (rc *ReSocket) GetIPAddress() string
- func (rc *ReSocket) IsConnected() bool
- func (rc *ReSocket) WriteMessage(data []byte) error
Constants ¶
This section is empty.
Variables ¶
var ErrNotConnected = errors.New("socket: not connected")
ErrNotConnected is returned when the application read/writes a message and the connection is closed
Functions ¶
This section is empty.
Types ¶
type ReSocket ¶
type ReSocket struct {
// RecIntvlMin specifies the initial reconnecting interval,
// default to 2 seconds
RecIntvlMin time.Duration
// RecIntvlMax specifies the maximum reconnecting interval,
// default to 30 seconds
RecIntvlMax time.Duration
// RecIntvlFactor specifies the rate of increase of the reconnection
// interval, default to 1.5
RecIntvlFactor float64
// DialTimeOut specifies the duration for the dial to complete,
// default to 10 seconds
DialTimeOut time.Duration
// KeepAliveTimeout is an interval for sending ping/pong messages
// disabled if 0
KeepAliveTimeout time.Duration
// NonVerbose suppress connecting/reconnecting messages.
NonVerbose bool
// contains filtered or unexported fields
}
The ReSocket type represents a Reconnecting Socket connection.
func (*ReSocket) Close ¶
func (rc *ReSocket) Close()
Close closes the underlying network connection without sending or waiting for a close frame.
func (*ReSocket) CloseAndReconnect ¶
func (rc *ReSocket) CloseAndReconnect()
CloseAndReconnect will try to reconnect.
func (*ReSocket) GetDialError ¶
GetDialError returns the last dialer error. nil on successful connection.
func (*ReSocket) GetIPAddress ¶
GetIPAddress returns current connection IPAddress
func (*ReSocket) IsConnected ¶
IsConnected returns the WebSocket connection state
func (*ReSocket) WriteMessage ¶
WriteMessage is a helper method for getting a writer using NextWriter, writing the message and closing the writer.
If the connection is closed ErrNotConnected is returned