Skip to content

Commit

Permalink
Merge pull request amir-the-h#10 from renat1015/main
Browse files Browse the repository at this point in the history
fix and upgrade api ws
  • Loading branch information
amir-the-h authored May 11, 2022
2 parents 4b18bcd + 3bc8580 commit c04f8a9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions api/ws/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,13 @@ func (c *ClientWs) sender(p bool) error {
return err
}
case <-ticker.C:
c.mu[p].Lock()
if c.conn[p] != nil && (c.lastTransmit[p] == nil || (c.lastTransmit[p] != nil && time.Since(*c.lastTransmit[p]) > PingPeriod)) {
go func() {
c.sendChan[p] <- []byte("ping")
}()
}
c.mu[p].Unlock()
case <-c.ctx.Done():
return c.handleCancel("sender")
}
Expand Down
2 changes: 1 addition & 1 deletion api/ws/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (c *Public) UOrderBook(req requests.OrderBook, rCh ...bool) error {
if len(rCh) > 0 && rCh[0] {
c.obCh = nil
}
return c.Unsubscribe(false, []okex.ChannelName{}, m)
return c.Unsubscribe(false, []okex.ChannelName{okex.ChannelName(req.Channel)}, m)
}

// OPTIONSummary
Expand Down
5 changes: 3 additions & 2 deletions events/public/public_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ type (
Limit []*publicdata.LimitPrice `json:"data"`
}
OrderBook struct {
Arg *events.Argument `json:"arg"`
Books []*market.OrderBookWs `json:"data"`
Arg *events.Argument `json:"arg"`
Books []*market.OrderBookWs `json:"data"`
Action string `json:"action"`
}
OPTIONSummary struct {
Arg *events.Argument `json:"arg"`
Expand Down

0 comments on commit c04f8a9

Please sign in to comment.