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,10 +118,11 @@ func (s *GameServer) OnTimer(conn components.IConnection) { | ||
118 | } | 118 | } |
119 | 119 | ||
120 | func (s *GameServer) OnClose(conn components.IConnection) { | 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 | if agent == nil { | 123 | if agent == nil { |
123 | return | 124 | return |
124 | } | 125 | } |
125 | agent.(*Agent).OnClose() | 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,14 +48,28 @@ func RoleEndBattleRsp(role *models.RoleTestModel, msg components.IMessage) { | ||
48 | func EquipmentDelRsp(role *models.RoleTestModel, msg components.IMessage) { | 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 | func DisConnectNty(role *models.RoleTestModel, msg components.IMessage) { | 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 | func RoleUpdateItemsNty(role *models.RoleTestModel, msg components.IMessage) { | 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
@@ -26,7 +26,7 @@ func main() { | @@ -26,7 +26,7 @@ func main() { | ||
26 | time.Sleep(2 * time.Second) | 26 | time.Sleep(2 * time.Second) |
27 | for { | 27 | for { |
28 | //tc.SendPB(pb.ProtoCode_HeartReq, nil) | 28 | //tc.SendPB(pb.ProtoCode_HeartReq, nil) |
29 | - tc.SendPB(pb.ProtoCode_HeroUpLevelRpc, pp) | 29 | + tc.SendPB(pb.ProtoCode_HeroUpLevelRpc, pp, 0) |
30 | time.Sleep(5 * time.Second) | 30 | time.Sleep(5 * time.Second) |
31 | } | 31 | } |
32 | 32 |
cmd/test/service/TestClient.go
@@ -55,7 +55,7 @@ func (t *TestClient) OnLoginQuery(msg components.IMessage) { | @@ -55,7 +55,7 @@ func (t *TestClient) OnLoginQuery(msg components.IMessage) { | ||
55 | Device: "test-create", | 55 | Device: "test-create", |
56 | } | 56 | } |
57 | r, _ := proto.Marshal(req) | 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 | return | 59 | return |
60 | } | 60 | } |
61 | } | 61 | } |
@@ -107,7 +107,7 @@ func (t *TestClient) Login(token string) { | @@ -107,7 +107,7 @@ func (t *TestClient) Login(token string) { | ||
107 | t.Token = token | 107 | t.Token = token |
108 | head := &components.PBHead{ | 108 | head := &components.PBHead{ |
109 | Length: 0, | 109 | Length: 0, |
110 | - Cmd: uint32(pb.ProtoCode_LoginRpc), | 110 | + Cmd: uint32(2), |
111 | ErrCode: 0, | 111 | ErrCode: 0, |
112 | PreField: 0, | 112 | PreField: 0, |
113 | } | 113 | } |
@@ -116,5 +116,5 @@ func (t *TestClient) Login(token string) { | @@ -116,5 +116,5 @@ func (t *TestClient) Login(token string) { | ||
116 | Device: "test-login", | 116 | Device: "test-login", |
117 | } | 117 | } |
118 | l, _ := proto.Marshal(loginReq) | 118 | l, _ := proto.Marshal(loginReq) |
119 | - t.Send(head.Cmd, l) | 119 | + t.Send(head.Cmd, l, 0) |
120 | } | 120 | } |
conf/conf.yml