forked from sonirico/go-hyperliquid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathws_types.go
More file actions
45 lines (37 loc) · 830 Bytes
/
ws_types.go
File metadata and controls
45 lines (37 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package hyperliquid
import (
"encoding/json"
)
//go:generate easyjson -all ws_types.go
type WSMessage struct {
Channel string `json:"channel"`
Data json.RawMessage `json:"data"`
}
type Subscription struct {
Type string `json:"type"`
Coin string `json:"coin,omitempty"`
User string `json:"user,omitempty"`
Interval string `json:"interval,omitempty"`
}
type subKey struct {
typ string
coin string
user string
interval string
}
func (s Subscription) key() subKey {
return subKey{
typ: s.Type,
coin: s.Coin,
user: s.User,
interval: s.Interval,
}
}
type WsCommand struct {
Method string `json:"method"`
Subscription *Subscription `json:"subscription,omitempty"`
}
type subscriptionCallback struct {
id int
callback func(WSMessage)
}