websocket

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConnectionTimeoutInSec      = 10
	WriteToChannelTimeoutInMS   = 1000
	RetryConnectionDurationInMS = 3000
)
View Source
const (
	ConnectionTimeout = 10
)

Variables

This section is empty.

Functions

func NewClientWithReconnect

func NewClientWithReconnect(opt *Option)

Types

type Client

type Client struct {
	sync.Once

	Context    context.Context
	CancelFunc context.CancelFunc
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opt *Option) (*Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) Option

func (c *Client) Option() *Option

type Connections

type Connections struct {
	// contains filtered or unexported fields
}

func NewConnections

func NewConnections(ctx context.Context) *Connections

func (*Connections) Handler

func (cs *Connections) Handler(w http.ResponseWriter, r *http.Request, handler handler.Interface)

func (*Connections) SendToAll

func (cs *Connections) SendToAll(data []byte)

func (*Connections) SendToOne

func (cs *Connections) SendToOne(data []byte, id int32) bool

type Option

type Option struct {
	Hostname string
	Address  string
	Path     string
	Status   OptionStatus

	Maintain      OptionMaintainType
	MaxRetryCount int64
	// RetryDuration was the wait time in Millisecond
	RetryDuration int64
	// contains filtered or unexported fields
}

func NewOption

func NewOption(ctx context.Context, hostname string, address string, path string, pingData []byte) *Option

func (*Option) Cancel

func (o *Option) Cancel()

func (*Option) ChangeStatus

func (o *Option) ChangeStatus(s OptionStatus)

func (*Option) Done

func (o *Option) Done() <-chan struct{}

func (*Option) Next

func (o *Option) Next() bool

func (*Option) Prepare

func (o *Option) Prepare() error

func (*Option) Read

func (o *Option) Read() <-chan []byte

func (*Option) RegisterFunc

func (o *Option) RegisterFunc(do ...OptionRegisterFunction)

func (*Option) Send

func (o *Option) Send(in []byte) error

func (*Option) SetMaxRetryCount

func (o *Option) SetMaxRetryCount(in int64)

type OptionMaintainType

type OptionMaintainType string
const (
	OptionMaintainOnce  OptionMaintainType = "once"
	OptionMaintainRetry OptionMaintainType = "retry"
)

type OptionRegisterFunction

type OptionRegisterFunction func() error

type OptionStatus

type OptionStatus string
const (
	OptionActive   OptionStatus = "active"
	OptionInActive OptionStatus = "inactive"
	OptionClosed   OptionStatus = "closed"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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