网络层
This commit is contained in:
21
Server/Gateway/handler/ws_handler/temp.go
Normal file
21
Server/Gateway/handler/ws_handler/temp.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package ws_handler
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type msg struct {
|
||||
Type string `json:"type"`
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
func parseMsg(data []byte) (*msg, error) {
|
||||
m := &msg{}
|
||||
if err := json.Unmarshal(data, m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func wapMsg(m *msg) []byte {
|
||||
data, _ := json.Marshal(m)
|
||||
return data
|
||||
}
|
||||
Reference in New Issue
Block a user