resc

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

that will automatically reconnect if the connection is dropped.

Index

Constants

This section is empty.

Variables

View Source
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
	// NonVerbose suppress connecting/reconnecting messages.
	NonVerbose bool
	// KeepAliveTimeout is an interval for sending ping/pong messages
	// disabled if 0
	KeepAliveTimeout time.Duration
	DialTimeOut      time.Duration
	// 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) Closed

func (rc *ReSocket) Closed() <-chan bool

func (*ReSocket) Connected

func (rc *ReSocket) Connected() <-chan struct{}

func (*ReSocket) Dial

func (rc *ReSocket) Dial(ipAddress string)

Dial creates a new client connection.

func (*ReSocket) GetConn

func (rc *ReSocket) GetConn() net.Conn

GetConn returns current connection connection

func (*ReSocket) GetDialError

func (rc *ReSocket) GetDialError() error

GetDialError returns the last dialer error. nil on successful connection.

func (*ReSocket) GetIPAddress

func (rc *ReSocket) GetIPAddress() string

GetIPAddress returns current connection IPAddress

func (*ReSocket) IsConnected

func (rc *ReSocket) IsConnected() bool

IsConnected returns the WebSocket connection state

func (*ReSocket) WriteMessage

func (rc *ReSocket) WriteMessage(data []byte) error

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL