websocket

package
v0.3.14 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChnlFuturesPriceRange = "futures/price_range" // 限价范围频道
	ChnlFuturesDepth5     = "futures/depth5"      // 深度数据频道,每次返回前5档
	ChnlFuturesPosition   = "futures/position"    // 用户持仓信息频道
	ChnlFuturesOrder      = "futures/order"       // 用户交易数据频道
)
View Source
const (
	EventTypeLogin       = "login"
	EventTypeSubscribe   = "subscribe"
	EventTypeUnsubscribe = "unsubscribe"
	EventTypeError       = "error"
)
View Source
const (
	ErrorInvalidSign = 30013
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(endpoint, apiKey, secretKey, password string, topics []string, handler MessageHandler) *Client

NewClient json: 返回json数据还是struct数据

func (*Client) Close

func (c *Client) Close()

func (*Client) Connect

func (c *Client) Connect() error

Connect 连接, 登录(如果有密码), 订阅

func (*Client) Connected

func (c *Client) Connected() bool

func (*Client) Subscribe

func (c *Client) Subscribe(topics []string) error

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(topics []string) error

type EventError

type EventError struct {
	Event     string `json:"event"`
	Message   string `json:"message"`
	ErrorCode int    `json:"errorCode"`
}

type EventLogin

type EventLogin struct {
	Event   string `json:"event"`
	Success bool   `json:"success"`
}

type EventSubscribe

type EventSubscribe struct {
	Event   string `json:"event"`
	Channel string `json:"channel"`
}

type EventUnsubscribe

type EventUnsubscribe struct {
	Event   string `json:"event"`
	Channel string `json:"channel"`
}

type MessageHandler

type MessageHandler func(message *TableMessage)

type TableMessage

type TableMessage struct {
	Action string      `json:"action"`
	Table  string      `json:"table"`
	Data   interface{} `json:"data"`
}

Jump to

Keyboard shortcuts

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