Skip to content

Commit

Permalink
feat: htx usdm ws apis
Browse files Browse the repository at this point in the history
  • Loading branch information
linstohu committed Dec 20, 2023
1 parent 19fd19c commit a71660f
Show file tree
Hide file tree
Showing 20 changed files with 1,705 additions and 3 deletions.
6 changes: 4 additions & 2 deletions htx/spot/marketws/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ func (m *MarketWsClient) readMessages() {

switch {
case msg.Ping != nil:
err := m.pong(msg.Ping)
err := m.pong(&PongMessage{
Pong: msg.Ping.Ping,
})
if err != nil {
m.logger.Error(fmt.Sprintf("handle ping error: %s", err.Error()))
}
Expand Down Expand Up @@ -327,7 +329,7 @@ func (m *MarketWsClient) send(req *Request) error {
return m.conn.WriteJSON(req)
}

func (m *MarketWsClient) pong(ping *PingMessage) error {
func (m *MarketWsClient) pong(ping *PongMessage) error {
m.sending.Lock()

// Rate Limit: https://www.htx.com/en-us/opend/newApiPages/?id=662
Expand Down
4 changes: 4 additions & 0 deletions htx/spot/marketws/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ type PingMessage struct {
Ping int64 `json:"ping,omitempty"`
}

type PongMessage struct {
Pong int64 `json:"pong,omitempty"`
}

type Response struct {
ID string `json:"id,omitempty"`
Status string `json:"status,omitempty"`
Expand Down
Loading

0 comments on commit a71660f

Please sign in to comment.