完善服务器

This commit is contained in:
2025-07-01 00:08:27 +08:00
parent b45eb83fe4
commit 7c2c32a31a
37 changed files with 1307 additions and 160 deletions

View File

@@ -2,20 +2,29 @@ package ws_handler
import "encoding/json"
type msg struct {
type tempMsg struct {
Type string `json:"type"`
Data string `json:"data"`
}
func parseMsg(data []byte) (*msg, error) {
m := &msg{}
type tempAction struct {
Action int `json:"action"`
Data string `json:"data"`
}
type tempActionMove struct {
Move int `json:"move"`
}
func parseMsg(data []byte) (*tempMsg, error) {
m := &tempMsg{}
if err := json.Unmarshal(data, m); err != nil {
return nil, err
}
return m, nil
}
func wapMsg(m *msg) []byte {
func wapMsg(m *tempMsg) []byte {
data, _ := json.Marshal(m)
return data
}