Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into meixiongfeng

This commit is contained in:
meixiongfeng 2022-07-14 14:20:07 +08:00
commit dd1ba19d30
23 changed files with 683 additions and 213 deletions

View File

@ -78,4 +78,6 @@ type IRPCXService interface {
RegisterFunctionName(name string, fn interface{}) (err error) RegisterFunctionName(name string, fn interface{}) (err error)
RpcCall(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) RpcCall(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error)
RpcGo(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (call *client.Call, err error) RpcGo(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (call *client.Call, err error)
AcrossClusterRpcCall(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error)
AcrossClusterRpcGo(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (call *client.Call, err error)
} }

View File

@ -12,6 +12,7 @@ import (
"go_dreamfactory/lego/sys/event" "go_dreamfactory/lego/sys/event"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/sys/rpcx" "go_dreamfactory/lego/sys/rpcx"
"github.com/smallnest/rpcx/client" "github.com/smallnest/rpcx/client"
) )
@ -156,3 +157,25 @@ func (this *RPCXService) RpcCall(ctx context.Context, servicePath string, servic
func (this *RPCXService) RpcGo(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (call *client.Call, err error) { func (this *RPCXService) RpcGo(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (call *client.Call, err error) {
return rpcx.Go(ctx, servicePath, serviceMethod, args, reply, nil) return rpcx.Go(ctx, servicePath, serviceMethod, args, reply, nil)
} }
///跨集群 同步 执行目标远程服务方法
//clusterTag 集群标签
///servicePath = worker 表示采用负载的方式调用 worker类型服务执行rpc方法
///servicePath = worker/worker_1 表示寻找目标服务节点调用rpc方法
///servicePath = worker/!worker_1 表示选择非worker_1的节点随机选择节点执行rpc方法
///servicePath = worker/[worker_1,worker_2] 表示随机选择[]里面的服务节点执行rpc方法
///servicePath = worker/![worker_1,worker_2] 表示随机选择非[]里面的服务节点执行rpc方法
func (this *RPCXService) AcrossClusterRpcCall(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) {
return rpcx.Call(ctx, servicePath, serviceMethod, args, reply)
}
///跨集群 异步 执行目标远程服务方法
//clusterTag 集群标签
///servicePath = worker 表示采用负载的方式调用 worker类型服务执行rpc方法
///servicePath = worker/worker_1 表示寻找目标服务节点调用rpc方法
///servicePath = worker/!worker_1 表示选择非worker_1的节点随机选择节点执行rpc方法
///servicePath = worker/[worker_1,worker_2] 表示随机选择[]里面的服务节点执行rpc方法
///servicePath = worker/![worker_1,worker_2] 表示随机选择非[]里面的服务节点执行rpc方法
func (this *RPCXService) AcrossClusterRpcGo(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (call *client.Call, err error) {
return rpcx.Go(ctx, servicePath, serviceMethod, args, reply, nil)
}

View File

@ -18,11 +18,12 @@ import (
"github.com/smallnest/rpcx/share" "github.com/smallnest/rpcx/share"
) )
func newClient(options Options) (sys *Client, err error) { func newClient(options *Options) (sys *Client, err error) {
sys = &Client{ sys = &Client{
options: options, options: options,
metadata: fmt.Sprintf("stype=%s&sid=%s&version=%s&addr=%s", options.ServiceType, options.ServiceId, options.ServiceVersion, "tcp@"+options.ServiceAddr), metadata: fmt.Sprintf("stag=%s&stype=%s&sid=%s&version=%s&addr=%s", options.ServiceTag, options.ServiceType, options.ServiceId, options.ServiceVersion, "tcp@"+options.ServiceAddr),
clients: make(map[string]client.XClient), clients: make(map[string]client.XClient),
otherClusterClients: make(map[string]map[string]client.XClient),
conns: make(map[string]net.Conn), conns: make(map[string]net.Conn),
connecting: make(map[string]struct{}), connecting: make(map[string]struct{}),
serviceMap: make(map[string]*service), serviceMap: make(map[string]*service),
@ -32,11 +33,12 @@ func newClient(options Options) (sys *Client, err error) {
} }
type Client struct { type Client struct {
options Options options *Options
metadata string metadata string
writeTimeout time.Duration writeTimeout time.Duration
AsyncWrite bool AsyncWrite bool
clients map[string]client.XClient clients map[string]client.XClient
otherClusterClients map[string]map[string]client.XClient //其他集群客户端
connsMapMu sync.RWMutex connsMapMu sync.RWMutex
conns map[string]net.Conn conns map[string]net.Conn
connectMapMu sync.RWMutex connectMapMu sync.RWMutex
@ -132,6 +134,7 @@ func (this *Client) Call(ctx context.Context, servicePath string, serviceMethod
this.clients[spath[0]] = c this.clients[spath[0]] = c
} }
ctx = context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{ ctx = context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{
ServiceClusterTag: this.options.ServiceTag,
CallRoutRulesKey: servicePath, CallRoutRulesKey: servicePath,
ServiceAddrKey: "tcp@" + this.options.ServiceAddr, ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
ServiceMetaKey: this.metadata, ServiceMetaKey: this.metadata,
@ -164,6 +167,90 @@ func (this *Client) Go(ctx context.Context, servicePath string, serviceMethod st
this.clients[spath[0]] = c this.clients[spath[0]] = c
} }
ctx = context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{ ctx = context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{
ServiceClusterTag: this.options.ServiceTag,
CallRoutRulesKey: servicePath,
ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
ServiceMetaKey: this.metadata,
})
return c.Go(ctx, string(serviceMethod), args, reply, done)
}
//跨集群 同步调用
func (this *Client) AcrossClusterCall(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) {
if servicePath == "" {
err = errors.New("servicePath no cant null")
return
}
var (
spath []string
clients map[string]client.XClient
d *client.ConsulDiscovery
c client.XClient
ok bool
)
spath = strings.Split(servicePath, "/")
if clients, ok = this.otherClusterClients[clusterTag]; !ok {
this.otherClusterClients[clusterTag] = make(map[string]client.XClient)
clients = this.otherClusterClients[clusterTag]
} else {
if c, ok = clients[spath[0]]; !ok {
if d, err = client.NewConsulDiscovery(clusterTag, spath[0], this.options.ConsulServers, nil); err != nil {
return
}
c = client.NewBidirectionalXClient(spath[0], client.Failfast, client.RandomSelect, d, client.DefaultOption, this.msgChan)
c.GetPlugins().Add(this)
if this.options.RpcxStartType == RpcxStartByClient && this.options.AutoConnect {
c.SetSelector(newSelector(this.UpdateServer))
} else {
c.SetSelector(newSelector(nil))
}
clients[spath[0]] = c
}
}
ctx = context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{
ServiceClusterTag: clusterTag,
CallRoutRulesKey: servicePath,
ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
ServiceMetaKey: this.metadata,
})
err = c.Call(ctx, serviceMethod, args, reply)
return
}
//跨集群 异步调用
func (this *Client) AcrossClusterGo(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (call *client.Call, err error) {
if servicePath == "" {
err = errors.New("servicePath no cant null")
return
}
var (
spath []string
clients map[string]client.XClient
d *client.ConsulDiscovery
c client.XClient
ok bool
)
spath = strings.Split(servicePath, "/")
if clients, ok = this.otherClusterClients[clusterTag]; !ok {
this.otherClusterClients[clusterTag] = make(map[string]client.XClient)
clients = this.otherClusterClients[clusterTag]
} else {
if c, ok = clients[spath[0]]; !ok {
if d, err = client.NewConsulDiscovery(clusterTag, spath[0], this.options.ConsulServers, nil); err != nil {
return
}
c = client.NewBidirectionalXClient(spath[0], client.Failfast, client.RandomSelect, d, client.DefaultOption, this.msgChan)
c.GetPlugins().Add(this)
if this.options.RpcxStartType == RpcxStartByClient && this.options.AutoConnect {
c.SetSelector(newSelector(this.UpdateServer))
} else {
c.SetSelector(newSelector(nil))
}
clients[spath[0]] = c
}
}
ctx = context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{
ServiceClusterTag: this.options.ServiceTag,
CallRoutRulesKey: servicePath, CallRoutRulesKey: servicePath,
ServiceAddrKey: "tcp@" + this.options.ServiceAddr, ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
ServiceMetaKey: this.metadata, ServiceMetaKey: this.metadata,

View File

@ -10,6 +10,7 @@ import (
) )
const ( const (
ServiceClusterTag = "ctag"
ServiceMetaKey = "smeta" ServiceMetaKey = "smeta"
ServiceAddrKey = "addr" ServiceAddrKey = "addr"
CallRoutRulesKey = "callrules" CallRoutRulesKey = "callrules"
@ -26,6 +27,8 @@ type (
UnregisterAll() (err error) UnregisterAll() (err error)
Call(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) Call(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error)
Go(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (call *client.Call, err error) Go(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (call *client.Call, err error)
AcrossClusterCall(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error)
AcrossClusterGo(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (call *client.Call, err error)
} }
) )
@ -33,18 +36,18 @@ var (
defsys ISys defsys ISys
) )
func OnInit(config map[string]interface{}, option ...Option) (err error) { func OnInit(config map[string]interface{}, opt ...Option) (err error) {
var options Options var options *Options
if options, err = newOptions(config, option...); err != nil { if options, err = newOptions(config, opt...); err != nil {
return return
} }
defsys, err = newSys(options) defsys, err = newSys(options)
return return
} }
func NewSys(option ...Option) (sys ISys, err error) { func NewSys(opt ...Option) (sys ISys, err error) {
var options Options var options *Options
if options, err = newOptionsByOption(option...); err != nil { if options, err = newOptionsByOption(opt...); err != nil {
return return
} }
sys, err = newSys(options) sys, err = newSys(options)
@ -92,6 +95,12 @@ func smetaToServiceNode(meta string) (node *ServiceNode, err error) {
data[k] = v[0] data[k] = v[0]
} }
} }
if stag, ok := data["stag"]; !ok {
err = fmt.Errorf("no found stag")
return
} else {
node.ServiceTag = stag
}
if sid, ok := data["sid"]; !ok { if sid, ok := data["sid"]; !ok {
err = fmt.Errorf("no found sid") err = fmt.Errorf("no found sid")
return return

View File

@ -85,37 +85,45 @@ func SetLog(v log.ILog) Option {
} }
} }
func newOptions(config map[string]interface{}, opts ...Option) (Options, error) { func newOptions(config map[string]interface{}, opts ...Option) (options *Options, err error) {
options := Options{ options = &Options{
AutoConnect: true, AutoConnect: true,
SerializeType: protocol.MsgPack, SerializeType: protocol.MsgPack,
Debug: true,
Log: log.Clone(log.SetLoglayer(2)),
} }
if config != nil { if config != nil {
mapstructure.Decode(config, &options) mapstructure.Decode(config, options)
} }
for _, o := range opts { for _, o := range opts {
o(&options) o(options)
} }
if len(options.ServiceTag) == 0 || len(options.ServiceType) == 0 || len(options.ServiceId) == 0 || len(options.ConsulServers) == 0 { if len(options.ServiceTag) == 0 || len(options.ServiceType) == 0 || len(options.ServiceId) == 0 || len(options.ConsulServers) == 0 {
return options, errors.New("[Sys.RPCX] newOptions err: 启动参数异常") return options, errors.New("[Sys.RPCX] newOptions err: 启动参数异常")
} }
if options.Debug && options.Log == nil {
if options.Log = log.Clone(log.SetLoglayer(2)); options.Log == nil {
err = errors.New("log is nil")
}
}
return options, nil return options, nil
} }
func newOptionsByOption(opts ...Option) (Options, error) { func newOptionsByOption(opts ...Option) (options *Options, err error) {
options := Options{ options = &Options{
AutoConnect: true, AutoConnect: true,
SerializeType: protocol.MsgPack, SerializeType: protocol.MsgPack,
Debug: true, Debug: true,
Log: log.Clone(log.SetLoglayer(2)), Log: log.Clone(log.SetLoglayer(2)),
} }
for _, o := range opts { for _, o := range opts {
o(&options) o(options)
} }
if len(options.ServiceTag) == 0 || len(options.ServiceType) == 0 || len(options.ServiceId) == 0 || len(options.ConsulServers) == 0 { if len(options.ServiceTag) == 0 || len(options.ServiceType) == 0 || len(options.ServiceId) == 0 || len(options.ConsulServers) == 0 {
return options, errors.New("[Sys.RPCX] newOptions err: 启动参数异常") return options, errors.New("[Sys.RPCX] newOptions err: 启动参数异常")
} }
if options.Debug && options.Log == nil {
if options.Log = log.Clone(log.SetLoglayer(2)); options.Log == nil {
err = errors.New("log is nil")
}
}
return options, nil return options, nil
} }

View File

@ -6,7 +6,7 @@ import (
"github.com/smallnest/rpcx/client" "github.com/smallnest/rpcx/client"
) )
func newSys(options Options) (sys ISys, err error) { func newSys(options *Options) (sys ISys, err error) {
if options.RpcxStartType == RpcxStartByService { //创建RPCX 服务端 if options.RpcxStartType == RpcxStartByService { //创建RPCX 服务端
sys, err = newService(options) sys, err = newService(options)
return return
@ -69,3 +69,13 @@ func (this *RPCX) Call(ctx context.Context, servicePath string, serviceMethod st
func (this *RPCX) Go(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (call *client.Call, err error) { func (this *RPCX) Go(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (call *client.Call, err error) {
return this.client.Go(ctx, servicePath, serviceMethod, args, reply, done) return this.client.Go(ctx, servicePath, serviceMethod, args, reply, done)
} }
//跨服同步调用
func (this *RPCX) AcrossClusterCall(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) {
return this.client.AcrossClusterCall(ctx, clusterTag, servicePath, serviceMethod, args, reply)
}
//跨服异步调用
func (this *RPCX) AcrossClusterGo(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (call *client.Call, err error) {
return this.client.AcrossClusterGo(ctx, clusterTag, servicePath, serviceMethod, args, reply, done)
}

View File

@ -24,6 +24,7 @@ func newSelector(fn func(map[string]*ServiceNode)) *Selector {
} }
type ServiceNode struct { type ServiceNode struct {
ServiceTag string `json:"stag"` //服务集群标签
ServiceId string `json:"sid"` //服务id ServiceId string `json:"sid"` //服务id
ServiceType string `json:"stype"` //服务类型 ServiceType string `json:"stype"` //服务类型
Version string `json:"version"` //服务版本 Version string `json:"version"` //服务版本

View File

@ -18,12 +18,12 @@ import (
"github.com/smallnest/rpcx/share" "github.com/smallnest/rpcx/share"
) )
func newService(options Options) (sys *Service, err error) { func newService(options *Options) (sys *Service, err error) {
sys = &Service{ sys = &Service{
options: options, options: options,
metadata: fmt.Sprintf("stype=%s&sid=%s&version=%s&addr=%s", options.ServiceType, options.ServiceId, options.ServiceVersion, "tcp@"+options.ServiceAddr), metadata: fmt.Sprintf("stag=%s&stype=%s&sid=%s&version=%s&addr=%s", options.ServiceTag, options.ServiceType, options.ServiceId, options.ServiceVersion, "tcp@"+options.ServiceAddr),
server: server.NewServer(), server: server.NewServer(),
selector: newSelector(nil), selectors: make(map[string]client.Selector),
clients: make(map[string]net.Conn), clients: make(map[string]net.Conn),
clientmeta: make(map[string]string), clientmeta: make(map[string]string),
pending: make(map[uint64]*client.Call), pending: make(map[uint64]*client.Call),
@ -46,10 +46,10 @@ func newService(options Options) (sys *Service, err error) {
} }
type Service struct { type Service struct {
options Options options *Options
metadata string metadata string
server *server.Server server *server.Server
selector client.Selector selectors map[string]client.Selector
clientmutex sync.Mutex clientmutex sync.Mutex
clients map[string]net.Conn clients map[string]net.Conn
clientmeta map[string]string clientmeta map[string]string
@ -100,7 +100,7 @@ func (this *Service) Call(ctx context.Context, servicePath string, serviceMethod
) )
seq := new(uint64) seq := new(uint64)
ctx = context.WithValue(ctx, seqKey{}, seq) ctx = context.WithValue(ctx, seqKey{}, seq)
if conn, done, err = this.call(ctx, servicePath, serviceMethod, args, reply, make(chan *client.Call, 1)); err != nil { if conn, done, err = this.call(ctx, this.options.ServiceTag, servicePath, serviceMethod, args, reply, make(chan *client.Call, 1)); err != nil {
return return
} }
select { select {
@ -130,13 +130,65 @@ func (this *Service) Call(ctx context.Context, servicePath string, serviceMethod
//异步调用 远程服务 //异步调用 远程服务
func (this *Service) Go(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (_call *client.Call, err error) { func (this *Service) Go(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (_call *client.Call, err error) {
_, _call, err = this.call(ctx, servicePath, serviceMethod, args, reply, done) _, _call, err = this.call(ctx, this.options.ServiceTag, servicePath, serviceMethod, args, reply, done)
return
}
//跨服 同步调用 远程服务
func (this *Service) AcrossClusterCall(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) {
var (
done *client.Call
conn net.Conn
)
seq := new(uint64)
ctx = context.WithValue(ctx, seqKey{}, seq)
if conn, done, err = this.call(ctx, clusterTag, servicePath, serviceMethod, args, reply, make(chan *client.Call, 1)); err != nil {
return
}
select {
case <-ctx.Done(): // cancel by context
this.mutex.Lock()
call := this.pending[*seq]
delete(this.pending, *seq)
this.mutex.Unlock()
if call != nil {
call.Error = ctx.Err()
call.Done <- call
}
return ctx.Err()
case call := <-done.Done:
err = call.Error
meta := ctx.Value(share.ResMetaDataKey)
if meta != nil && len(call.ResMetadata) > 0 {
resMeta := meta.(map[string]string)
for k, v := range call.ResMetadata {
resMeta[k] = v
}
resMeta[share.ServerAddress] = conn.RemoteAddr().String()
}
}
return
}
//跨服 异步调用 远程服务
func (this *Service) AcrossClusterGo(ctx context.Context, clusterTag, servicePath string, serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (_call *client.Call, err error) {
_, _call, err = this.call(ctx, clusterTag, servicePath, serviceMethod, args, reply, done)
return return
} }
//监听客户端链接到服务上 保存客户端的连接对象 //监听客户端链接到服务上 保存客户端的连接对象
func (this *Service) PreHandleRequest(ctx context.Context, r *protocol.Message) error { func (this *Service) PreHandleRequest(ctx context.Context, r *protocol.Message) error {
var (
stag string
selector client.Selector
ok bool
)
req_metadata := ctx.Value(share.ReqMetaDataKey).(map[string]string) req_metadata := ctx.Value(share.ReqMetaDataKey).(map[string]string)
if stag, ok = req_metadata[ServiceClusterTag]; ok {
if selector, ok = this.selectors[stag]; !ok {
this.selectors[stag] = newSelector(nil)
selector = this.selectors[stag]
}
if addr, ok := req_metadata[ServiceAddrKey]; ok { if addr, ok := req_metadata[ServiceAddrKey]; ok {
if _, ok = this.clientmeta[addr]; !ok { if _, ok = this.clientmeta[addr]; !ok {
if smeta, ok := req_metadata[ServiceMetaKey]; ok { if smeta, ok := req_metadata[ServiceMetaKey]; ok {
@ -148,11 +200,12 @@ func (this *Service) PreHandleRequest(ctx context.Context, r *protocol.Message)
servers[k] = v servers[k] = v
} }
this.clientmutex.Unlock() this.clientmutex.Unlock()
this.selector.UpdateServer(servers) selector.UpdateServer(servers)
this.Debugf("fond new node addr:%s smeta:%s \n", addr, smeta) this.Debugf("fond new node addr:%s smeta:%s \n", addr, smeta)
} }
} }
} }
}
return nil return nil
} }
@ -247,11 +300,12 @@ func (this *Service) Fatalf(format string, a ...interface{}) {
} }
//执行远程调用 //执行远程调用
func (this *Service) call(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (conn net.Conn, _call *client.Call, err error) { func (this *Service) call(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (conn net.Conn, _call *client.Call, err error) {
var ( var (
spath []string spath []string
clientaddr string clientaddr string
metadata map[string]string metadata map[string]string
selector client.Selector
ok bool ok bool
) )
if servicePath == "" { if servicePath == "" {
@ -259,6 +313,7 @@ func (this *Service) call(ctx context.Context, servicePath string, serviceMethod
return return
} }
metadata = map[string]string{ metadata = map[string]string{
ServiceClusterTag: clusterTag,
CallRoutRulesKey: servicePath, CallRoutRulesKey: servicePath,
ServiceAddrKey: "tcp@" + this.options.ServiceAddr, ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
ServiceMetaKey: this.metadata, ServiceMetaKey: this.metadata,
@ -269,7 +324,10 @@ func (this *Service) call(ctx context.Context, servicePath string, serviceMethod
ServiceAddrKey: "tcp@" + this.options.ServiceAddr, ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
ServiceMetaKey: this.metadata, ServiceMetaKey: this.metadata,
}) })
if clientaddr = this.selector.Select(ctx, spath[0], serviceMethod, args); clientaddr == "" { if selector, ok = this.selectors[clusterTag]; !ok {
err = fmt.Errorf("on found serviceTag:%s", clusterTag)
}
if clientaddr = selector.Select(ctx, spath[0], serviceMethod, args); clientaddr == "" {
err = fmt.Errorf("on found servicePath:%s", servicePath) err = fmt.Errorf("on found servicePath:%s", servicePath)
return return
} }

View File

@ -65,7 +65,7 @@ func (this *modelEquipmentComp) QueryEquipmentAmount(uid string, equipmentId int
} }
//添加装备 //添加装备
func (this *modelEquipmentComp) AddEquipments(uId string, cIds map[int32]uint32) (err error) { func (this *modelEquipmentComp) AddEquipments(uId string, cIds map[int32]uint32) (change []*pb.DB_Equipment, err error) {
var ( var (
configure *cfg.Game_equip configure *cfg.Game_equip
equipments []*pb.DB_Equipment equipments []*pb.DB_Equipment
@ -81,11 +81,13 @@ func (this *modelEquipmentComp) AddEquipments(uId string, cIds map[int32]uint32)
} }
add = make(map[string]*pb.DB_Equipment) add = make(map[string]*pb.DB_Equipment)
update = make(map[string]*pb.DB_Equipment) update = make(map[string]*pb.DB_Equipment)
change = make([]*pb.DB_Equipment, len(equipments))
for k, v := range cIds { for k, v := range cIds {
iskeep = false iskeep = false
for _, equipment := range equipments { for _, equipment := range equipments {
if equipment.CId == k && equipment.IsInitialState { if equipment.CId == k && equipment.IsInitialState {
update[equipment.Id] = equipment update[equipment.Id] = equipment
change = append(change, equipment)
equipment.OverlayNum += v equipment.OverlayNum += v
iskeep = true iskeep = true
break break
@ -94,9 +96,10 @@ func (this *modelEquipmentComp) AddEquipments(uId string, cIds map[int32]uint32)
if !iskeep { if !iskeep {
if c, ok := configure.GetDataMap()[k]; ok { if c, ok := configure.GetDataMap()[k]; ok {
if equipment, err := this.newEquipment(uId, c, v); err != nil { if equipment, err := this.newEquipment(uId, c, v); err != nil {
return err return nil, err
} else { } else {
add[equipment.Id] = equipment add[equipment.Id] = equipment
change = append(change, equipment)
} }
} }
} }

View File

@ -81,10 +81,27 @@ func (this *Equipment) QueryEquipmentAmount(source *comm.ModuleCallSource, uid s
//添加武器 //添加武器
func (this *Equipment) AddNewEquipments(source *comm.ModuleCallSource, uid string, cIds map[int32]uint32) (code pb.ErrorCode) { func (this *Equipment) AddNewEquipments(source *comm.ModuleCallSource, uid string, cIds map[int32]uint32) (code pb.ErrorCode) {
var err error var (
if err = this.modelEquipment.AddEquipments(uid, cIds); err != nil { err error
change []*pb.DB_Equipment
)
if change, err = this.modelEquipment.AddEquipments(uid, cIds); err != nil {
log.Errorf("err%v", err) log.Errorf("err%v", err)
code = pb.ErrorCode_SystemError code = pb.ErrorCode_SystemError
return
}
if len(change) > 0 {
this.equipmentsChangePush(uid, change)
}
return
}
//Evens--------------------------------------------------------------------------------------------------------------------------------
//推送道具变化消息
func (this *Equipment) equipmentsChangePush(uid string, items []*pb.DB_Equipment) (err error) {
if session, ok := this.GetUserSession(uid); ok {
session.SendMsg(string(this.GetType()), "change", &pb.EquipmentChangePush{Equipments: items})
err = session.Push()
} }
return return
} }

View File

@ -7,6 +7,7 @@ import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/utils" "go_dreamfactory/utils"
"strings"
"sync" "sync"
"sync/atomic" "sync/atomic"
"time" "time"
@ -64,13 +65,13 @@ func (this *Agent) readLoop() {
locp: locp:
for { for {
if _, data, err = this.wsConn.ReadMessage(); err != nil { if _, data, err = this.wsConn.ReadMessage(); err != nil {
log.Errorf("agent:%s uId:%s ReadMessage err:%v", this.sessionId, this.uId, err) this.gateway.Errorf("agent:%s uId:%s ReadMessage err:%v", this.sessionId, this.uId, err)
go this.Close() go this.Close()
break locp break locp
} }
if err = proto.Unmarshal(data, msg); err != nil { if err = proto.Unmarshal(data, msg); err != nil {
log.Errorf("agent:%s uId:%s Unmarshal err:%v", this.sessionId, this.uId, err) this.gateway.Errorf("agent:%s uId:%s Unmarshal err:%v", this.sessionId, this.uId, err)
go this.Close() go this.Close()
break locp break locp
} else { } else {
@ -93,7 +94,7 @@ locp:
} }
} }
} }
log.Debugf("agent:%s uId:%s readLoop end!", this.sessionId, this.uId) this.gateway.Debugf("agent:%s uId:%s readLoop end!", this.sessionId, this.uId)
} }
func (this *Agent) writeLoop() { func (this *Agent) writeLoop() {
@ -111,7 +112,7 @@ locp:
if ok { if ok {
data, err = proto.Marshal(msg) data, err = proto.Marshal(msg)
if err = this.wsConn.WriteMessage(websocket.BinaryMessage, data); err != nil { if err = this.wsConn.WriteMessage(websocket.BinaryMessage, data); err != nil {
log.Errorf("agent:%s uId:%d WriteMessage err:%v", this.sessionId, this.uId, err) this.gateway.Errorf("agent:%s uId:%d WriteMessage err:%v", this.sessionId, this.uId, err)
go this.Close() go this.Close()
} }
} else { } else {
@ -119,7 +120,7 @@ locp:
} }
} }
} }
log.Debugf("agent:%s uId:%s writeLoop end!", this.sessionId, this.uId) this.gateway.Debugf("agent:%s uId:%s writeLoop end!", this.sessionId, this.uId)
} }
//安全认证 所有协议 //安全认证 所有协议
@ -213,17 +214,33 @@ func (this *Agent) Close() {
//分发用户消息 //分发用户消息
func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) { func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) {
reply := &pb.RPCMessageReply{} var (
log.Debugf("agent:%s uId:%s MessageDistribution msg:%s.%s", this.sessionId, this.uId, msg.MainType, msg.SubType) reply *pb.RPCMessageReply = &pb.RPCMessageReply{}
serviceTag string = ""
servicePath string = comm.Service_Worker
rule string
ok bool
)
servicePath := comm.Service_Worker this.gateway.Debugf("agent:%s uId:%s MessageDistribution msg:%s.%s", this.sessionId, this.uId, msg.MainType, msg.SubType)
if rule, ok := this.gateway.GetMsgDistribute(msg.MainType, msg.SubType); ok { if rule, ok = this.gateway.GetMsgDistribute(msg.MainType, msg.SubType); ok {
paths := strings.Split(rule, "/")
if len(paths) == 3 {
serviceTag = paths[0]
servicePath = fmt.Sprintf("%s/%s", paths[1], paths[2])
} else if len(paths) < 3 && len(paths) > 0 {
servicePath = rule servicePath = rule
} else { } else {
if len(this.wId) > 0 { this.gateway.Errorf("messageDistribution rule is empty!")
return
}
} else {
if len(this.wId) > 0 { //已经绑定worker 服务器
servicePath = fmt.Sprintf("%s/%s", comm.Service_Worker, this.wId) servicePath = fmt.Sprintf("%s/%s", comm.Service_Worker, this.wId)
} }
} }
if len(serviceTag) == 0 {
if err = this.gateway.Service().RpcCall(context.Background(), servicePath, string(comm.Rpc_GatewayRoute), &pb.AgentMessage{ if err = this.gateway.Service().RpcCall(context.Background(), servicePath, string(comm.Rpc_GatewayRoute), &pb.AgentMessage{
Ip: this.IP(), Ip: this.IP(),
UserSessionId: this.sessionId, UserSessionId: this.sessionId,
@ -233,9 +250,23 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) {
SubType: msg.SubType, SubType: msg.SubType,
Message: msg.Data, Message: msg.Data,
}, reply); err != nil { }, reply); err != nil {
log.Errorf("agent:%s uId:%s MessageDistribution err:%v", this.sessionId, this.uId, err) this.gateway.Errorf("agent:%s uId:%s MessageDistribution err:%v", this.sessionId, this.uId, err)
return return
} }
} else { //跨集群调用
if err = this.gateway.Service().AcrossClusterRpcCall(context.Background(), serviceTag, servicePath, string(comm.Rpc_GatewayRoute), &pb.AgentMessage{
Ip: this.IP(),
UserSessionId: this.sessionId,
UserId: this.uId,
GatewayServiceId: this.gateway.Service().GetId(),
MainType: msg.MainType,
SubType: msg.SubType,
Message: msg.Data,
}, reply); err != nil {
this.gateway.Errorf("agent:%s uId:%s MessageDistribution err:%v", this.sessionId, this.uId, err)
return
}
}
if reply.Code != pb.ErrorCode_Success { if reply.Code != pb.ErrorCode_Success {
data, _ := anypb.New(&pb.NotifyErrorNotifyPush{ReqMainType: msg.MainType, ReqSubType: msg.SubType, Code: pb.ErrorCode(reply.Code.Number())}) data, _ := anypb.New(&pb.NotifyErrorNotifyPush{ReqMainType: msg.MainType, ReqSubType: msg.SubType, Code: pb.ErrorCode(reply.Code.Number())})
err = this.WriteMsg(&pb.UserMessage{ err = this.WriteMsg(&pb.UserMessage{

View File

@ -5,6 +5,7 @@ import (
"go_dreamfactory/lego/base" "go_dreamfactory/lego/base"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
) )
type ( type (
@ -22,6 +23,7 @@ type (
// IGateway 网关模块 接口定义 // IGateway 网关模块 接口定义
IGateway interface { IGateway interface {
core.IModule core.IModule
log.Ilogf
Service() base.IRPCXService Service() base.IRPCXService
Connect(a IAgent) Connect(a IAgent)
DisConnect(a IAgent) DisConnect(a IAgent)

View File

@ -1,6 +1,7 @@
package gateway package gateway
import ( import (
"fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/base" "go_dreamfactory/lego/base"
@ -22,6 +23,7 @@ func NewModule() core.IModule {
type Gateway struct { type Gateway struct {
cbase.ModuleBase cbase.ModuleBase
options *Options
service base.IRPCXService // rpcx服务接口 主要client->server service base.IRPCXService // rpcx服务接口 主要client->server
wsService *WSServiceComp // websocket服务 监听websocket连接 wsService *WSServiceComp // websocket服务 监听websocket连接
agentMgr *AgentMgrComp // 客户端websocket连接管理 agentMgr *AgentMgrComp // 客户端websocket连接管理
@ -46,6 +48,7 @@ func (this *Gateway) Service() base.IRPCXService {
// Init 模块初始化函数 // Init 模块初始化函数
func (this *Gateway) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { func (this *Gateway) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
err = this.ModuleBase.Init(service, module, options) err = this.ModuleBase.Init(service, module, options)
this.options = options.(*Options)
this.service = service.(base.IRPCXService) this.service = service.(base.IRPCXService)
return return
} }
@ -98,3 +101,35 @@ func (this *Gateway) DisConnect(a IAgent) {
func (this *Gateway) GetMsgDistribute(mtype, stype string) (rule string, ok bool) { func (this *Gateway) GetMsgDistribute(mtype, stype string) (rule string, ok bool) {
return this.configure.GetMsgDistribute(mtype, stype) return this.configure.GetMsgDistribute(mtype, stype)
} }
//日志
func (this *Gateway) Debugf(format string, a ...interface{}) {
if this.options.GetDebug() {
this.options.GetLog().Debugf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...)
}
}
func (this *Gateway) Infof(format string, a ...interface{}) {
if this.options.GetDebug() {
this.options.GetLog().Infof(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...)
}
}
func (this *Gateway) Warnf(format string, a ...interface{}) {
if this.options.Debug {
this.options.GetLog().Warnf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...)
}
}
func (this *Gateway) Errorf(format string, a ...interface{}) {
if this.options.GetLog() != nil {
this.options.GetLog().Errorf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...)
}
}
func (this *Gateway) Panicf(format string, a ...interface{}) {
if this.options.GetLog() != nil {
this.options.GetLog().Panicf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...)
}
}
func (this *Gateway) Fatalf(format string, a ...interface{}) {
if this.options.GetLog() != nil {
this.options.GetLog().Fatalf(fmt.Sprintf("[Module:%s] ", this.GetType())+format, a...)
}
}

View File

@ -2,6 +2,7 @@ package gateway
import ( import (
"go_dreamfactory/lego/utils/mapstructure" "go_dreamfactory/lego/utils/mapstructure"
"go_dreamfactory/modules"
) )
/* /*
@ -10,7 +11,7 @@ import (
type ( type (
Options struct { Options struct {
Debug bool //日志开关 modules.Options
GinDebug bool //web引擎日志开关 GinDebug bool //web引擎日志开关
ListenPort int //websocket 监听端口 ListenPort int //websocket 监听端口
} }
@ -19,6 +20,9 @@ type (
// LoadConfig 配置文件序列化为Options // LoadConfig 配置文件序列化为Options
func (this *Options) LoadConfig(settings map[string]interface{}) (err error) { func (this *Options) LoadConfig(settings map[string]interface{}) (err error) {
if settings != nil { if settings != nil {
if err = this.Options.LoadConfig(settings); err != nil {
return
}
err = mapstructure.Decode(settings, this) err = mapstructure.Decode(settings, this)
} }
return return

View File

@ -23,7 +23,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ItemsGetlistReq)
tempgrids []*pb.DB_UserItemData tempgrids []*pb.DB_UserItemData
grids []*pb.DB_UserItemData grids []*pb.DB_UserItemData
modifys []*pb.DB_UserItemData modifys []*pb.DB_UserItemData
dels []string dels []*pb.DB_UserItemData
) )
defer func() { defer func() {
session.SendMsg(string(this.module.GetType()), "getlist", &pb.ItemsGetlistResp{Grids: grids}) session.SendMsg(string(this.module.GetType()), "getlist", &pb.ItemsGetlistResp{Grids: grids})
@ -46,12 +46,12 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ItemsGetlistReq)
} else { } else {
tempgrids = this.module.configure.GetPackItemByType(items, req.IType) tempgrids = this.module.configure.GetPackItemByType(items, req.IType)
modifys = make([]*pb.DB_UserItemData, 0, len(tempgrids)) modifys = make([]*pb.DB_UserItemData, 0, len(tempgrids))
dels = make([]string, 0, len(tempgrids)) dels = make([]*pb.DB_UserItemData, 0, len(tempgrids))
grids = make([]*pb.DB_UserItemData, 0, len(items)) grids = make([]*pb.DB_UserItemData, 0, len(items))
nt = time.Now().Unix() nt = time.Now().Unix()
for _, v := range tempgrids { for _, v := range tempgrids {
if v.ETime > 0 && v.ETime < nt { //已经过期 if v.ETime > 0 && v.ETime < nt { //已经过期
dels = append(dels, v.GridId) dels = append(dels, v)
} else { } else {
grids = append(grids, v) grids = append(grids, v)
if v.IsNewItem { if v.IsNewItem {

View File

@ -76,7 +76,11 @@ func (this *ModelItemsComp) Pack_UpdateUserPack(uId string, itmes ...*pb.DB_User
} }
//更新用户的背包信息 //更新用户的背包信息
func (this *ModelItemsComp) Pack_DeleteUserPack(uId string, gridIds ...string) (err error) { func (this *ModelItemsComp) Pack_DeleteUserPack(uId string, itmes ...*pb.DB_UserItemData) (err error) {
gridIds := make([]string, len(itmes))
for i, v := range itmes {
gridIds[i] = v.GridId
}
if err = this.DelListlds(uId, gridIds...); err != nil { if err = this.DelListlds(uId, gridIds...); err != nil {
this.module.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
@ -106,11 +110,11 @@ func (this *ModelItemsComp) Pack_QueryUserPackItemsAmount(uId string, itemid ...
} }
///添加或则减少物品到用户背包 ///添加或则减少物品到用户背包
func (this *ModelItemsComp) Pack_AddItemToUserPack(uId string, itemId int32, addnum int32) (err error) { func (this *ModelItemsComp) Pack_AddItemToUserPack(uId string, itemId int32, addnum int32) (change []*pb.DB_UserItemData, err error) {
var ( var (
itmes []*pb.DB_UserItemData itmes []*pb.DB_UserItemData
add []*pb.DB_UserItemData add []*pb.DB_UserItemData
del []string del []*pb.DB_UserItemData
update []*pb.DB_UserItemData update []*pb.DB_UserItemData
leftnum int64 leftnum int64
) )
@ -121,6 +125,7 @@ func (this *ModelItemsComp) Pack_AddItemToUserPack(uId string, itemId int32, add
this.module.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} }
change = make([]*pb.DB_UserItemData, len(itmes))
add, update, del, leftnum = this.pack_addItemToUserPack(itmes, itemId, addnum) add, update, del, leftnum = this.pack_addItemToUserPack(itmes, itemId, addnum)
if leftnum < 0 { if leftnum < 0 {
err = ItemNotEnoughError err = ItemNotEnoughError
@ -134,29 +139,31 @@ func (this *ModelItemsComp) Pack_AddItemToUserPack(uId string, itemId int32, add
this.module.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} }
change = append(change, add...)
} }
if len(del) > 0 { if len(del) > 0 {
if err = this.Pack_DeleteUserPack(uId, del...); err != nil { if err = this.Pack_DeleteUserPack(uId, del...); err != nil {
this.module.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} }
change = append(change, del...)
} }
if len(update) > 0 { if len(update) > 0 {
if err = this.Pack_UpdateUserPack(uId, update...); err != nil { if err = this.Pack_UpdateUserPack(uId, update...); err != nil {
this.module.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} }
change = append(change, update...)
} }
return return
} }
///添加或则减少多个物品到用户背包 ///添加或则减少多个物品到用户背包
func (this *ModelItemsComp) Pack_AddItemsToUserPack(uId string, items map[int32]int32) (err error) { func (this *ModelItemsComp) Pack_AddItemsToUserPack(uId string, items map[int32]int32) (change []*pb.DB_UserItemData, err error) {
var ( var (
itmes []*pb.DB_UserItemData itmes []*pb.DB_UserItemData
add []*pb.DB_UserItemData add []*pb.DB_UserItemData
del []string del []*pb.DB_UserItemData
update []*pb.DB_UserItemData update []*pb.DB_UserItemData
leftnum int64 leftnum int64
) )
@ -164,6 +171,7 @@ func (this *ModelItemsComp) Pack_AddItemsToUserPack(uId string, items map[int32]
this.module.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} }
change = make([]*pb.DB_UserItemData, len(itmes))
for k, v := range items { for k, v := range items {
add, update, del, leftnum = this.pack_addItemToUserPack(itmes, k, v) add, update, del, leftnum = this.pack_addItemToUserPack(itmes, k, v)
if leftnum < 0 { if leftnum < 0 {
@ -178,18 +186,21 @@ func (this *ModelItemsComp) Pack_AddItemsToUserPack(uId string, items map[int32]
this.module.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} }
change = append(change, add...)
} }
if len(del) > 0 { if len(del) > 0 {
if err = this.Pack_DeleteUserPack(uId, del...); err != nil { if err = this.Pack_DeleteUserPack(uId, del...); err != nil {
this.module.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} }
change = append(change, del...)
} }
if len(update) > 0 { if len(update) > 0 {
if err = this.Pack_UpdateUserPack(uId, update...); err != nil { if err = this.Pack_UpdateUserPack(uId, update...); err != nil {
this.module.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} }
change = append(change, update...)
} }
} }
return return
@ -237,7 +248,7 @@ func (this *ModelItemsComp) Pack_AddItemToUserPackByGrid(uId string, gridid stri
} }
///添加移除物品到用户背包 ///添加移除物品到用户背包
func (this *ModelItemsComp) pack_addItemToUserPack(items []*pb.DB_UserItemData, itemId int32, addnum int32) (add, update []*pb.DB_UserItemData, del []string, leftnum int64) { func (this *ModelItemsComp) pack_addItemToUserPack(items []*pb.DB_UserItemData, itemId int32, addnum int32) (add, update, del []*pb.DB_UserItemData, leftnum int64) {
var ( var (
err error err error
conf *cfg.Game_itemData conf *cfg.Game_itemData
@ -253,7 +264,7 @@ func (this *ModelItemsComp) pack_addItemToUserPack(items []*pb.DB_UserItemData,
isNew = true isNew = true
leftnum = int64(addnum) leftnum = int64(addnum)
add = make([]*pb.DB_UserItemData, 0) add = make([]*pb.DB_UserItemData, 0)
del = make([]string, 0) del = make([]*pb.DB_UserItemData, 0)
update = make([]*pb.DB_UserItemData, 0) update = make([]*pb.DB_UserItemData, 0)
for _, v := range items { for _, v := range items {
@ -263,7 +274,7 @@ func (this *ModelItemsComp) pack_addItemToUserPack(items []*pb.DB_UserItemData,
if num < 0 { if num < 0 {
leftnum += int64(v.Amount) leftnum += int64(v.Amount)
v.Amount = 0 v.Amount = 0
del = append(del, v.GridId) del = append(del, v)
} else if num > 0 && num < int64(v.Amount) { } else if num > 0 && num < int64(v.Amount) {
leftnum = 0 leftnum = 0
v.Amount = uint32(num) v.Amount = uint32(num)
@ -285,7 +296,7 @@ func (this *ModelItemsComp) pack_addItemToUserPack(items []*pb.DB_UserItemData,
} else if num == 0 { } else if num == 0 {
leftnum = 0 leftnum = 0
v.Amount = 0 v.Amount = 0
del = append(del, v.GridId) del = append(del, v)
} }
} }
} }

View File

@ -63,9 +63,12 @@ func (this *Items) QueryItemsAmount(source *comm.ModuleCallSource, uId string, i
///添加单个物品到背包 (可以加物品和减物品) ///添加单个物品到背包 (可以加物品和减物品)
func (this *Items) AddItem(source *comm.ModuleCallSource, uId string, itemid, addnum int32) (code pb.ErrorCode) { func (this *Items) AddItem(source *comm.ModuleCallSource, uId string, itemid, addnum int32) (code pb.ErrorCode) {
var err error var (
err error
change []*pb.DB_UserItemData
)
defer this.Debugf("给用户添加物品 uId:%s itemid:%d addnum:%d issucc:%v", uId, itemid, addnum, err == nil) defer this.Debugf("给用户添加物品 uId:%s itemid:%d addnum:%d issucc:%v", uId, itemid, addnum, err == nil)
if err = this.modelItems.Pack_AddItemToUserPack(uId, itemid, addnum); err != nil { if change, err = this.modelItems.Pack_AddItemToUserPack(uId, itemid, addnum); err != nil {
this.Errorf("给用户添加物品 uId:%s itemid:%d addnum:%d err:%v", uId, itemid, addnum, err) this.Errorf("给用户添加物品 uId:%s itemid:%d addnum:%d err:%v", uId, itemid, addnum, err)
if err == ItemNotEnoughError { if err == ItemNotEnoughError {
code = pb.ErrorCode_ItemsNoEnough code = pb.ErrorCode_ItemsNoEnough
@ -74,15 +77,21 @@ func (this *Items) AddItem(source *comm.ModuleCallSource, uId string, itemid, ad
} else { } else {
code = pb.ErrorCode_Unknown code = pb.ErrorCode_Unknown
} }
return
} }
this.itemsChangePush(uId, change) //推送道具背包变化
return return
} }
///添加多个物品到背包 (可以加物品和减物品) ///添加多个物品到背包 (可以加物品和减物品)
func (this *Items) AddItems(source *comm.ModuleCallSource, uId string, items map[int32]int32) (code pb.ErrorCode) { func (this *Items) AddItems(source *comm.ModuleCallSource, uId string, items map[int32]int32) (code pb.ErrorCode) {
var err error var (
err error
change []*pb.DB_UserItemData
)
defer this.Debugf("给用户添加物品 uId:%s items:%d items:%v", uId, items, err == nil) defer this.Debugf("给用户添加物品 uId:%s items:%d items:%v", uId, items, err == nil)
if err = this.modelItems.Pack_AddItemsToUserPack(uId, items); err != nil { if change, err = this.modelItems.Pack_AddItemsToUserPack(uId, items); err != nil {
this.Errorf("给用户添加物品 uId:%s items:%d err:%v", uId, items, err) this.Errorf("给用户添加物品 uId:%s items:%d err:%v", uId, items, err)
if err == ItemNotEnoughError { if err == ItemNotEnoughError {
code = pb.ErrorCode_ItemsNoEnough code = pb.ErrorCode_ItemsNoEnough
@ -91,8 +100,20 @@ func (this *Items) AddItems(source *comm.ModuleCallSource, uId string, items map
} else { } else {
code = pb.ErrorCode_Unknown code = pb.ErrorCode_Unknown
} }
return
}
if len(change) > 0 {
this.itemsChangePush(uId, change) //推送道具背包变化
} }
return return
} }
//Evens-------------------------------------------------------------------------------------------------------------------------------- //Evens--------------------------------------------------------------------------------------------------------------------------------
//推送道具变化消息
func (this *Items) itemsChangePush(uid string, items []*pb.DB_UserItemData) (err error) {
if session, ok := this.GetUserSession(uid); ok {
session.SendMsg(string(this.GetType()), "change", &pb.ItemsChangePush{Grids: items})
err = session.Push()
}
return
}

View File

@ -257,11 +257,17 @@ func (this *ModuleBase) Warnf(format string, a ...interface{}) {
} }
} }
func (this *ModuleBase) Errorf(format string, a ...interface{}) { func (this *ModuleBase) Errorf(format string, a ...interface{}) {
if this.options.GetLog() != nil {
this.options.GetLog().Errorf(fmt.Sprintf("[Module:%s] ", this.module.GetType())+format, a...) this.options.GetLog().Errorf(fmt.Sprintf("[Module:%s] ", this.module.GetType())+format, a...)
}
} }
func (this *ModuleBase) Panicf(format string, a ...interface{}) { func (this *ModuleBase) Panicf(format string, a ...interface{}) {
if this.options.GetLog() != nil {
this.options.GetLog().Panicf(fmt.Sprintf("[Module:%s] ", this.module.GetType())+format, a...) this.options.GetLog().Panicf(fmt.Sprintf("[Module:%s] ", this.module.GetType())+format, a...)
}
} }
func (this *ModuleBase) Fatalf(format string, a ...interface{}) { func (this *ModuleBase) Fatalf(format string, a ...interface{}) {
if this.options.GetLog() != nil {
this.options.GetLog().Fatalf(fmt.Sprintf("[Module:%s] ", this.module.GetType())+format, a...) this.options.GetLog().Fatalf(fmt.Sprintf("[Module:%s] ", this.module.GetType())+format, a...)
}
} }

View File

@ -107,6 +107,54 @@ func (x *EquipmentGetListResp) GetEquipments() []*DB_Equipment {
return nil return nil
} }
//推送装备背包变化
type EquipmentChangePush struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Equipments []*DB_Equipment `protobuf:"bytes,1,rep,name=Equipments,proto3" json:"Equipments"` //装备列表
}
func (x *EquipmentChangePush) Reset() {
*x = EquipmentChangePush{}
if protoimpl.UnsafeEnabled {
mi := &file_equipment_equipment_msg_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EquipmentChangePush) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EquipmentChangePush) ProtoMessage() {}
func (x *EquipmentChangePush) ProtoReflect() protoreflect.Message {
mi := &file_equipment_equipment_msg_proto_msgTypes[2]
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 EquipmentChangePush.ProtoReflect.Descriptor instead.
func (*EquipmentChangePush) Descriptor() ([]byte, []int) {
return file_equipment_equipment_msg_proto_rawDescGZIP(), []int{2}
}
func (x *EquipmentChangePush) GetEquipments() []*DB_Equipment {
if x != nil {
return x.Equipments
}
return nil
}
//装备挂在到英雄上 //装备挂在到英雄上
type EquipmentEquipReq struct { type EquipmentEquipReq struct {
state protoimpl.MessageState state protoimpl.MessageState
@ -120,7 +168,7 @@ type EquipmentEquipReq struct {
func (x *EquipmentEquipReq) Reset() { func (x *EquipmentEquipReq) Reset() {
*x = EquipmentEquipReq{} *x = EquipmentEquipReq{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_equipment_equipment_msg_proto_msgTypes[2] mi := &file_equipment_equipment_msg_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -133,7 +181,7 @@ func (x *EquipmentEquipReq) String() string {
func (*EquipmentEquipReq) ProtoMessage() {} func (*EquipmentEquipReq) ProtoMessage() {}
func (x *EquipmentEquipReq) ProtoReflect() protoreflect.Message { func (x *EquipmentEquipReq) ProtoReflect() protoreflect.Message {
mi := &file_equipment_equipment_msg_proto_msgTypes[2] mi := &file_equipment_equipment_msg_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -146,7 +194,7 @@ func (x *EquipmentEquipReq) ProtoReflect() protoreflect.Message {
// Deprecated: Use EquipmentEquipReq.ProtoReflect.Descriptor instead. // Deprecated: Use EquipmentEquipReq.ProtoReflect.Descriptor instead.
func (*EquipmentEquipReq) Descriptor() ([]byte, []int) { func (*EquipmentEquipReq) Descriptor() ([]byte, []int) {
return file_equipment_equipment_msg_proto_rawDescGZIP(), []int{2} return file_equipment_equipment_msg_proto_rawDescGZIP(), []int{3}
} }
func (x *EquipmentEquipReq) GetHeroCardId() string { func (x *EquipmentEquipReq) GetHeroCardId() string {
@ -175,7 +223,7 @@ type EquipmentEquipResp struct {
func (x *EquipmentEquipResp) Reset() { func (x *EquipmentEquipResp) Reset() {
*x = EquipmentEquipResp{} *x = EquipmentEquipResp{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_equipment_equipment_msg_proto_msgTypes[3] mi := &file_equipment_equipment_msg_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -188,7 +236,7 @@ func (x *EquipmentEquipResp) String() string {
func (*EquipmentEquipResp) ProtoMessage() {} func (*EquipmentEquipResp) ProtoMessage() {}
func (x *EquipmentEquipResp) ProtoReflect() protoreflect.Message { func (x *EquipmentEquipResp) ProtoReflect() protoreflect.Message {
mi := &file_equipment_equipment_msg_proto_msgTypes[3] mi := &file_equipment_equipment_msg_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -201,7 +249,7 @@ func (x *EquipmentEquipResp) ProtoReflect() protoreflect.Message {
// Deprecated: Use EquipmentEquipResp.ProtoReflect.Descriptor instead. // Deprecated: Use EquipmentEquipResp.ProtoReflect.Descriptor instead.
func (*EquipmentEquipResp) Descriptor() ([]byte, []int) { func (*EquipmentEquipResp) Descriptor() ([]byte, []int) {
return file_equipment_equipment_msg_proto_rawDescGZIP(), []int{3} return file_equipment_equipment_msg_proto_rawDescGZIP(), []int{4}
} }
func (x *EquipmentEquipResp) GetEquipments() []*DB_Equipment { func (x *EquipmentEquipResp) GetEquipments() []*DB_Equipment {
@ -223,7 +271,7 @@ type EquipmentUpgradeReq struct {
func (x *EquipmentUpgradeReq) Reset() { func (x *EquipmentUpgradeReq) Reset() {
*x = EquipmentUpgradeReq{} *x = EquipmentUpgradeReq{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_equipment_equipment_msg_proto_msgTypes[4] mi := &file_equipment_equipment_msg_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -236,7 +284,7 @@ func (x *EquipmentUpgradeReq) String() string {
func (*EquipmentUpgradeReq) ProtoMessage() {} func (*EquipmentUpgradeReq) ProtoMessage() {}
func (x *EquipmentUpgradeReq) ProtoReflect() protoreflect.Message { func (x *EquipmentUpgradeReq) ProtoReflect() protoreflect.Message {
mi := &file_equipment_equipment_msg_proto_msgTypes[4] mi := &file_equipment_equipment_msg_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -249,7 +297,7 @@ func (x *EquipmentUpgradeReq) ProtoReflect() protoreflect.Message {
// Deprecated: Use EquipmentUpgradeReq.ProtoReflect.Descriptor instead. // Deprecated: Use EquipmentUpgradeReq.ProtoReflect.Descriptor instead.
func (*EquipmentUpgradeReq) Descriptor() ([]byte, []int) { func (*EquipmentUpgradeReq) Descriptor() ([]byte, []int) {
return file_equipment_equipment_msg_proto_rawDescGZIP(), []int{4} return file_equipment_equipment_msg_proto_rawDescGZIP(), []int{5}
} }
func (x *EquipmentUpgradeReq) GetEquipmentId() string { func (x *EquipmentUpgradeReq) GetEquipmentId() string {
@ -272,7 +320,7 @@ type EquipmentUpgradeResp struct {
func (x *EquipmentUpgradeResp) Reset() { func (x *EquipmentUpgradeResp) Reset() {
*x = EquipmentUpgradeResp{} *x = EquipmentUpgradeResp{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_equipment_equipment_msg_proto_msgTypes[5] mi := &file_equipment_equipment_msg_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -285,7 +333,7 @@ func (x *EquipmentUpgradeResp) String() string {
func (*EquipmentUpgradeResp) ProtoMessage() {} func (*EquipmentUpgradeResp) ProtoMessage() {}
func (x *EquipmentUpgradeResp) ProtoReflect() protoreflect.Message { func (x *EquipmentUpgradeResp) ProtoReflect() protoreflect.Message {
mi := &file_equipment_equipment_msg_proto_msgTypes[5] mi := &file_equipment_equipment_msg_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -298,7 +346,7 @@ func (x *EquipmentUpgradeResp) ProtoReflect() protoreflect.Message {
// Deprecated: Use EquipmentUpgradeResp.ProtoReflect.Descriptor instead. // Deprecated: Use EquipmentUpgradeResp.ProtoReflect.Descriptor instead.
func (*EquipmentUpgradeResp) Descriptor() ([]byte, []int) { func (*EquipmentUpgradeResp) Descriptor() ([]byte, []int) {
return file_equipment_equipment_msg_proto_rawDescGZIP(), []int{5} return file_equipment_equipment_msg_proto_rawDescGZIP(), []int{6}
} }
func (x *EquipmentUpgradeResp) GetIsSucc() bool { func (x *EquipmentUpgradeResp) GetIsSucc() bool {
@ -327,27 +375,32 @@ var file_equipment_equipment_msg_proto_rawDesc = []byte{
0x74, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2d, 0x0a, 0x0a, 0x74, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2d, 0x0a, 0x0a,
0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x0d, 0x2e, 0x44, 0x42, 0x5f, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x5f, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x52,
0x0a, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x55, 0x0a, 0x11, 0x45, 0x0a, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x44, 0x0a, 0x13, 0x45,
0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x45, 0x71, 0x75, 0x69, 0x70, 0x52, 0x65, 0x71, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x75,
0x12, 0x1e, 0x0a, 0x0a, 0x48, 0x65, 0x72, 0x6f, 0x43, 0x61, 0x72, 0x64, 0x49, 0x64, 0x18, 0x01, 0x73, 0x68, 0x12, 0x2d, 0x0a, 0x0a, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x73,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x48, 0x65, 0x72, 0x6f, 0x43, 0x61, 0x72, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x5f, 0x45, 0x71, 0x75, 0x69,
0x12, 0x20, 0x0a, 0x0b, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0a, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74,
0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x55, 0x0a, 0x11, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x45, 0x71,
0x49, 0x64, 0x22, 0x43, 0x0a, 0x12, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x45, 0x75, 0x69, 0x70, 0x52, 0x65, 0x71, 0x12, 0x1e, 0x0a, 0x0a, 0x48, 0x65, 0x72, 0x6f, 0x43, 0x61,
0x71, 0x75, 0x69, 0x70, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2d, 0x0a, 0x0a, 0x45, 0x71, 0x75, 0x69, 0x72, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x48, 0x65, 0x72, 0x6f,
0x70, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x43, 0x61, 0x72, 0x64, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d,
0x42, 0x5f, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0a, 0x45, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x45, 0x71, 0x75,
0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x37, 0x0a, 0x13, 0x45, 0x71, 0x75, 0x69, 0x70, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x43, 0x0a, 0x12, 0x45, 0x71, 0x75, 0x69,
0x6d, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x71, 0x12, 0x20, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x45, 0x71, 0x75, 0x69, 0x70, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2d,
0x0a, 0x0b, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x0a, 0x0a, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03,
0x01, 0x28, 0x09, 0x52, 0x0b, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x5f, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e,
0x22, 0x5b, 0x0a, 0x14, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x74, 0x52, 0x0a, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x37, 0x0a,
0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x73, 0x53, 0x75, 0x13, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64,
0x63, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x49, 0x73, 0x53, 0x75, 0x63, 0x63, 0x65, 0x52, 0x65, 0x71, 0x12, 0x20, 0x0a, 0x0b, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e,
0x12, 0x2b, 0x0a, 0x09, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x45, 0x71, 0x75, 0x69, 0x70,
0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x5f, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x5b, 0x0a, 0x14, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d,
0x6e, 0x74, 0x52, 0x09, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x06, 0x5a, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16,
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x0a, 0x06, 0x49, 0x73, 0x53, 0x75, 0x63, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06,
0x49, 0x73, 0x53, 0x75, 0x63, 0x63, 0x12, 0x2b, 0x0a, 0x09, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d,
0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x5f, 0x45,
0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x09, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d,
0x65, 0x6e, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
} }
var ( var (
@ -362,25 +415,27 @@ func file_equipment_equipment_msg_proto_rawDescGZIP() []byte {
return file_equipment_equipment_msg_proto_rawDescData return file_equipment_equipment_msg_proto_rawDescData
} }
var file_equipment_equipment_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_equipment_equipment_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_equipment_equipment_msg_proto_goTypes = []interface{}{ var file_equipment_equipment_msg_proto_goTypes = []interface{}{
(*EquipmentGetListReq)(nil), // 0: EquipmentGetListReq (*EquipmentGetListReq)(nil), // 0: EquipmentGetListReq
(*EquipmentGetListResp)(nil), // 1: EquipmentGetListResp (*EquipmentGetListResp)(nil), // 1: EquipmentGetListResp
(*EquipmentEquipReq)(nil), // 2: EquipmentEquipReq (*EquipmentChangePush)(nil), // 2: EquipmentChangePush
(*EquipmentEquipResp)(nil), // 3: EquipmentEquipResp (*EquipmentEquipReq)(nil), // 3: EquipmentEquipReq
(*EquipmentUpgradeReq)(nil), // 4: EquipmentUpgradeReq (*EquipmentEquipResp)(nil), // 4: EquipmentEquipResp
(*EquipmentUpgradeResp)(nil), // 5: EquipmentUpgradeResp (*EquipmentUpgradeReq)(nil), // 5: EquipmentUpgradeReq
(*DB_Equipment)(nil), // 6: DB_Equipment (*EquipmentUpgradeResp)(nil), // 6: EquipmentUpgradeResp
(*DB_Equipment)(nil), // 7: DB_Equipment
} }
var file_equipment_equipment_msg_proto_depIdxs = []int32{ var file_equipment_equipment_msg_proto_depIdxs = []int32{
6, // 0: EquipmentGetListResp.Equipments:type_name -> DB_Equipment 7, // 0: EquipmentGetListResp.Equipments:type_name -> DB_Equipment
6, // 1: EquipmentEquipResp.Equipments:type_name -> DB_Equipment 7, // 1: EquipmentChangePush.Equipments:type_name -> DB_Equipment
6, // 2: EquipmentUpgradeResp.Equipment:type_name -> DB_Equipment 7, // 2: EquipmentEquipResp.Equipments:type_name -> DB_Equipment
3, // [3:3] is the sub-list for method output_type 7, // 3: EquipmentUpgradeResp.Equipment:type_name -> DB_Equipment
3, // [3:3] is the sub-list for method input_type 4, // [4:4] is the sub-list for method output_type
3, // [3:3] is the sub-list for extension type_name 4, // [4:4] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension extendee 4, // [4:4] is the sub-list for extension type_name
0, // [0:3] is the sub-list for field type_name 4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
} }
func init() { file_equipment_equipment_msg_proto_init() } func init() { file_equipment_equipment_msg_proto_init() }
@ -415,7 +470,7 @@ func file_equipment_equipment_msg_proto_init() {
} }
} }
file_equipment_equipment_msg_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { file_equipment_equipment_msg_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EquipmentEquipReq); i { switch v := v.(*EquipmentChangePush); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -427,7 +482,7 @@ func file_equipment_equipment_msg_proto_init() {
} }
} }
file_equipment_equipment_msg_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { file_equipment_equipment_msg_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EquipmentEquipResp); i { switch v := v.(*EquipmentEquipReq); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -439,7 +494,7 @@ func file_equipment_equipment_msg_proto_init() {
} }
} }
file_equipment_equipment_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { file_equipment_equipment_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EquipmentUpgradeReq); i { switch v := v.(*EquipmentEquipResp); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -451,6 +506,18 @@ func file_equipment_equipment_msg_proto_init() {
} }
} }
file_equipment_equipment_msg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { file_equipment_equipment_msg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EquipmentUpgradeReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_equipment_equipment_msg_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EquipmentUpgradeResp); i { switch v := v.(*EquipmentUpgradeResp); i {
case 0: case 0:
return &v.state return &v.state
@ -469,7 +536,7 @@ func file_equipment_equipment_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_equipment_equipment_msg_proto_rawDesc, RawDescriptor: file_equipment_equipment_msg_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 6, NumMessages: 7,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

View File

@ -116,6 +116,54 @@ func (x *ItemsGetlistResp) GetGrids() []*DB_UserItemData {
return nil return nil
} }
//背包变化推送
type ItemsChangePush struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Grids []*DB_UserItemData `protobuf:"bytes,1,rep,name=Grids,proto3" json:"Grids"` //变化数据
}
func (x *ItemsChangePush) Reset() {
*x = ItemsChangePush{}
if protoimpl.UnsafeEnabled {
mi := &file_items_items_msg_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ItemsChangePush) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ItemsChangePush) ProtoMessage() {}
func (x *ItemsChangePush) ProtoReflect() protoreflect.Message {
mi := &file_items_items_msg_proto_msgTypes[2]
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 ItemsChangePush.ProtoReflect.Descriptor instead.
func (*ItemsChangePush) Descriptor() ([]byte, []int) {
return file_items_items_msg_proto_rawDescGZIP(), []int{2}
}
func (x *ItemsChangePush) GetGrids() []*DB_UserItemData {
if x != nil {
return x.Grids
}
return nil
}
//使用物品请求 //使用物品请求
type ItemsUseItemReq struct { type ItemsUseItemReq struct {
state protoimpl.MessageState state protoimpl.MessageState
@ -130,7 +178,7 @@ type ItemsUseItemReq struct {
func (x *ItemsUseItemReq) Reset() { func (x *ItemsUseItemReq) Reset() {
*x = ItemsUseItemReq{} *x = ItemsUseItemReq{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_items_items_msg_proto_msgTypes[2] mi := &file_items_items_msg_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -143,7 +191,7 @@ func (x *ItemsUseItemReq) String() string {
func (*ItemsUseItemReq) ProtoMessage() {} func (*ItemsUseItemReq) ProtoMessage() {}
func (x *ItemsUseItemReq) ProtoReflect() protoreflect.Message { func (x *ItemsUseItemReq) ProtoReflect() protoreflect.Message {
mi := &file_items_items_msg_proto_msgTypes[2] mi := &file_items_items_msg_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -156,7 +204,7 @@ func (x *ItemsUseItemReq) ProtoReflect() protoreflect.Message {
// Deprecated: Use ItemsUseItemReq.ProtoReflect.Descriptor instead. // Deprecated: Use ItemsUseItemReq.ProtoReflect.Descriptor instead.
func (*ItemsUseItemReq) Descriptor() ([]byte, []int) { func (*ItemsUseItemReq) Descriptor() ([]byte, []int) {
return file_items_items_msg_proto_rawDescGZIP(), []int{2} return file_items_items_msg_proto_rawDescGZIP(), []int{3}
} }
func (x *ItemsUseItemReq) GetGridId() string { func (x *ItemsUseItemReq) GetGridId() string {
@ -190,7 +238,7 @@ type ItemsUseItemResp struct {
func (x *ItemsUseItemResp) Reset() { func (x *ItemsUseItemResp) Reset() {
*x = ItemsUseItemResp{} *x = ItemsUseItemResp{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_items_items_msg_proto_msgTypes[3] mi := &file_items_items_msg_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -203,7 +251,7 @@ func (x *ItemsUseItemResp) String() string {
func (*ItemsUseItemResp) ProtoMessage() {} func (*ItemsUseItemResp) ProtoMessage() {}
func (x *ItemsUseItemResp) ProtoReflect() protoreflect.Message { func (x *ItemsUseItemResp) ProtoReflect() protoreflect.Message {
mi := &file_items_items_msg_proto_msgTypes[3] mi := &file_items_items_msg_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -216,7 +264,7 @@ func (x *ItemsUseItemResp) ProtoReflect() protoreflect.Message {
// Deprecated: Use ItemsUseItemResp.ProtoReflect.Descriptor instead. // Deprecated: Use ItemsUseItemResp.ProtoReflect.Descriptor instead.
func (*ItemsUseItemResp) Descriptor() ([]byte, []int) { func (*ItemsUseItemResp) Descriptor() ([]byte, []int) {
return file_items_items_msg_proto_rawDescGZIP(), []int{3} return file_items_items_msg_proto_rawDescGZIP(), []int{4}
} }
//出售道具请求sailitem //出售道具请求sailitem
@ -233,7 +281,7 @@ type ItemsSellItemReq struct {
func (x *ItemsSellItemReq) Reset() { func (x *ItemsSellItemReq) Reset() {
*x = ItemsSellItemReq{} *x = ItemsSellItemReq{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_items_items_msg_proto_msgTypes[4] mi := &file_items_items_msg_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -246,7 +294,7 @@ func (x *ItemsSellItemReq) String() string {
func (*ItemsSellItemReq) ProtoMessage() {} func (*ItemsSellItemReq) ProtoMessage() {}
func (x *ItemsSellItemReq) ProtoReflect() protoreflect.Message { func (x *ItemsSellItemReq) ProtoReflect() protoreflect.Message {
mi := &file_items_items_msg_proto_msgTypes[4] mi := &file_items_items_msg_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -259,7 +307,7 @@ func (x *ItemsSellItemReq) ProtoReflect() protoreflect.Message {
// Deprecated: Use ItemsSellItemReq.ProtoReflect.Descriptor instead. // Deprecated: Use ItemsSellItemReq.ProtoReflect.Descriptor instead.
func (*ItemsSellItemReq) Descriptor() ([]byte, []int) { func (*ItemsSellItemReq) Descriptor() ([]byte, []int) {
return file_items_items_msg_proto_rawDescGZIP(), []int{4} return file_items_items_msg_proto_rawDescGZIP(), []int{5}
} }
func (x *ItemsSellItemReq) GetGridId() string { func (x *ItemsSellItemReq) GetGridId() string {
@ -293,7 +341,7 @@ type ItemsSellItemResp struct {
func (x *ItemsSellItemResp) Reset() { func (x *ItemsSellItemResp) Reset() {
*x = ItemsSellItemResp{} *x = ItemsSellItemResp{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_items_items_msg_proto_msgTypes[5] mi := &file_items_items_msg_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -306,7 +354,7 @@ func (x *ItemsSellItemResp) String() string {
func (*ItemsSellItemResp) ProtoMessage() {} func (*ItemsSellItemResp) ProtoMessage() {}
func (x *ItemsSellItemResp) ProtoReflect() protoreflect.Message { func (x *ItemsSellItemResp) ProtoReflect() protoreflect.Message {
mi := &file_items_items_msg_proto_msgTypes[5] mi := &file_items_items_msg_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -319,7 +367,7 @@ func (x *ItemsSellItemResp) ProtoReflect() protoreflect.Message {
// Deprecated: Use ItemsSellItemResp.ProtoReflect.Descriptor instead. // Deprecated: Use ItemsSellItemResp.ProtoReflect.Descriptor instead.
func (*ItemsSellItemResp) Descriptor() ([]byte, []int) { func (*ItemsSellItemResp) Descriptor() ([]byte, []int) {
return file_items_items_msg_proto_rawDescGZIP(), []int{5} return file_items_items_msg_proto_rawDescGZIP(), []int{6}
} }
var File_items_items_msg_proto protoreflect.FileDescriptor var File_items_items_msg_proto protoreflect.FileDescriptor
@ -334,22 +382,25 @@ var file_items_items_msg_proto_rawDesc = []byte{
0x65, 0x74, 0x6c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x26, 0x0a, 0x05, 0x47, 0x72, 0x65, 0x74, 0x6c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x26, 0x0a, 0x05, 0x47, 0x72,
0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x44, 0x42, 0x5f, 0x55, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x44, 0x42, 0x5f, 0x55,
0x73, 0x65, 0x72, 0x49, 0x74, 0x65, 0x6d, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x47, 0x72, 0x69, 0x73, 0x65, 0x72, 0x49, 0x74, 0x65, 0x6d, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x47, 0x72, 0x69,
0x64, 0x73, 0x22, 0x59, 0x0a, 0x0f, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x55, 0x73, 0x65, 0x49, 0x74, 0x64, 0x73, 0x22, 0x39, 0x0a, 0x0f, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x43, 0x68, 0x61, 0x6e, 0x67,
0x65, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x18, 0x65, 0x50, 0x75, 0x73, 0x68, 0x12, 0x26, 0x0a, 0x05, 0x47, 0x72, 0x69, 0x64, 0x73, 0x18, 0x01,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x49, 0x74,
0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49, 0x65, 0x6d, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x47, 0x72, 0x69, 0x64, 0x73, 0x22, 0x59, 0x0a,
0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0f, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71,
0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x12, 0x0a, 0x12, 0x16, 0x0a, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x10, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d,
0x70, 0x22, 0x5a, 0x0a, 0x10, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64,
0x65, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x18, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x12, 0x0a, 0x10, 0x49, 0x74, 0x65, 0x6d,
0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49, 0x73, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x22, 0x5a, 0x0a, 0x10,
0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71,
0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x13, 0x0a, 0x12, 0x16, 0x0a, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x11, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d,
0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64,
0x6f, 0x33, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d,
0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x13, 0x0a, 0x11, 0x49, 0x74, 0x65, 0x6d,
0x73, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a,
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -364,23 +415,25 @@ func file_items_items_msg_proto_rawDescGZIP() []byte {
return file_items_items_msg_proto_rawDescData return file_items_items_msg_proto_rawDescData
} }
var file_items_items_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_items_items_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_items_items_msg_proto_goTypes = []interface{}{ var file_items_items_msg_proto_goTypes = []interface{}{
(*ItemsGetlistReq)(nil), // 0: ItemsGetlistReq (*ItemsGetlistReq)(nil), // 0: ItemsGetlistReq
(*ItemsGetlistResp)(nil), // 1: ItemsGetlistResp (*ItemsGetlistResp)(nil), // 1: ItemsGetlistResp
(*ItemsUseItemReq)(nil), // 2: ItemsUseItemReq (*ItemsChangePush)(nil), // 2: ItemsChangePush
(*ItemsUseItemResp)(nil), // 3: ItemsUseItemResp (*ItemsUseItemReq)(nil), // 3: ItemsUseItemReq
(*ItemsSellItemReq)(nil), // 4: ItemsSellItemReq (*ItemsUseItemResp)(nil), // 4: ItemsUseItemResp
(*ItemsSellItemResp)(nil), // 5: ItemsSellItemResp (*ItemsSellItemReq)(nil), // 5: ItemsSellItemReq
(*DB_UserItemData)(nil), // 6: DB_UserItemData (*ItemsSellItemResp)(nil), // 6: ItemsSellItemResp
(*DB_UserItemData)(nil), // 7: DB_UserItemData
} }
var file_items_items_msg_proto_depIdxs = []int32{ var file_items_items_msg_proto_depIdxs = []int32{
6, // 0: ItemsGetlistResp.Grids:type_name -> DB_UserItemData 7, // 0: ItemsGetlistResp.Grids:type_name -> DB_UserItemData
1, // [1:1] is the sub-list for method output_type 7, // 1: ItemsChangePush.Grids:type_name -> DB_UserItemData
1, // [1:1] is the sub-list for method input_type 2, // [2:2] is the sub-list for method output_type
1, // [1:1] is the sub-list for extension type_name 2, // [2:2] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension extendee 2, // [2:2] is the sub-list for extension type_name
0, // [0:1] is the sub-list for field type_name 2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
} }
func init() { file_items_items_msg_proto_init() } func init() { file_items_items_msg_proto_init() }
@ -415,7 +468,7 @@ func file_items_items_msg_proto_init() {
} }
} }
file_items_items_msg_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { file_items_items_msg_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ItemsUseItemReq); i { switch v := v.(*ItemsChangePush); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -427,7 +480,7 @@ func file_items_items_msg_proto_init() {
} }
} }
file_items_items_msg_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { file_items_items_msg_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ItemsUseItemResp); i { switch v := v.(*ItemsUseItemReq); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -439,7 +492,7 @@ func file_items_items_msg_proto_init() {
} }
} }
file_items_items_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { file_items_items_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ItemsSellItemReq); i { switch v := v.(*ItemsUseItemResp); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -451,6 +504,18 @@ func file_items_items_msg_proto_init() {
} }
} }
file_items_items_msg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { file_items_items_msg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ItemsSellItemReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_items_items_msg_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ItemsSellItemResp); i { switch v := v.(*ItemsSellItemResp); i {
case 0: case 0:
return &v.state return &v.state
@ -469,7 +534,7 @@ func file_items_items_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_items_items_msg_proto_rawDesc, RawDescriptor: file_items_items_msg_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 6, NumMessages: 7,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

View File

@ -11,6 +11,11 @@ message EquipmentGetListResp {
repeated DB_Equipment Equipments = 1; // repeated DB_Equipment Equipments = 1; //
} }
//
message EquipmentChangePush {
repeated DB_Equipment Equipments = 1; //
}
// //
message EquipmentEquipReq{ message EquipmentEquipReq{
string HeroCardId = 1; //Id string HeroCardId = 1; //Id

View File

@ -12,6 +12,11 @@ message ItemsGetlistResp {
repeated DB_UserItemData Grids = 1; // repeated DB_UserItemData Grids = 1; //
} }
//
message ItemsChangePush {
repeated DB_UserItemData Grids = 1; //
}
//使 //使
message ItemsUseItemReq { message ItemsUseItemReq {
string GridId = 1; //Id string GridId = 1; //Id

View File

@ -28,7 +28,7 @@ func ValidSecretKey(secStr string) bool {
clientMd5Key := secStr[3:35] clientMd5Key := secStr[3:35]
rawmsg := secStr[35:] rawmsg := secStr[35:]
log.Debugf("data base: %s", rawmsg) // log.Debugf("data base: %s", rawmsg)
serverMd5Key := MD5Str(rawmsg) //这里可以再加上客户端和服务端的秘钥再MD5 serverMd5Key := MD5Str(rawmsg) //这里可以再加上客户端和服务端的秘钥再MD5
return strings.EqualFold(strings.ToLower(serverMd5Key), strings.ToLower(clientMd5Key)) return strings.EqualFold(strings.ToLower(serverMd5Key), strings.ToLower(clientMd5Key))
} }