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.

22 lines
413 B

package model
import "encoding/json"
type PingV1Message struct {
Op string `json:"op"`
Timestamp int64 `json:"ts"`
}
func (p *PingV1Message) IsPing() bool {
return p != nil && p.Op == "ping" && p.Timestamp != 0
}
func ParsePingV1Message(message string) *PingV1Message {
result := PingV1Message{}
err := json.Unmarshal([]byte(message), &result)
if err != nil {
return nil
}
return &result
}