Commit cdef950e34ab424773a8dbbe2daf40f11aff29da
1 parent
e172952c
fix: 服务器bug, 当未登录时,handle is nil 会导致崩溃。
Showing
5 changed files
with
24 additions
and
9 deletions
 
Show diff stats
cmd/gameserver/service/game.go
| ... | ... | @@ -118,10 +118,11 @@ func (s *GameServer) OnTimer(conn components.IConnection) { | 
| 118 | 118 | } | 
| 119 | 119 | |
| 120 | 120 | func (s *GameServer) OnClose(conn components.IConnection) { | 
| 121 | - agent := s.GetConnManage().GetConn(conn.GetID()) | |
| 121 | + connID := conn.GetID() | |
| 122 | + agent := s.GetConnManage().GetConn(connID) | |
| 122 | 123 | if agent == nil { | 
| 123 | 124 | return | 
| 124 | 125 | } | 
| 125 | 126 | agent.(*Agent).OnClose() | 
| 126 | - s.GetConnManage().DelConn(conn.GetID()) | |
| 127 | + s.GetConnManage().DelConn(connID) | |
| 127 | 128 | } | ... | ... | 
cmd/test/action/TestAction.go
| ... | ... | @@ -48,14 +48,28 @@ func RoleEndBattleRsp(role *models.RoleTestModel, msg components.IMessage) { | 
| 48 | 48 | func EquipmentDelRsp(role *models.RoleTestModel, msg components.IMessage) { | 
| 49 | 49 | } | 
| 50 | 50 | |
| 51 | -func EquipmentAddRsp(role *models.RoleTestModel, msg components.IMessage) { | |
| 51 | +func HeroUpLevelRsp(role *models.RoleTestModel, msg components.IMessage) { | |
| 52 | 52 | } | 
| 53 | 53 | |
| 54 | -func HeroUpLevelRsp(role *models.RoleTestModel, msg components.IMessage) { | |
| 54 | +func EmailListRsp(role *models.RoleTestModel, msg components.IMessage) { | |
| 55 | +} | |
| 56 | + | |
| 57 | +func EmailDrawRsp(role *models.RoleTestModel, msg components.IMessage) { | |
| 58 | +} | |
| 59 | + | |
| 60 | +func EmailCheckRsp(role *models.RoleTestModel, msg components.IMessage) { | |
| 55 | 61 | } | 
| 56 | 62 | |
| 63 | +func EmailDelRsp(role *models.RoleTestModel, msg components.IMessage) { | |
| 64 | +} | |
| 57 | 65 | func DisConnectNty(role *models.RoleTestModel, msg components.IMessage) { | 
| 58 | 66 | } | 
| 59 | 67 | |
| 68 | +func RoleUpdatePropertyNty(role *models.RoleTestModel, msg components.IMessage) { | |
| 69 | +} | |
| 70 | + | |
| 60 | 71 | func RoleUpdateItemsNty(role *models.RoleTestModel, msg components.IMessage) { | 
| 61 | 72 | } | 
| 73 | + | |
| 74 | +func EquipmentAddNty(role *models.RoleTestModel, msg components.IMessage) { | |
| 75 | +} | ... | ... | 
cmd/test/main.go
cmd/test/service/TestClient.go
| ... | ... | @@ -55,7 +55,7 @@ func (t *TestClient) OnLoginQuery(msg components.IMessage) { | 
| 55 | 55 | Device: "test-create", | 
| 56 | 56 | } | 
| 57 | 57 | r, _ := proto.Marshal(req) | 
| 58 | - t.GetConn().SendSuccess(uint32(pb.ProtoCode_CreateRpc), r) | |
| 58 | + t.GetConn().SendSuccess(uint32(pb.ProtoCode_CreateRpc), r, 0) | |
| 59 | 59 | return | 
| 60 | 60 | } | 
| 61 | 61 | } | 
| ... | ... | @@ -107,7 +107,7 @@ func (t *TestClient) Login(token string) { | 
| 107 | 107 | t.Token = token | 
| 108 | 108 | head := &components.PBHead{ | 
| 109 | 109 | Length: 0, | 
| 110 | - Cmd: uint32(pb.ProtoCode_LoginRpc), | |
| 110 | + Cmd: uint32(2), | |
| 111 | 111 | ErrCode: 0, | 
| 112 | 112 | PreField: 0, | 
| 113 | 113 | } | 
| ... | ... | @@ -116,5 +116,5 @@ func (t *TestClient) Login(token string) { | 
| 116 | 116 | Device: "test-login", | 
| 117 | 117 | } | 
| 118 | 118 | l, _ := proto.Marshal(loginReq) | 
| 119 | - t.Send(head.Cmd, l) | |
| 119 | + t.Send(head.Cmd, l, 0) | |
| 120 | 120 | } | ... | ... |