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: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUB  = "sub"
	PING = "ping"
	PONG = "pong"
	AUTH = "auth"
)
View Source
const (
	MaxTryTimes = 5

	TimerIntervalSecond = 5
)
View Source
const (
	GlobalOrderWsBaseURL = "wss://api.hbdm.com/linear-swap-notification"
)

Variables

This section is empty.

Functions

This section is empty.

Types

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) GetCrossAccountUpdateTopic

func (m *AccountWsClient) GetCrossAccountUpdateTopic(marginAccount string) (string, error)

func (*AccountWsClient) GetIsolatedAccountUpdateTopic

func (m *AccountWsClient) GetIsolatedAccountUpdateTopic(contractCode string) (string, error)

func (*AccountWsClient) GetListeners

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

func (*AccountWsClient) GetUnifyAccountUpdateTopic

func (m *AccountWsClient) GetUnifyAccountUpdateTopic() (string, error)

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 AuthRequest

type AuthRequest struct {
	Operation        string `json:"op,omitempty"`
	Type             string `json:"type,omitempty"`
	AccessKeyId      string `json:"AccessKeyId,omitempty"`
	SignatureMethod  string `json:"SignatureMethod,omitempty"`
	SignatureVersion string `json:"SignatureVersion,omitempty"`
	Timestamp        string `json:"Timestamp,omitempty"`
	Signature        string `json:"Signature,omitempty"`
}

type Listener

type Listener func(any)

type Message

type Message struct {
	Operation string `json:"op,omitempty"`
	Topic     string `json:"topic,omitempty"`
	Ts        int64  `json:"ts,omitempty"`

	ErrCode int    `json:"err-code,omitempty"`
	ErrMsg  string `json:"err-msg,omitempty"`

	Raw json.RawMessage `json:"-"`
}

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