ws

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectType

type ConnectType int
const (
	Connect ConnectType = iota
	Reconnect
)

type WsClient

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

func NewWsClient

func NewWsClient(url string, imp WsImp, exchangeType constant.ExchangeType, pingInterval, pongTimeout time.Duration) *WsClient

NewWsClient 新建Ws客户端

func (*WsClient) Close

func (ws *WsClient) Close()

func (*WsClient) Dial

func (ws *WsClient) Dial(typ ConnectType) error

func (*WsClient) SetPingInterval

func (ws *WsClient) SetPingInterval(t time.Duration)

func (*WsClient) SetRecvPingTime

func (ws *WsClient) SetRecvPingTime(t time.Time)

func (*WsClient) SetRecvPongTime

func (ws *WsClient) SetRecvPongTime(t time.Time)

func (*WsClient) SetpPongTimeout

func (ws *WsClient) SetpPongTimeout(t time.Duration)

func (*WsClient) WatchClosed

func (ws *WsClient) WatchClosed()

用于监控ws是否断开

func (*WsClient) Write

func (ws *WsClient) Write(req interface{}) error

func (*WsClient) WriteBytes

func (ws *WsClient) WriteBytes(bs []byte)

type WsImp

type WsImp interface {
	OnConnected(*WsClient, ConnectType)
	Handle(*WsClient, []byte)
	Ping(*WsClient)
}

Jump to

Keyboard shortcuts

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