You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
444 B
25 lines
444 B
2 months ago
|
package model
|
||
|
|
||
|
import "encoding/json"
|
||
|
|
||
|
type PingV2Message struct {
|
||
|
Action string `json:"action"`
|
||
|
Data *struct {
|
||
|
Timestamp int64 `json:"ts"`
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (p *PingV2Message) IsPing() bool {
|
||
|
return p != nil && p.Action == "ping" && p.Data.Timestamp != 0
|
||
|
}
|
||
|
|
||
|
func ParsePingV2Message(message string) *PingV2Message {
|
||
|
result := PingV2Message{}
|
||
|
err := json.Unmarshal([]byte(message), &result)
|
||
|
if err != nil {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
return &result
|
||
|
}
|