client

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusNormal = uint32(1)
	StatusStop   = uint32(2)
)
View Source
const BufferSize4M = 4 * 1024 * 1024
View Source
const DefaultMessageTimeout = time.Minute * 5
View Source
const DefaultPingPeriod = (60 * time.Second * 9) / 10
View Source
const DefaultPongWait = 60 * time.Second
View Source
const DefaultWriteWait = 10 * time.Second

Variables

View Source
var DefaultDialer = websocket.Dialer{
	Proxy:            http.ProxyFromEnvironment,
	HandshakeTimeout: 45 * time.Second,
	ReadBufferSize:   BufferSize4M,
	WriteBufferSize:  BufferSize4M,
	WriteBufferPool:  &sync.Pool{},
}

Functions

This section is empty.

Types

type Client

type Client struct {
	BufferSize           int
	WriteWait            time.Duration
	PingPeriod           time.Duration
	PongWait             time.Duration
	TextMessageHandler   func(message []byte)
	BinaryMessageHandler func(message []byte)
	ErrorHandler         func(err error)
	SendMessageHandler   func(envelope *Envelope)
	// contains filtered or unexported fields
}

func NewClient

func NewClient(conn *websocket.Conn, sendChanLength uint) *Client

func (*Client) Close

func (c *Client) Close()

func (*Client) GetEnvelope

func (c *Client) GetEnvelope() *Envelope

func (*Client) IsRunning

func (c *Client) IsRunning() bool

func (*Client) PutEnvelope

func (c *Client) PutEnvelope(envelope *Envelope)

func (*Client) ReadPump

func (c *Client) ReadPump()

func (*Client) Send

func (c *Client) Send(envelope *Envelope)

func (*Client) WritePump

func (c *Client) WritePump()

type Envelope

type Envelope struct {
	Type int
	Msg  *bytes.Buffer
}

func (*Envelope) Reset

func (e *Envelope) Reset()

type EnvelopePool

type EnvelopePool struct {
	// contains filtered or unexported fields
}
var GlobalEnvelopePool EnvelopePool

func (*EnvelopePool) Get

func (ep *EnvelopePool) Get() *Envelope

func (*EnvelopePool) Put

func (ep *EnvelopePool) Put(epv *Envelope)

type WSAction

type WSAction struct {
	Action string          `json:"action"`
	Args   json.RawMessage `json:"args"`
}

Jump to

Keyboard shortcuts

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