market

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: May 15, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConnectionClosedError = fmt.Errorf("websocket connection closed")

ConnectionClosedError Websocket未连接错误

View Source
var Endpoint = "wss://api.huobi.pro/ws"

Endpoint 行情的Websocket入口

View Source
var SafeWebSocketDestroyError = fmt.Errorf("connection destroy by user")

Functions

This section is empty.

Types

type Listener

type Listener = func(topic string, json *simplejson.Json)

Listener 订阅事件监听器

type Market

type Market struct {

	// 主动发送心跳的时间间隔,默认5秒
	HeartbeatInterval time.Duration
	// 接收消息超时时间,默认10秒
	ReceiveTimeout time.Duration
	// contains filtered or unexported fields
}

func NewMarket

func NewMarket() (m *Market, err error)

NewMarket 创建Market实例

func (*Market) Close

func (m *Market) Close() error

Close 关闭连接

func (*Market) Loop

func (m *Market) Loop()

Loop 进入循环

func (*Market) ReConnect

func (m *Market) ReConnect() (err error)

ReConnect 重新连接

func (*Market) Request

func (m *Market) Request(req string) (*simplejson.Json, error)

Request 请求行情信息

func (*Market) Subscribe

func (m *Market) Subscribe(topic string, listener Listener) error

Subscribe 订阅

func (*Market) Unsubscribe

func (m *Market) Unsubscribe(topic string)

Unsubscribe 取消订阅

type SafeWebSocket added in v1.0.3

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

SafeWebSocket 安全的WebSocket封装 保证读取和发送操作是并发安全的,支持自定义保持alive函数

func NewSafeWebSocket added in v1.0.3

func NewSafeWebSocket(endpoint string) (*SafeWebSocket, error)

NewSafeWebSocket 创建安全的WebSocket实例并连接

func (*SafeWebSocket) Destroy added in v1.0.3

func (s *SafeWebSocket) Destroy() (err error)

Destroy 销毁

func (*SafeWebSocket) KeepAlive added in v1.0.3

KeepAlive 设置alive周期及函数

func (*SafeWebSocket) Listen added in v1.0.3

Listen 监听消息

func (*SafeWebSocket) Loop added in v1.0.3

func (s *SafeWebSocket) Loop() error

Loop 进入事件循环,直到连接关闭才退出

func (*SafeWebSocket) Send added in v1.0.3

func (s *SafeWebSocket) Send(b []byte)

Send 发送消息

type SafeWebSocketAliveHandler added in v1.0.3

type SafeWebSocketAliveHandler = func()

type SafeWebSocketMessageListener added in v1.0.3

type SafeWebSocketMessageListener = func(b []byte)

Jump to

Keyboard shortcuts

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