22 lines
295 B
Go
22 lines
295 B
Go
package models
|
|
|
|
import "encoding/json"
|
|
|
|
type WSMessage struct {
|
|
Type string `json:"type"`
|
|
}
|
|
|
|
func GetPongByteSlice() []byte {
|
|
b, err := json.Marshal(WSMessage{
|
|
Type: "pong",
|
|
})
|
|
if err != nil {
|
|
return []byte{}
|
|
}
|
|
return b
|
|
}
|
|
|
|
func (w WSMessage) IsPing() bool {
|
|
return w.Type == "ping"
|
|
}
|