Skip to content

Commit c8738d3

Browse files
committed
update data
1 parent 8abb764 commit c8738d3

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

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

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,45 @@ func PlayerSendToServer(conn *websocket.Conn, data interface{}) {
3232
fmt.Println("err:", err.Error())
3333
return
3434
}
35-
///fmt.Println("jsons:", string(jsons))
35+
// fmt.Println("jsons:", string(jsons))
3636
errq := websocket.Message.Send(conn, jsons)
3737
if errq != nil {
3838
fmt.Println(errq)
3939
}
4040
return
4141
}
42+
43+
// 群发广播函数:同一个房间
44+
func PlayerSendBroadcastToRoomPlayer(iroomID int) {
45+
46+
// -------------------------------------------------------------------------
47+
for itr := M.Iterator(); itr.HasNext(); {
48+
k, v, _ := itr.Next()
49+
strsplit := Strings_Split(k.(string), "|")
50+
for i := 0; i < len(strsplit); i++ {
51+
if len(strsplit) < 2 {
52+
continue
53+
}
54+
// 进行数据的查询类型
55+
switch v.(interface{}).(type) {
56+
case *NetDataConn:
57+
{
58+
// 判断 链接是不是 connect
59+
// 数据 处理操作
60+
if "" == "connect" {
61+
data := &Proto2.Net_Kicking_Player{
62+
Protocol: Proto.GameNet_Proto,
63+
Protocol2: Proto2.Net_Kicking_PlayerProto2,
64+
ErrorCode: 10001,
65+
}
66+
// 发送数据
67+
v.(interface{}).(*NetDataConn).PlayerSendMessage(data)
68+
}
69+
}
70+
}
71+
}
72+
}
73+
74+
// -------------------------------------------------------------------------
75+
return
76+
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ func GS2GW_Timer(ws *websocket.Conn) {
133133
continue
134134
}
135135
glog.Info("发送数据:", data)
136-
137136
}
138137
}
139138
}

0 commit comments

Comments
 (0)