MCPcopy
hub / github.com/aceld/zinx / LostConnection

Method LostConnection

zinx_app_demo/mmo_game/core/player.go:368–389  ·  view source on GitHub ↗

Player logs off 玩家下线

()

Source from the content-addressed store, hash-verified

366// Player logs off
367// 玩家下线
368func (p *Player) LostConnection() {
369 // 1 Get players in the surrounding AOI nine-grid
370 // 获取周围AOI九宫格内的玩家
371 players := p.GetSurroundingPlayers()
372
373 // 2 Assemble MsgID:201 message
374 // 封装MsgID:201消息
375 msg := &pb.SyncPID{
376 PID: p.PID,
377 }
378
379 // 3 Send messages to surrounding players
380 // 向周围玩家发送消息
381 for _, player := range players {
382 player.SendMsg(201, msg)
383 }
384
385 // 4 Remove the current player from AOI in the world manager
386 // 世界管理器将当前玩家从AOI中摘除
387 WorldMgrObj.AoiMgr.RemoveFromGrIDByPos(int(p.PID), p.X, p.Z)
388 WorldMgrObj.RemovePlayerByPID(p.PID)
389}
390
391// SendMsg Send messages to the client, mainly serializing and sending the protobuf data of the pb Message
392//

Callers 1

OnConnectionLostFunction · 0.80

Calls 4

GetSurroundingPlayersMethod · 0.95
RemoveFromGrIDByPosMethod · 0.80
RemovePlayerByPIDMethod · 0.80
SendMsgMethod · 0.65

Tested by

no test coverage detected