Skip to content

Commit 121f713

Browse files
committed
update data
1 parent 98ba3ce commit 121f713

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

第一季 从零开始写游戏服务器 第二期/最新课节--课程代码/class3/src/snake/match.go renamed to 第一季 从零开始写游戏服务器 第二期/最新课节--课程代码/class3/src/snake/NetInitSend.go

File renamed without changes.

第一季 从零开始写游戏服务器 第二期/最新课节--课程代码/class3/src/snake/NetSnake.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func Send_PlayerLogin(conn *websocket.Conn, strName string, strPW string) {
2121
Login_Name: strName,
2222
Login_PW: strPW,
2323
}
24+
// 发送数据
2425
PlayerSendToServer(conn, data)
2526
}
2627

@@ -38,3 +39,26 @@ func Send_XYZ_Data(conn *websocket.Conn, strOpenID string, strRoomID string, OP_
3839
// 2 发送数据到服务器
3940
PlayerSendToServer(conn, data)
4041
}
42+
43+
// 处理数据的返回
44+
func GameServerReceive(ws *websocket.Conn) {
45+
for {
46+
var content string
47+
err := websocket.Message.Receive(ws, &content)
48+
if err != nil {
49+
fmt.Println(err.Error())
50+
continue
51+
}
52+
// decode
53+
fmt.Println(strings.Trim("", "\""))
54+
fmt.Println(content)
55+
content = strings.Replace(content, "\"", "", -1)
56+
contentstr, errr := base64Decode([]byte(content))
57+
if errr != nil {
58+
fmt.Println(errr)
59+
continue
60+
}
61+
// 解析数据 --
62+
fmt.Println("返回数据:", string(contentstr))
63+
}
64+
}

第一季 从零开始写游戏服务器 第二期/最新课节--课程代码/class3/src/snake/tmain.go

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -84,33 +84,12 @@ func initNet() bool {
8484
}
8585
// 协程支持 --接受线程操作
8686
go GameServerReceive(connbak)
87+
// 1 登录 协议
88+
// 2 进入游戏
8789
initMatch(connbak)
8890
return true
8991
}
9092

91-
// 处理数据的返回
92-
func GameServerReceive(ws *websocket.Conn) {
93-
for {
94-
var content string
95-
err := websocket.Message.Receive(ws, &content)
96-
if err != nil {
97-
fmt.Println(err.Error())
98-
continue
99-
}
100-
// decode
101-
fmt.Println(strings.Trim("", "\""))
102-
fmt.Println(content)
103-
content = strings.Replace(content, "\"", "", -1)
104-
contentstr, errr := base64Decode([]byte(content))
105-
if errr != nil {
106-
fmt.Println(errr)
107-
continue
108-
}
109-
// 解析数据 --
110-
fmt.Println("返回数据:", string(contentstr))
111-
}
112-
}
113-
11493
// 表示光标的位置
11594
type loct struct {
11695
i, j int

0 commit comments

Comments
 (0)