Skip to content

Commit

Permalink
quick fail
Browse files Browse the repository at this point in the history
  • Loading branch information
xm-tech committed Oct 26, 2022
1 parent 5379117 commit 12151ad
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions zinx_app_demo/mmo_game/core/player.go
Expand Up @@ -337,6 +337,11 @@ func (p *Player) LostConnection() {
主要是将pb的protobuf数据序列化之后发送
*/
func (p *Player) SendMsg(msgID uint32, data proto.Message) {
if p.Conn == nil {
fmt.Println("connection in player is nil")
return
}

//fmt.Printf("before Marshal data = %+v\n", data)
//将proto Message结构体序列化
msg, err := proto.Marshal(data)
Expand All @@ -345,12 +350,6 @@ func (p *Player) SendMsg(msgID uint32, data proto.Message) {
return
}
//fmt.Printf("after Marshal data = %+v\n", msg)

if p.Conn == nil {
fmt.Println("connection in player is nil")
return
}

//调用Zinx框架的SendMsg发包
if err := p.Conn.SendMsg(msgID, msg); err != nil {
fmt.Println("Player SendMsg error !")
Expand Down

0 comments on commit 12151ad

Please sign in to comment.