accountws

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GlobalWsBaseURL       = "wss://api.huobi.pro/ws/v2"
	GlobalWsBaseURLForAWS = "wss://api-aws.huobi.pro/ws/v2"
)
View Source
const (
	MaxTryTimes = 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountUpdateTopicParam

type AccountUpdateTopicParam struct {
	Mode int `validate:"required,oneof=0 1 2"`
}

type AccountWsClient

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

func NewAccountWsClient

func NewAccountWsClient(cfg *AccountWsClientCfg) (*AccountWsClient, error)

func (*AccountWsClient) AddListener

func (m *AccountWsClient) AddListener(event string, listener Listener) *emission.Emitter

func (*AccountWsClient) Close

func (m *AccountWsClient) Close() error

func (*AccountWsClient) GetAccountUpdateTopic

func (m *AccountWsClient) GetAccountUpdateTopic(params *AccountUpdateTopicParam) (string, error)

func (*AccountWsClient) GetListeners

func (m *AccountWsClient) GetListeners(event string, argument any) *emission.Emitter

func (*AccountWsClient) IsConnected

func (m *AccountWsClient) IsConnected() bool

IsConnected returns the WebSocket connection state

func (*AccountWsClient) Open

func (m *AccountWsClient) Open() error

func (*AccountWsClient) RemoveListener

func (m *AccountWsClient) RemoveListener(event string, listener Listener) *emission.Emitter

func (*AccountWsClient) Subscribe

func (m *AccountWsClient) Subscribe(topic string) error

func (*AccountWsClient) UnSubscribe

func (m *AccountWsClient) UnSubscribe(topic string) error

type AccountWsClientCfg

type AccountWsClientCfg struct {
	Debug         bool
	BaseURL       string `validate:"required"`
	AutoReconnect bool   `validate:"required"`

	Key    string `validate:"required"`
	Secret string `validate:"required"`

	Logger *slog.Logger
}

type ActionType

type ActionType = string
const (
	SUB   ActionType = "sub"
	UNSUB ActionType = "unsub"
	REQ   ActionType = "req"
	PING  ActionType = "ping"
	PONG  ActionType = "pong"
	PUSH  ActionType = "push"
)

type AuthParams

type AuthParams struct {
	AuthType         string `json:"authType,omitempty"`
	AccessKey        string `json:"accessKey,omitempty"`
	SignatureMethod  string `json:"signatureMethod,omitempty"`
	SignatureVersion string `json:"signatureVersion,omitempty"`
	Timestamp        string `json:"timestamp,omitempty"`
	Signature        string `json:"signature,omitempty"`
}

type AuthRequest

type AuthRequest struct {
	Action  ActionType `json:"action,omitempty"`
	Channel string     `json:"ch,omitempty"`
	Params  AuthParams `json:"params,omitempty"`
}

type Listener

type Listener func(any)

type Message

type Message struct {
	Action  ActionType      `json:"action,omitempty"`
	Channel string          `json:"ch,omitempty"`
	Code    int             `json:"code,omitempty"`
	Data    json.RawMessage `json:"data,omitempty"`
}

func (*Message) UnmarshalJSON

func (m *Message) UnmarshalJSON(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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