diff --git a/cmd/gameserver/service/agent.go b/cmd/gameserver/service/agent.go index 9e9b35a..5d12134 100644 --- a/cmd/gameserver/service/agent.go +++ b/cmd/gameserver/service/agent.go @@ -100,7 +100,7 @@ func (c *Agent) SendMsg(errCode int32, cmd uint32, msg interface{}, preserve uin if msg == nil || errCode != 0 { return c.Send(errCode, cmd, nil, preserve) } - return c.SendPB(errCode, cmd, msg.(proto.Message), preserve) + return c.SendPB(errCode, pb.ProtoCode(cmd), msg.(proto.Message), preserve) } func (c *Agent) OnMessage(msg components.IMessage) error { diff --git a/common/components/conn.go b/common/components/conn.go index eb19e0d..49bb271 100644 --- a/common/components/conn.go +++ b/common/components/conn.go @@ -7,6 +7,7 @@ import ( "net" "pro2d/common" "pro2d/common/logger" + "pro2d/pb" "sync" "sync/atomic" "time" @@ -141,12 +142,12 @@ func (c *Connection) Send(errCode int32, cmd uint32, data []byte, preserve uint3 } } -func (c *Connection) SendPB(errCode int32, cmd uint32, data proto.Message, preserve uint32) error { +func (c *Connection) SendPB(errCode int32, cmd pb.ProtoCode, data proto.Message, preserve uint32) error { pbData, err := proto.Marshal(data) if err != nil { return err } - buf, err := c.splitter.Pack(cmd, pbData, errCode, preserve) + buf, err := c.splitter.Pack(uint32(cmd), pbData, errCode, preserve) if err != nil { return err } diff --git a/common/components/icompontents.go b/common/components/icompontents.go index 9ebfebc..c62f090 100644 --- a/common/components/icompontents.go +++ b/common/components/icompontents.go @@ -53,7 +53,7 @@ type ( Start() Stop() Send(errCode int32, cmd uint32, b []byte, preserve uint32) error - SendPB(errCode int32, cmd uint32, b proto.Message, preserve uint32) error + SendPB(errCode int32, cmd pb.ProtoCode, b proto.Message, preserve uint32) error SendSuccess(cmd uint32, b []byte, preserve uint32) error CustomChan() chan<- func() diff --git a/models/role.go b/models/role.go index afa2911..8cdb24d 100644 --- a/models/role.go +++ b/models/role.go @@ -208,7 +208,7 @@ func (m *RoleModel) UpdateProperties(property map[string]interface{}, notify boo Role: role, } if m.GetConn() != nil && notify { - m.GetConn().SendPB(0, uint32(pb.ProtoCode_RoleUpdatePropertyNty), update, 0) + m.GetConn().SendPB(0, pb.ProtoCode_RoleUpdatePropertyNty, update, 0) } } diff --git a/models/rolePlugin.go b/models/rolePlugin.go index f3694f6..43a00e1 100644 --- a/models/rolePlugin.go +++ b/models/rolePlugin.go @@ -65,7 +65,7 @@ func (m *RoleModel) AddItem(key string, count int32, param *pb.LogConf) bool { } if m.GetConn() != nil { - m.GetConn().SendPB(0, uint32(pb.ProtoCode_RoleUpdateItemsNty), &pb.RoleUpdateItemsNty{Items: fmt.Sprintf("%s=%d", key, num)}, 0) + m.GetConn().SendPB(0, pb.ProtoCode_RoleUpdateItemsNty, &pb.RoleUpdateItemsNty{Items: fmt.Sprintf("%s=%d", key, num)}, 0) } return true @@ -99,7 +99,7 @@ func (m *RoleModel) AddItems(params common.IMapStringNum, logconf *pb.LogConf) b m.SetProperty("items", common.MapNumToString(m.Items)) if m.GetConn() != nil { - m.GetConn().SendPB(0, uint32(pb.ProtoCode_RoleUpdateItemsNty), &pb.RoleUpdateItemsNty{Items: common.MapToString(tmp)}, 0) + m.GetConn().SendPB(0, pb.ProtoCode_RoleUpdateItemsNty, &pb.RoleUpdateItemsNty{Items: common.MapToString(tmp)}, 0) } return true @@ -386,7 +386,7 @@ func (m *RoleModel) InsertEmail(email *pb.Email) error { nty := &pb.EmailNewNty{Emails: email} if m.GetConn() != nil { - m.GetConn().SendPB(0, uint32(pb.ProtoCode_EmailNewNty), nty, 0) + m.GetConn().SendPB(0, pb.ProtoCode_EmailNewNty, nty, 0) } return nil } -- libgit2 0.21.2