modify websocketserver to broker with callback functions
This commit is contained in:
21
websocket/models/wsMessage.go
Normal file
21
websocket/models/wsMessage.go
Normal file
@@ -0,0 +1,21 @@
|
||||
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"
|
||||
}
|
Reference in New Issue
Block a user