wsclient

package
v0.0.0-...-ade9fc0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TAddress

type TAddress struct {
	Name     string
	NeedAuth bool
	U        url.URL
}

TAddress websocket address to connect

type TWSClient

type TWSClient struct {

	// DoAfterOpenSuccess will be called after connect to server success.
	// If err != nil, will disconnect to the server.
	DoAfterOpenSuccess func(serverName string, curAddr *TAddress, conn *websocket.Conn) error

	ServerBinaryMsgChan chan []byte
	ServerTextMsgChan   chan []byte
	// contains filtered or unexported fields
}

TWSClient websocket client

func New

func New(serverName string, serverAddrs []*TAddress) *TWSClient

New create a new websocket client

func (*TWSClient) AddHeader

func (c *TWSClient) AddHeader(header http.Header)

AddHeader add http header

func (*TWSClient) IsOnline

func (c *TWSClient) IsOnline() bool

IsOnline websocket client is connected to websocket server.

func (*TWSClient) SendBinary

func (c *TWSClient) SendBinary(data []byte) error

SendBinary send binary data

func (*TWSClient) SendBinaryBlock

func (c *TWSClient) SendBinaryBlock(data []byte) error

SendBinaryBlock send binary data

func (*TWSClient) SendBinaryWithTimeout

func (c *TWSClient) SendBinaryWithTimeout(data []byte, d time.Duration) error

SendBinaryWithTimeout send binary data with timeout

func (*TWSClient) SendJSON

func (c *TWSClient) SendJSON(v interface{}) error

SendJSON send json data

func (*TWSClient) SendJSONBlock

func (c *TWSClient) SendJSONBlock(v interface{}) error

SendJSONBlock send json data

func (*TWSClient) SendJSONWithTimeout

func (c *TWSClient) SendJSONWithTimeout(v interface{}, d time.Duration) error

SendJSONWithTimeout send json data with timeout

func (*TWSClient) SendText

func (c *TWSClient) SendText(data []byte) error

SendText send text data

func (*TWSClient) SendTextBlock

func (c *TWSClient) SendTextBlock(data []byte) error

SendTextBlock send text data

func (*TWSClient) SendTextWithTimeout

func (c *TWSClient) SendTextWithTimeout(data []byte, d time.Duration) error

SendTextWithTimeout send text data with timeout

func (*TWSClient) SetProxyAddr

func (c *TWSClient) SetProxyAddr(addr string)

SetProxyAddr set proxy address

func (*TWSClient) SetTimeOutHandShake

func (c *TWSClient) SetTimeOutHandShake(d time.Duration)

SetTimeOutHandShake set websocket connection handshake timeout.

func (*TWSClient) SetTimeOutPing

func (c *TWSClient) SetTimeOutPing(t int64)

SetTimeOutPing set websocket send ping period. c.pingPeriod must be smaller than c.pongWait

func (*TWSClient) SetTimeOutRetry

func (c *TWSClient) SetTimeOutRetry(d time.Duration)

SetTimeOutRetry set retry to connect to server timeout.

func (*TWSClient) SetTimeoutRead

func (c *TWSClient) SetTimeoutRead(d time.Duration)

SetTimeoutRead set websocket read message timeout.

func (*TWSClient) SetTimeoutWrite

func (c *TWSClient) SetTimeoutWrite(d time.Duration)

SetTimeoutWrite set websocket write message timeout.

func (*TWSClient) Start

func (c *TWSClient) Start()

Start start websocket client

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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