Nexus/pkg/nex/ws.go
2024-10-19 22:36:33 +08:00

21 lines
400 B
Go

package nex
import "github.com/goccy/go-json"
type WebSocketPackage struct {
Action string `json:"w"`
Endpoint string `json:"e,omitempty"`
Message string `json:"m,omitempty"`
Payload any `json:"p"`
}
func (v WebSocketPackage) Marshal() []byte {
data, _ := json.Marshal(v)
return data
}
func (v WebSocketPackage) RawPayload() []byte {
out, _ := json.Marshal(v.Payload)
return out
}