/
gateway_payload.go
45 lines (38 loc) · 988 Bytes
/
gateway_payload.go
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 sonya
import (
"encoding/json"
"time"
)
type gwPayload struct {
Opcode int `json:"op"`
DataRaw json.RawMessage `json:"d"`
SequenceNumber *int `json:"s,omitempty"`
Type *string `json:"t,omitempty"`
Data any `json:"-"`
}
type plHello struct {
HeartbeatInterval time.Duration `json:"heartbeat_interval"`
}
func (p *plHello) UnmarshalJSON(data []byte) error {
j := &struct {
HeartbeatInterval int64 `json:"heartbeat_interval"`
}{}
if err := json.Unmarshal(data, &j); err != nil {
return err
}
p.HeartbeatInterval = time.Duration(j.HeartbeatInterval) * time.Millisecond
return nil
}
type plIdentify struct {
Token string `json:"token"`
Intents int `json:"intents"`
Properties struct {
OS string `json:"$os"`
Browser string `json:"$browser"`
Device string `json:"$device"`
} `json:"properties"`
}
type plHeartbeat struct {
}
type plHeartbeatACK struct {
}