From eadc9aff4df073fc1146adae03fcff79e734059f Mon Sep 17 00:00:00 2001 From: zqj <582132116@qq.com> Date: Wed, 6 Apr 2022 16:33:43 +0800 Subject: [PATCH] feat: 增加上阵下阵协议,增加 IAgent接口, --- cmd/gameserver/action/RoleAction.go | 31 ++++++++++++++++++++++++++----- cmd/gameserver/action/protocode.go | 3 ++- cmd/gameserver/agent.go | 142 ---------------------------------------------------------------------------------------------------------------------------------------------- cmd/gameserver/game.go | 113 ----------------------------------------------------------------------------------------------------------------- cmd/gameserver/main.go | 9 +++++---- cmd/gameserver/service/agent.go | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ cmd/gameserver/service/game.go | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/components/conn.go | 34 ++++++++++++++++++++-------------- common/components/connector.go | 36 ++++++++++++++++++------------------ common/components/icompontents.go | 13 ++++++++++--- common/components/pbsplitter.go | 10 +++++----- common/db/mongoproxy/mongo.go | 22 +++++++++++----------- conf/conf.yaml | 2 +- models/role.go | 14 ++++++++++++-- models/role_test.go | 20 ++++++++++++++++++++ models/schema.go | 29 +++++++++++++++++++++++------ pb/game.pb.go | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------- pb/protocode.pb.go | 64 ++++++++++++++++++++++++++++++++++++---------------------------- protos | 2 +- tools/protostostruct.go | 1 + 20 files changed, 513 insertions(+), 370 deletions(-) delete mode 100644 cmd/gameserver/agent.go delete mode 100644 cmd/gameserver/game.go create mode 100644 cmd/gameserver/service/agent.go create mode 100644 cmd/gameserver/service/game.go diff --git a/cmd/gameserver/action/RoleAction.go b/cmd/gameserver/action/RoleAction.go index 681d36c..9056b1f 100644 --- a/cmd/gameserver/action/RoleAction.go +++ b/cmd/gameserver/action/RoleAction.go @@ -11,14 +11,14 @@ import ( "pro2d/pb" ) -func HeartRpc(msg components.IMessage) (int32, interface{}) { +func HeartRpc(agent components.IAgent, msg components.IMessage) (int32, interface{}) { //msg.Conn.SetLastHeartCheckTime() return 0, nil } func getRandomName() string { name := "" - for { + for { name = common.RandomName(common.DefaultName) if name == "" { continue @@ -35,7 +35,7 @@ func getRandomName() string { return name } -func CreateRpc(msg components.IMessage) (int32, interface{}) { +func CreateRpc(agent components.IAgent, msg components.IMessage) (int32, interface{}) { req := pb.CreateReq{} if err := proto.Unmarshal(msg.GetData(), &req); err != nil { logger.Error("CreateRpc err: %v", err) @@ -57,7 +57,7 @@ func CreateRpc(msg components.IMessage) (int32, interface{}) { return 0, nil } -func LoginRpc(msg components.IMessage) (int32, interface{}) { +func LoginRpc(agent components.IAgent, msg components.IMessage) (int32, interface{}) { //logger.Debug("11111111cmd: %v, msg: %s", msg.GetHeader().GetMsgID(), msg.GetData()) req := pb.LoginReq{} if err := proto.Unmarshal(msg.GetData(), &req); err != nil { @@ -70,6 +70,27 @@ func LoginRpc(msg components.IMessage) (int32, interface{}) { return 2, nil } role.SetProperty("Device", req.Device) + protoMsg := &pb.RoleRsp{ + Role: role.Role, + Hero: role.GetAllHero(), + Team: role.GetAllTeam(), + } + //登录成功,存储agent role + agent.SetSchema(role) + return 0, protoMsg +} - return 0, role +func GoIntoBattleRpc(agent components.IAgent, msg components.IMessage) (int32, interface{}) { + req := pb.GoIntoBattleReq{} + if err := proto.Unmarshal(msg.GetData(), &req); err != nil { + logger.Error("loginRpc err: %v", err) + return 1, nil + } + role := agent.GetSchema().(*models.RoleModel) + if role == nil { + return 2, nil + } + + role.UpdateTeam(req.Team) + return 0, nil } diff --git a/cmd/gameserver/action/protocode.go b/cmd/gameserver/action/protocode.go index af9ecde..6c22a61 100644 --- a/cmd/gameserver/action/protocode.go +++ b/cmd/gameserver/action/protocode.go @@ -11,6 +11,7 @@ func GetActionMap() map[interface{}]interface{} { am[uint32(pb.ProtoCode_HeartReq)] = HeartRpc am[uint32(pb.ProtoCode_LoginReq)] = LoginRpc am[uint32(pb.ProtoCode_CreateReq)] = CreateRpc + am[uint32(pb.ProtoCode_GoIntoBattleReq)] = GoIntoBattleRpc return am -} \ No newline at end of file +} diff --git a/cmd/gameserver/agent.go b/cmd/gameserver/agent.go deleted file mode 100644 index 67c32b0..0000000 --- a/cmd/gameserver/agent.go +++ /dev/null @@ -1,142 +0,0 @@ -package main - -import ( - "github.com/golang/protobuf/proto" - "math" - "pro2d/cmd/gameserver/action" - "pro2d/common" - "pro2d/common/components" - "pro2d/common/logger" - "pro2d/models" - "pro2d/pb" - "sync" - "sync/atomic" -) - -type Agent struct { - components.IConnection - Server components.IServer - - Role *models.RoleModel - nextCheckTime int64 //下一次检查的时间 - lastHeartCheckTime int64 - heartTimeoutCount int //超时次数 -} - -var agentPool = sync.Pool{New: func() interface{} { return new(Agent)}} - -func NewAgent(s components.IServer) *Agent { - a := agentPool.Get().(*Agent) - a.Server = s - - a.nextCheckTime = 0 - a.lastHeartCheckTime = common.Timex() - a.heartTimeoutCount= 0 - return a -} - -func (c *Agent) OnConnection(conn components.IConnection) { - c.IConnection = conn -} - -func (c *Agent) OnLogin(msg components.IMessage) { - //第一次登录 - errCode, irole := action.LoginRpc(msg) - if errCode != 0 { - c.Send(errCode, msg.GetHeader().GetMsgID(), nil) - return - } - - role := irole.(*models.RoleModel) - protoMsg := &pb.RoleRsp{ - Role: role.Role, - Hero: role.GetAllHero(), - Team: role.GetAllTeam(), - } - rsp, err := proto.Marshal(protoMsg) - if err != nil { - c.Send(-100, msg.GetHeader().GetMsgID(), nil) - return - } - c.Send(errCode, msg.GetHeader().GetMsgID(), rsp) - //登录成功,存储agent role - c.Role = role -} - -func (c *Agent) OnMessage(msg components.IMessage) { - atomic.StoreInt64(&c.lastHeartCheckTime, common.Timex()) - - if msg.GetHeader().GetMsgID() == uint32(pb.ProtoCode_LoginReq) { - c.OnLogin(msg) - return - } - - md := c.Server.GetAction(msg.GetHeader().GetMsgID()) - if md == nil { - logger.Debug("cmd: %d, handler is nil", msg.GetHeader().GetMsgID()) - return - } - logger.Debug("protocolID: %d", msg.GetHeader().GetMsgID()) - //fmt.Printf("errCode: %d, protoMsg:%v\n", errCode, protoMsg) - - f := md.(func (msg components.IMessage) (int32, interface{})) - errCode, protoMsg := f(msg) - - if protoMsg == nil { - c.Send(errCode, msg.GetHeader().GetMsgID(), nil) - return - } - - rsp, err := proto.Marshal(protoMsg.(proto.Message)) - if err != nil { - c.Send(-100, msg.GetHeader().GetMsgID(), nil) - return - } - c.Send(errCode, msg.GetHeader().GetMsgID(), rsp) -} - -func (c *Agent) OnTimer() { - nextCheckTime := atomic.LoadInt64(&c.nextCheckTime) - now := common.Timex() - if now >= nextCheckTime { - //检查心跳 - c.checkHeartBeat(now) - nextCheckTime = now + common.HeartTimerInterval - atomic.StoreInt64(&c.nextCheckTime, nextCheckTime) - } - - if c.Role != nil { - //role 恢复数据 - c.Role.OnRecoverTimer(now) - } -} - -func (c *Agent) OnClose() { - c.Close() -} - -func (c *Agent) Close() { - c.Role = nil - agentPool.Put(c) - - if c.Role == nil { - return - } - - c.Role.OnOfflineEvent() -} - -func (c *Agent) checkHeartBeat(now int64) { - lastHeartCheckTime := atomic.LoadInt64(&c.lastHeartCheckTime) - //logger.Debug("checkHeartBeat ID: %d, last: %d, now: %d", c.GetID(), lastHeartCheckTime, now) - if math.Abs(float64(lastHeartCheckTime - now)) > common.HeartTimerInterval { - c.heartTimeoutCount++ - if c.heartTimeoutCount >= common.HeartTimeoutCountMax { - c.Stop() - return - } - logger.Debug("timeout count: %d", c.heartTimeoutCount) - }else { - c.heartTimeoutCount = 0 - } -} diff --git a/cmd/gameserver/game.go b/cmd/gameserver/game.go deleted file mode 100644 index fd9faaf..0000000 --- a/cmd/gameserver/game.go +++ /dev/null @@ -1,113 +0,0 @@ -package main - -import ( - "fmt" - "math/rand" - _ "net/http/pprof" - "pro2d/cmd/gameserver/action" - "pro2d/common" - "pro2d/common/components" - "pro2d/common/db/mongoproxy" - "pro2d/common/db/redisproxy" - "pro2d/common/logger" - "pro2d/models" - "time" - - "pro2d/common/etcd" -) - -type GameServer struct { - components.IServer - EtcdClient *etcd.EtcdClient -} - -func NewGameServer(sconf *common.SConf) (*GameServer, error) { - s := &GameServer{} - - options := []components.ServerOption{ - components.WithPlugin(components.NewPlugin(sconf.PluginPath)), - - components.WithConnCbk(s.OnConnection), - components.WithMsgCbk(s.OnMessage), - components.WithCloseCbk(s.OnClose), - components.WithTimerCbk(s.OnTimer), - } - //加密 - if sconf.Encipher { - options = append(options, components.WithSplitter(components.NewPBSplitter(components.NewAesEncipher()))) - logger.Debug("open encipher aes...") - } else { - options = append(options, components.WithSplitter(components.NewPBSplitter(nil))) - } - - iserver := components.NewServer(sconf.Port, options...) - iserver.SetActions(action.GetActionMap()) - s.IServer = iserver - - //mgo init - err := mongoproxy.ConnectMongo(sconf.MongoConf) - if err != nil { - return nil, err - } - models.InitGameModels() - - //redis init - if err = redisproxy.ConnectRedis(sconf.RedisConf.DB, sconf.RedisConf.Auth, sconf.RedisConf.Address); err != nil { - return nil, err - } - - //Etcd 初始化 - s.EtcdClient, err = etcd.NewEtcdClient(common.GlobalConf.Etcd) - if err != nil { - return nil, err - } - s.EtcdClient.PutWithLeasePrefix(common.GlobalConf.GameConf.Name, common.GlobalConf.GameConf.ID, fmt.Sprintf("%s:%d", common.GlobalConf.GameConf.IP, common.GlobalConf.GameConf.Port), 5) - - return s, nil -} - -func (s *GameServer) Start() error { - //设置随机种子 - rand.Seed(time.Now().Unix()) - - return s.IServer.Start() -} - -func (s *GameServer) Stop() { - s.IServer.Stop() - - mongoproxy.CloseMongo() - redisproxy.CloseRedis() - s.EtcdClient.Close() -} - -func (s *GameServer) OnConnection(conn components.IConnection) { - agent := NewAgent(s) - agent.OnConnection(conn) - s.GetConnManage().AddConn(conn.GetID(), agent) -} - -func (s *GameServer) OnMessage(msg components.IMessage) { - agent := s.GetConnManage().GetConn(msg.GetSession().GetID()) - if agent == nil { - return - } - agent.(*Agent).OnMessage(msg) -} - -func (s *GameServer) OnTimer(conn components.IConnection) { - agent := s.GetConnManage().GetConn(conn.GetID()) - if agent == nil { - return - } - agent.(*Agent).OnTimer() -} - -func (s *GameServer) OnClose(conn components.IConnection) { - agent := s.GetConnManage().GetConn(conn.GetID()) - if agent == nil { - return - } - agent.(*Agent).OnClose() - s.GetConnManage().DelConn(conn.GetID()) -} diff --git a/cmd/gameserver/main.go b/cmd/gameserver/main.go index c21302c..e1456d6 100644 --- a/cmd/gameserver/main.go +++ b/cmd/gameserver/main.go @@ -5,12 +5,13 @@ import ( "net/http" "os" "os/signal" + "pro2d/cmd/gameserver/service" "pro2d/common" "pro2d/common/logger" "syscall" ) -func main() { +func main() { err := make(chan error) stopChan := make(chan os.Signal) signal.Notify(stopChan, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL) @@ -18,7 +19,7 @@ func main() { userChan := make(chan os.Signal) signal.Notify(userChan, syscall.SIGUSR1, syscall.SIGUSR2) - s,err1 := NewGameServer(common.GlobalConf.GameConf) + s, err1 := service.NewGameServer(common.GlobalConf.GameConf) if err1 != nil { logger.Error(err1) return @@ -33,7 +34,7 @@ func main() { for { select { - case e := <- err: + case e := <-err: logger.Error("game server error: %v", e) return case <-stopChan: @@ -41,7 +42,7 @@ func main() { s.Stop() return case u := <-userChan: - logger.Debug("userChan .. %v",u.String()) + logger.Debug("userChan .. %v", u.String()) e := s.IServer.GetPlugin().LoadPlugin() if e != nil { logger.Error("err: ", e.Error()) diff --git a/cmd/gameserver/service/agent.go b/cmd/gameserver/service/agent.go new file mode 100644 index 0000000..5c5c7fa --- /dev/null +++ b/cmd/gameserver/service/agent.go @@ -0,0 +1,129 @@ +package service + +import ( + "github.com/golang/protobuf/proto" + "math" + "pro2d/common" + "pro2d/common/components" + "pro2d/common/logger" + "pro2d/models" + "pro2d/pb" + "sync" + "sync/atomic" +) + +type Agent struct { + components.IConnection + Server components.IServer + components.IAgent + + Role *models.RoleModel + nextCheckTime int64 //下一次检查的时间 + lastHeartCheckTime int64 + heartTimeoutCount int //超时次数 +} + +var agentPool = sync.Pool{New: func() interface{} { return new(Agent) }} + +func NewAgent(s components.IServer) *Agent { + a := agentPool.Get().(*Agent) + a.Server = s + + a.nextCheckTime = 0 + a.lastHeartCheckTime = common.Timex() + a.heartTimeoutCount = 0 + return a +} + +func (c *Agent) SetSchema(schema components.ISchema) { + c.Role = schema.(*models.RoleModel) +} + +func (c *Agent) GetSchema() components.ISchema { + return c.Role +} + +func (c *Agent) SetServer(server components.IServer) { + c.Server = server +} + +func (c *Agent) GetServer() components.IServer { + return c.Server +} + +func (c *Agent) OnConnection(conn components.IConnection) { + c.IConnection = conn +} + +func (c *Agent) OnMessage(msg components.IMessage) { + atomic.StoreInt64(&c.lastHeartCheckTime, common.Timex()) + if msg.GetHeader().GetMsgID() == uint32(pb.ProtoCode_HeartReq) { + return + } + + md := c.Server.GetAction(msg.GetHeader().GetMsgID()) + if md == nil { + logger.Debug("cmd: %d, handler is nil", msg.GetHeader().GetMsgID()) + return + } + logger.Debug("protocolID: %d", msg.GetHeader().GetMsgID()) + //fmt.Printf("errCode: %d, protoMsg:%v\n", errCode, protoMsg) + + f := md.(func(agent components.IAgent, msg components.IMessage) (int32, interface{})) + errCode, protoMsg := f(c, msg) + + if protoMsg == nil { + c.Send(errCode, msg.GetHeader().GetMsgID(), nil) + return + } + + rsp, err := proto.Marshal(protoMsg.(proto.Message)) + if err != nil { + c.Send(-100, msg.GetHeader().GetMsgID(), nil) + return + } + c.Send(errCode, msg.GetHeader().GetMsgID(), rsp) +} + +func (c *Agent) OnTimer() { + nextCheckTime := atomic.LoadInt64(&c.nextCheckTime) + now := common.Timex() + if now >= nextCheckTime { + //检查心跳 + c.checkHeartBeat(now) + nextCheckTime = now + common.HeartTimerInterval + atomic.StoreInt64(&c.nextCheckTime, nextCheckTime) + } + + if c.Role != nil { + //role 恢复数据 + c.Role.OnRecoverTimer(now) + } +} + +func (c *Agent) OnClose() { + c.IConnection = nil + c.Role = nil + agentPool.Put(c) + + if c.Role == nil { + return + } + + c.Role.OnOfflineEvent() +} + +func (c *Agent) checkHeartBeat(now int64) { + lastHeartCheckTime := atomic.LoadInt64(&c.lastHeartCheckTime) + //logger.Debug("checkHeartBeat ID: %d, last: %d, now: %d", c.GetID(), lastHeartCheckTime, now) + if math.Abs(float64(lastHeartCheckTime-now)) > common.HeartTimerInterval { + c.heartTimeoutCount++ + if c.heartTimeoutCount >= common.HeartTimeoutCountMax { + c.Stop() + return + } + logger.Debug("timeout count: %d", c.heartTimeoutCount) + } else { + c.heartTimeoutCount = 0 + } +} diff --git a/cmd/gameserver/service/game.go b/cmd/gameserver/service/game.go new file mode 100644 index 0000000..c059d35 --- /dev/null +++ b/cmd/gameserver/service/game.go @@ -0,0 +1,113 @@ +package service + +import ( + "fmt" + "math/rand" + _ "net/http/pprof" + "pro2d/cmd/gameserver/action" + "pro2d/common" + "pro2d/common/components" + "pro2d/common/db/mongoproxy" + "pro2d/common/db/redisproxy" + "pro2d/common/logger" + "pro2d/models" + "time" + + "pro2d/common/etcd" +) + +type GameServer struct { + components.IServer + EtcdClient *etcd.EtcdClient +} + +func NewGameServer(sconf *common.SConf) (*GameServer, error) { + s := &GameServer{} + + options := []components.ServerOption{ + components.WithPlugin(components.NewPlugin(sconf.PluginPath)), + + components.WithConnCbk(s.OnConnection), + components.WithMsgCbk(s.OnMessage), + components.WithCloseCbk(s.OnClose), + components.WithTimerCbk(s.OnTimer), + } + //加密 + if sconf.Encipher { + options = append(options, components.WithSplitter(components.NewPBSplitter(components.NewAesEncipher()))) + logger.Debug("open encipher aes...") + } else { + options = append(options, components.WithSplitter(components.NewPBSplitter(nil))) + } + + iserver := components.NewServer(sconf.Port, options...) + iserver.SetActions(action.GetActionMap()) + s.IServer = iserver + + //mgo init + err := mongoproxy.ConnectMongo(sconf.MongoConf) + if err != nil { + return nil, err + } + models.InitGameModels() + + //redis init + if err = redisproxy.ConnectRedis(sconf.RedisConf.DB, sconf.RedisConf.Auth, sconf.RedisConf.Address); err != nil { + return nil, err + } + + //Etcd 初始化 + s.EtcdClient, err = etcd.NewEtcdClient(common.GlobalConf.Etcd) + if err != nil { + return nil, err + } + s.EtcdClient.PutWithLeasePrefix(common.GlobalConf.GameConf.Name, common.GlobalConf.GameConf.ID, fmt.Sprintf("%s:%d", common.GlobalConf.GameConf.IP, common.GlobalConf.GameConf.Port), 5) + + return s, nil +} + +func (s *GameServer) Start() error { + //设置随机种子 + rand.Seed(time.Now().Unix()) + + return s.IServer.Start() +} + +func (s *GameServer) Stop() { + s.IServer.Stop() + + mongoproxy.CloseMongo() + redisproxy.CloseRedis() + s.EtcdClient.Close() +} + +func (s *GameServer) OnConnection(conn components.IConnection) { + agent := NewAgent(s) + agent.OnConnection(conn) + s.GetConnManage().AddConn(conn.GetID(), agent) +} + +func (s *GameServer) OnMessage(msg components.IMessage) { + agent := s.GetConnManage().GetConn(msg.GetSID()) + if agent == nil { + return + } + agent.(*Agent).OnMessage(msg) +} + +func (s *GameServer) OnTimer(conn components.IConnection) { + agent := s.GetConnManage().GetConn(conn.GetID()) + if agent == nil { + return + } + agent.(*Agent).OnTimer() +} + +func (s *GameServer) OnClose(conn components.IConnection) { + agent := s.GetConnManage().GetConn(conn.GetID()) + if agent == nil { + return + } + agent.(*Agent).OnClose() + s.GetConnManage().DelConn(conn.GetID()) +} diff --git a/common/components/conn.go b/common/components/conn.go index 9cd3135..973e49f 100644 --- a/common/components/conn.go +++ b/common/components/conn.go @@ -15,7 +15,7 @@ type Connection struct { IConnection net.Conn splitter ISplitter - Id uint32 + Id uint32 scanner *bufio.Scanner writer *bufio.Writer @@ -33,7 +33,7 @@ type Connection struct { } var connectionPool = &sync.Pool{ - New: func() interface{} { return new(Connection)}, + New: func() interface{} { return new(Connection) }, } func NewConn(id int, conn net.Conn, splitter ISplitter) IConnection { @@ -48,8 +48,8 @@ func NewConn(id int, conn net.Conn, splitter ISplitter) IConnection { c.Conn = conn c.splitter = splitter - c.scanner = bufio.NewScanner(conn) - c.writer = bufio.NewWriter(conn) + c.scanner = bufio.NewScanner(conn) + c.writer = bufio.NewWriter(conn) c.reset() @@ -57,11 +57,11 @@ func NewConn(id int, conn net.Conn, splitter ISplitter) IConnection { } func (c *Connection) reset() { - c.WBuffer = make(chan []byte, common.MaxMsgChan) - c.Quit = make(chan *Connection) + c.WBuffer = make(chan []byte, common.MaxMsgChan) + c.Quit = make(chan *Connection) if c.readFunc == nil { - c.readFunc = make(chan func(), 10) + c.readFunc = make(chan func(), 10) } if c.timerFunc == nil { c.timerFunc = make(chan func(), 10) @@ -104,7 +104,9 @@ func (c *Connection) Start() { } func (c *Connection) Stop() { - if atomic.LoadUint32(&c.Status) == 0 { return } + if atomic.LoadUint32(&c.Status) == 0 { + return + } sendTimeout := time.NewTimer(5 * time.Millisecond) defer sendTimeout.Stop() @@ -148,7 +150,7 @@ func (c *Connection) defaultTimerCallback(conn IConnection) { func (c *Connection) write() { defer func() { - logger.Debug("write close") + //logger.Debug("write close") c.Stop() }() @@ -167,7 +169,7 @@ func (c *Connection) write() { func (c *Connection) read() { defer func() { - logger.Debug("read close") + //logger.Debug("read close") c.Stop() }() @@ -179,7 +181,7 @@ func (c *Connection) read() { return } - req.SetSession(c) + req.SetSID(c.GetID()) c.readFunc <- func() { c.messageCallback(req) } @@ -194,7 +196,7 @@ func (c *Connection) read() { //此设计目的是为了让网络数据与定时器处理都在一条协程里处理。不想加锁。。。 func (c *Connection) listen() { defer func() { - logger.Debug("listen close") + //logger.Debug("listen close") c.quitting() }() @@ -211,7 +213,9 @@ func (c *Connection) listen() { } func (c *Connection) handleTimeOut() { - if atomic.LoadUint32(&c.Status) == 0 { return } + if atomic.LoadUint32(&c.Status) == 0 { + return + } c.timerFunc <- func() { c.timerCallback(c) @@ -220,7 +224,9 @@ func (c *Connection) handleTimeOut() { } func (c *Connection) quitting() { - if atomic.LoadUint32(&c.Status) == 0 { return } + if atomic.LoadUint32(&c.Status) == 0 { + return + } atomic.StoreUint32(&c.Status, 0) logger.Debug("ID: %d close", c.Id) diff --git a/common/components/connector.go b/common/components/connector.go index 860eac7..7141aaa 100644 --- a/common/components/connector.go +++ b/common/components/connector.go @@ -23,20 +23,20 @@ func WithCtorCount(count int) ConnectorOption { type Connector struct { IConnector IServer - splitter ISplitter - ip string - port int - sum int + splitter ISplitter + ip string + port int + sum int Conns IConnManage - ids uint32 + ids uint32 } func NewConnector(ip string, port int, options ...ConnectorOption) IConnector { c := &Connector{ - ids: 0, - ip: ip, - port: port, + ids: 0, + ip: ip, + port: port, Conns: NewConnManage(), } for _, option := range options { @@ -50,7 +50,7 @@ func (c *Connector) Connect() error { c.sum = 1 } for i := 0; i < c.sum; i++ { - conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d",c.ip, c.port)) + conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", c.ip, c.port)) if err != nil { return err } @@ -67,14 +67,14 @@ func (c *Connector) Connect() error { return nil } -func (c *Connector) DisConnect(){ +func (c *Connector) DisConnect() { c.Conns.StopAllConns() } -func (c *Connector) Send( cmd uint32, b []byte) { +func (c *Connector) Send(cmd uint32, b []byte) { c.Conns.Range(func(key interface{}, value interface{}) bool { conn := value.(IConnection) - conn.Send(0, cmd ,b) + conn.Send(0, cmd, b) return true }) } @@ -83,18 +83,18 @@ func (c *Connector) GetSplitter() ISplitter { return c.splitter } -func (c *Connector) OnConnect(conn IConnection){ +func (c *Connector) OnConnect(conn IConnection) { c.Conns.AddConn(conn.GetID(), conn) } -func (c *Connector) OnMessage(msg IMessage){ - logger.Debug("recv msg cmd: %d, conn: %d data: %s", msg.GetHeader().GetMsgID(), msg.GetSession().GetID(), msg.GetData()) +func (c *Connector) OnMessage(msg IMessage) { + logger.Debug("recv msg cmd: %d, conn: %d data: %s", msg.GetHeader().GetMsgID(), msg.GetSID(), msg.GetData()) } -func (c *Connector) OnClose(conn IConnection){ +func (c *Connector) OnClose(conn IConnection) { logger.Debug("onclose id: %d", conn.GetID()) } -func (c *Connector) OnTimer(conn IConnection){ +func (c *Connector) OnTimer(conn IConnection) { logger.Debug("ontimer id: %d", conn.GetID()) -} \ No newline at end of file +} diff --git a/common/components/icompontents.go b/common/components/icompontents.go index 907464a..fd972c8 100644 --- a/common/components/icompontents.go +++ b/common/components/icompontents.go @@ -21,8 +21,8 @@ type ( GetData() []byte //获取消息内容 SetData([]byte) //设置消息内容 - SetSession(IConnection) //设置连接 - GetSession() IConnection //获取连接 + SetSID(id uint32) //设置连接 + GetSID() uint32 //获取连接 } //网络拆包解包器 ISplitter interface { @@ -77,6 +77,13 @@ type ( SetCloseCallback(CloseCallback) SetTimerCallback(TimerCallback) } + IAgent interface { + GetSchema() ISchema + SetSchema(schema ISchema) + + GetServer() IServer + SetServer(server IServer) + } //Connector IConnector interface { @@ -125,10 +132,10 @@ type ( GetPri() interface{} GetSchema() interface{} GetSchemaName() string + UpdateSchema(interface{}) Load() error Create() error - Save() error Update() SetProperty(key string, val interface{}) diff --git a/common/components/pbsplitter.go b/common/components/pbsplitter.go index d99c1f6..f64c1eb 100644 --- a/common/components/pbsplitter.go +++ b/common/components/pbsplitter.go @@ -35,7 +35,7 @@ type PBMessage struct { Head IHead Body []byte - conn IConnection + ID uint32 } func (m *PBMessage) GetHeader() IHead { @@ -53,12 +53,12 @@ func (m *PBMessage) SetData(b []byte) { m.Body = b } -func (m *PBMessage) SetSession(connection IConnection) { - m.conn = connection +func (m *PBMessage) SetSID(id uint32) { + m.ID = id } -func (m *PBMessage) GetSession() IConnection { - return m.conn +func (m *PBMessage) GetSID() uint32 { + return m.ID } type PBSplitter struct { diff --git a/common/db/mongoproxy/mongo.go b/common/db/mongoproxy/mongo.go index 01c9ac9..f766b75 100644 --- a/common/db/mongoproxy/mongo.go +++ b/common/db/mongoproxy/mongo.go @@ -13,7 +13,7 @@ import ( ) var ( - mongoClient *mongo.Client + mongoClient *mongo.Client mongoDatabase *mongo.Database ) @@ -22,7 +22,7 @@ type MgoColl struct { Schema components.ISchema dbname string - coll *mongo.Collection + coll *mongo.Collection } func NewMongoColl(dbname string, schema components.ISchema) *MgoColl { @@ -45,19 +45,19 @@ func (m *MgoColl) CreateTable() error { return DB().CreateCollection(context.TODO(), m.dbname) } -func (m *MgoColl) Create() (interface{}, error){ +func (m *MgoColl) Create() (interface{}, error) { return m.coll.InsertOne(context.TODO(), m.Schema.GetSchema()) } -func (m *MgoColl) Save() error{ - _, err := m.coll.UpdateOne(context.TODO(), m.Schema.GetPri(), m.Schema.GetSchema()) +func (m *MgoColl) Save() error { + _, err := m.coll.UpdateOne(context.TODO(), m.Schema.GetPri(), bson.D{{"$set", m.Schema.GetSchema()}}) if err != nil { return err } return nil } -func (m *MgoColl) Load() error{ +func (m *MgoColl) Load() error { r := m.coll.FindOne(context.TODO(), m.Schema.GetPri()) err := r.Decode(m.Schema.GetSchema()) if err != nil { @@ -72,7 +72,7 @@ func (m *MgoColl) FindOne() error { return singleResult.Decode(m.Schema.GetSchema()) } -func (m *MgoColl) UpdateOne(filter interface{}, update interface{})*mongo.UpdateResult { +func (m *MgoColl) UpdateOne(filter interface{}, update interface{}) *mongo.UpdateResult { res, err := m.coll.UpdateOne(context.TODO(), filter, bson.D{{"$set", update}}) if err != nil { return nil @@ -86,23 +86,23 @@ func (m *MgoColl) UpdateProperty(key string, val interface{}) error { } func (m *MgoColl) UpdateProperties(properties map[string]interface{}) error { - _, err := m.coll.UpdateOne(context.TODO(), m.Schema.GetPri(), properties) + _, err := m.coll.UpdateOne(context.TODO(), m.Schema.GetPri(), bson.D{{"$set", properties}}) return err } //索引 -func (m *MgoColl) SetUnique(key string) (string, error){ +func (m *MgoColl) SetUnique(key string) (string, error) { return m.coll.Indexes().CreateOne( context.Background(), mongo.IndexModel{ - Keys : bsonx.Doc{{key, bsonx.Int32(1)}}, + Keys: bsonx.Doc{{key, bsonx.Int32(1)}}, Options: options.Index().SetUnique(true), }, ) } func (m *MgoColl) Delete(key string, value interface{}) int64 { - filter := bson.D{ {key, value}} + filter := bson.D{{key, value}} count, err := m.coll.DeleteOne(context.TODO(), filter, nil) if err != nil { fmt.Println(err) diff --git a/conf/conf.yaml b/conf/conf.yaml index 9fadefb..5e34a2c 100644 --- a/conf/conf.yaml +++ b/conf/conf.yaml @@ -35,7 +35,7 @@ server_game: id: "2" name: "game" ip: "192.168.0.206" - encipher: true + encipher: false port: 8850 pool_size: 1 debugport: 6061 diff --git a/models/role.go b/models/role.go index e1aeb78..aa6288a 100644 --- a/models/role.go +++ b/models/role.go @@ -103,7 +103,7 @@ func (m *RoleModel) InitRole() { func (m *RoleModel) LoadHero() { heros := make([]*pb.Hero, 10) - err := mongoproxy.FindMany("hero", "role_id", m.Role.Id, &heros) + err := mongoproxy.FindMany("hero", "roleid", m.Role.Id, &heros) if err != nil { logger.Error(err) return @@ -115,7 +115,7 @@ func (m *RoleModel) LoadHero() { func (m *RoleModel) LoadTeams() { teams := make([]*pb.Team, 4) - err := mongoproxy.FindMany("team", "role_id", m.Role.Id, &teams) + err := mongoproxy.FindMany("team", "roleid", m.Role.Id, &teams) if err != nil { logger.Error(err) return @@ -188,6 +188,16 @@ func (m *RoleModel) AddTeam(team *pb.Team) { m.Teams[team.Id] = t } +func (m *RoleModel) UpdateTeam(teams []*pb.Team) { + for _, team := range teams { + team.RoleId = m.Role.Id + t := m.Teams[team.Id] + if t != nil { + t.UpdateSchema(team) + } + } +} + func (m *RoleModel) OnRecoverTimer(now int64) { m.saveRoleData(now) } diff --git a/models/role_test.go b/models/role_test.go index e567eee..6fbdf58 100644 --- a/models/role_test.go +++ b/models/role_test.go @@ -82,3 +82,23 @@ func TestRoleModel_ProtoReflect(t *testing.T) { sch.UpdateProperty(nil, "Device", "123123123", false) fmt.Println(sch.Role) } +func TestRoleModel_UpdateTeam(t *testing.T) { + err := mongoproxy.ConnectMongo(common.GlobalConf.GameConf.MongoConf) + if err != nil { + logger.Error(err) + return + } + sch := NewRole("1") + sch.Load() + sch.LoadAll() + sch.UpdateTeam([]*pb.Team{ + &pb.Team{ + Id: "147262174025748480", + RoleId: "", + HeroId1: "", + HeroId2: "", + HeroId3: "", + }, + }) + sch.OnOfflineEvent() +} diff --git a/models/schema.go b/models/schema.go index d82c038..f3ae9fb 100644 --- a/models/schema.go +++ b/models/schema.go @@ -43,7 +43,11 @@ func NewSchema(key string, schema interface{}) *Schema { } for i := 0; i < s.Type().NumField(); i++ { - sch.reflectIndex[strings.ToLower(s.Type().Field(i).Name)] = i + name := s.Type().Field(i).Name + if strings.Compare(name[0:1], strings.ToLower(name[0:1])) == 0 { + continue + } + sch.reflectIndex[strings.ToLower(strings.ToLower(name))] = i } sch.db = mongoproxy.NewMongoColl(sch.GetSchemaName(), sch) @@ -95,6 +99,20 @@ func (s *Schema) GetSchemaName() string { return strings.ToLower(s.reflectValue.Type().Name()) } +func (s *Schema) UpdateSchema(schema interface{}) { + sch := reflect.ValueOf(schema) + if sch.Kind() == reflect.Ptr { + sch = reflect.ValueOf(schema).Elem() + } + for i := 0; i < sch.Type().NumField(); i++ { + name := sch.Type().Field(i).Name + if _, ok := s.reflectIndex[strings.ToLower(name)]; !ok { + continue + } + s.SetProperty(sch.Type().Field(i).Name, sch.Field(i).Interface()) + } +} + func (s *Schema) Load() error { return s.db.Load() } @@ -104,17 +122,15 @@ func (s *Schema) Create() error { return err } -func (s *Schema) Save() error { - return s.db.Save() -} - +//更新缓存字段到数据库 func (s *Schema) Update() { - if s.cacheFields != nil { + if len(s.cacheFields) > 0 { s.db.UpdateProperties(s.cacheFields) s.cacheFields = make(map[string]interface{}) } } +//更新内存,并把字段缓存 func (s *Schema) SetProperty(key string, val interface{}) { idx, ok := s.reflectIndex[strings.ToLower(key)] if !ok { @@ -124,6 +140,7 @@ func (s *Schema) SetProperty(key string, val interface{}) { s.cacheFields[strings.ToLower(key)] = val } +//更新内存,并把字段缓存 func (s *Schema) SetProperties(properties map[string]interface{}) { for key, val := range properties { idx, ok := s.reflectIndex[strings.ToLower(key)] diff --git a/pb/game.pb.go b/pb/game.pb.go index 22f09af..6ca008c 100644 --- a/pb/game.pb.go +++ b/pb/game.pb.go @@ -343,6 +343,53 @@ func (x *UpdateRolePropertyRsp) GetRole() *Role { return nil } +type GoIntoBattleReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Team []*Team `protobuf:"bytes,1,rep,name=team,proto3" json:"team,omitempty"` +} + +func (x *GoIntoBattleReq) Reset() { + *x = GoIntoBattleReq{} + if protoimpl.UnsafeEnabled { + mi := &file_game_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GoIntoBattleReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GoIntoBattleReq) ProtoMessage() {} + +func (x *GoIntoBattleReq) ProtoReflect() protoreflect.Message { + mi := &file_game_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GoIntoBattleReq.ProtoReflect.Descriptor instead. +func (*GoIntoBattleReq) Descriptor() ([]byte, []int) { + return file_game_proto_rawDescGZIP(), []int{6} +} + +func (x *GoIntoBattleReq) GetTeam() []*Team { + if x != nil { + return x.Team + } + return nil +} + var File_game_proto protoreflect.FileDescriptor var file_game_proto_rawDesc = []byte{ @@ -371,8 +418,11 @@ var file_game_proto_rawDesc = []byte{ 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, - 0x65, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x22, 0x33, 0x0a, 0x0f, 0x47, 0x6f, 0x49, 0x6e, 0x74, 0x6f, 0x42, 0x61, 0x74, 0x74, 0x6c, + 0x65, 0x52, 0x65, 0x71, 0x12, 0x20, 0x0a, 0x04, 0x74, 0x65, 0x61, 0x6d, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, 0x54, 0x65, 0x61, 0x6d, + 0x52, 0x04, 0x74, 0x65, 0x61, 0x6d, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, + 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -387,7 +437,7 @@ func file_game_proto_rawDescGZIP() []byte { return file_game_proto_rawDescData } -var file_game_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_game_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_game_proto_goTypes = []interface{}{ (*HeartReq)(nil), // 0: game.HeartReq (*HeartRsp)(nil), // 1: game.HeartRsp @@ -395,20 +445,22 @@ var file_game_proto_goTypes = []interface{}{ (*CreateReq)(nil), // 3: game.CreateReq (*RoleRsp)(nil), // 4: game.RoleRsp (*UpdateRolePropertyRsp)(nil), // 5: game.UpdateRolePropertyRsp - (*Role)(nil), // 6: models.Role - (*Hero)(nil), // 7: models.Hero - (*Team)(nil), // 8: models.Team + (*GoIntoBattleReq)(nil), // 6: game.GoIntoBattleReq + (*Role)(nil), // 7: models.Role + (*Hero)(nil), // 8: models.Hero + (*Team)(nil), // 9: models.Team } var file_game_proto_depIdxs = []int32{ - 6, // 0: game.RoleRsp.role:type_name -> models.Role - 7, // 1: game.RoleRsp.hero:type_name -> models.Hero - 8, // 2: game.RoleRsp.team:type_name -> models.Team - 6, // 3: game.UpdateRolePropertyRsp.role:type_name -> models.Role - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 7, // 0: game.RoleRsp.role:type_name -> models.Role + 8, // 1: game.RoleRsp.hero:type_name -> models.Hero + 9, // 2: game.RoleRsp.team:type_name -> models.Team + 7, // 3: game.UpdateRolePropertyRsp.role:type_name -> models.Role + 9, // 4: game.GoIntoBattleReq.team:type_name -> models.Team + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_game_proto_init() } @@ -490,6 +542,18 @@ func file_game_proto_init() { return nil } } + file_game_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GoIntoBattleReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -497,7 +561,7 @@ func file_game_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_game_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 7, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/protocode.pb.go b/pb/protocode.pb.go index 9d59502..dacd5e7 100644 --- a/pb/protocode.pb.go +++ b/pb/protocode.pb.go @@ -24,33 +24,39 @@ type ProtoCode int32 const ( ProtoCode_UNKNOWN ProtoCode = 0 - ProtoCode_HeartReq ProtoCode = 1 - ProtoCode_HeartRsp ProtoCode = 2 - ProtoCode_LoginReq ProtoCode = 3 - ProtoCode_CreateReq ProtoCode = 4 - ProtoCode_RoleRsp ProtoCode = 5 - ProtoCode_UpdateRolePropertyRsp ProtoCode = 6 + ProtoCode_LoginRsp ProtoCode = 1 + ProtoCode_HeartReq ProtoCode = 2 + ProtoCode_HeartRsp ProtoCode = 3 + ProtoCode_LoginReq ProtoCode = 4 + ProtoCode_CreateReq ProtoCode = 5 + ProtoCode_RoleRsp ProtoCode = 6 + ProtoCode_UpdateRolePropertyRsp ProtoCode = 7 + ProtoCode_GoIntoBattleReq ProtoCode = 8 ) // Enum value maps for ProtoCode. var ( ProtoCode_name = map[int32]string{ 0: "UNKNOWN", - 1: "HeartReq", - 2: "HeartRsp", - 3: "LoginReq", - 4: "CreateReq", - 5: "RoleRsp", - 6: "UpdateRolePropertyRsp", + 1: "LoginRsp", + 2: "HeartReq", + 3: "HeartRsp", + 4: "LoginReq", + 5: "CreateReq", + 6: "RoleRsp", + 7: "UpdateRolePropertyRsp", + 8: "GoIntoBattleReq", } ProtoCode_value = map[string]int32{ "UNKNOWN": 0, - "HeartReq": 1, - "HeartRsp": 2, - "LoginReq": 3, - "CreateReq": 4, - "RoleRsp": 5, - "UpdateRolePropertyRsp": 6, + "LoginRsp": 1, + "HeartReq": 2, + "HeartRsp": 3, + "LoginReq": 4, + "CreateReq": 5, + "RoleRsp": 6, + "UpdateRolePropertyRsp": 7, + "GoIntoBattleReq": 8, } ) @@ -85,16 +91,18 @@ var File_protocode_proto protoreflect.FileDescriptor var file_protocode_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2a, 0x79, 0x0a, 0x09, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, - 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x48, 0x65, 0x61, 0x72, 0x74, 0x52, - 0x65, 0x71, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x48, 0x65, 0x61, 0x72, 0x74, 0x52, 0x73, 0x70, - 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x10, 0x03, - 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x10, 0x04, 0x12, - 0x0b, 0x0a, 0x07, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x73, 0x70, 0x10, 0x05, 0x12, 0x19, 0x0a, 0x15, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, - 0x74, 0x79, 0x52, 0x73, 0x70, 0x10, 0x06, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x62, - 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2a, 0x9c, 0x01, 0x0a, + 0x09, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, + 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, + 0x52, 0x73, 0x70, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x48, 0x65, 0x61, 0x72, 0x74, 0x52, 0x65, + 0x71, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x48, 0x65, 0x61, 0x72, 0x74, 0x52, 0x73, 0x70, 0x10, + 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x10, 0x04, 0x12, + 0x0d, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x10, 0x05, 0x12, 0x0b, + 0x0a, 0x07, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x73, 0x70, 0x10, 0x06, 0x12, 0x19, 0x0a, 0x15, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, + 0x79, 0x52, 0x73, 0x70, 0x10, 0x07, 0x12, 0x13, 0x0a, 0x0f, 0x47, 0x6f, 0x49, 0x6e, 0x74, 0x6f, + 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x10, 0x08, 0x42, 0x0a, 0x5a, 0x08, 0x2e, + 0x2e, 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/protos b/protos index 43bf509..0039125 160000 --- a/protos +++ b/protos @@ -1 +1 @@ -Subproject commit 43bf509f59c5aa87099fff52e0eeede70b0fe7d4 +Subproject commit 003912502b9da983fa9c33b1890f9830b625e21a diff --git a/tools/protostostruct.go b/tools/protostostruct.go index 6212a76..013dbbb 100644 --- a/tools/protostostruct.go +++ b/tools/protostostruct.go @@ -1,3 +1,4 @@ +//弃用 使用python3重写了。 package main import ( -- libgit2 0.21.2