Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into meixiongfeng
This commit is contained in:
commit
dd1ba19d30
@ -78,4 +78,6 @@ type IRPCXService interface {
|
||||
RegisterFunctionName(name string, fn 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)
|
||||
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)
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"go_dreamfactory/lego/sys/event"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/lego/sys/rpcx"
|
||||
|
||||
"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) {
|
||||
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)
|
||||
}
|
||||
|
@ -18,32 +18,34 @@ import (
|
||||
"github.com/smallnest/rpcx/share"
|
||||
)
|
||||
|
||||
func newClient(options Options) (sys *Client, err error) {
|
||||
func newClient(options *Options) (sys *Client, err error) {
|
||||
sys = &Client{
|
||||
options: options,
|
||||
metadata: fmt.Sprintf("stype=%s&sid=%s&version=%s&addr=%s", options.ServiceType, options.ServiceId, options.ServiceVersion, "tcp@"+options.ServiceAddr),
|
||||
clients: make(map[string]client.XClient),
|
||||
conns: make(map[string]net.Conn),
|
||||
connecting: make(map[string]struct{}),
|
||||
serviceMap: make(map[string]*service),
|
||||
msgChan: make(chan *protocol.Message, 1000),
|
||||
options: options,
|
||||
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),
|
||||
otherClusterClients: make(map[string]map[string]client.XClient),
|
||||
conns: make(map[string]net.Conn),
|
||||
connecting: make(map[string]struct{}),
|
||||
serviceMap: make(map[string]*service),
|
||||
msgChan: make(chan *protocol.Message, 1000),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
options Options
|
||||
metadata string
|
||||
writeTimeout time.Duration
|
||||
AsyncWrite bool
|
||||
clients map[string]client.XClient
|
||||
connsMapMu sync.RWMutex
|
||||
conns map[string]net.Conn
|
||||
connectMapMu sync.RWMutex
|
||||
connecting map[string]struct{}
|
||||
serviceMapMu sync.RWMutex
|
||||
serviceMap map[string]*service
|
||||
msgChan chan *protocol.Message // 接收rpcXServer推送消息
|
||||
options *Options
|
||||
metadata string
|
||||
writeTimeout time.Duration
|
||||
AsyncWrite bool
|
||||
clients map[string]client.XClient
|
||||
otherClusterClients map[string]map[string]client.XClient //其他集群客户端
|
||||
connsMapMu sync.RWMutex
|
||||
conns map[string]net.Conn
|
||||
connectMapMu sync.RWMutex
|
||||
connecting map[string]struct{}
|
||||
serviceMapMu sync.RWMutex
|
||||
serviceMap map[string]*service
|
||||
msgChan chan *protocol.Message // 接收rpcXServer推送消息
|
||||
}
|
||||
|
||||
// DoMessage 服务端消息处理
|
||||
@ -132,9 +134,10 @@ func (this *Client) Call(ctx context.Context, servicePath string, serviceMethod
|
||||
this.clients[spath[0]] = c
|
||||
}
|
||||
ctx = context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{
|
||||
CallRoutRulesKey: servicePath,
|
||||
ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
|
||||
ServiceMetaKey: this.metadata,
|
||||
ServiceClusterTag: this.options.ServiceTag,
|
||||
CallRoutRulesKey: servicePath,
|
||||
ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
|
||||
ServiceMetaKey: this.metadata,
|
||||
})
|
||||
err = c.Call(ctx, serviceMethod, args, reply)
|
||||
return
|
||||
@ -164,9 +167,93 @@ func (this *Client) Go(ctx context.Context, servicePath string, serviceMethod st
|
||||
this.clients[spath[0]] = c
|
||||
}
|
||||
ctx = context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{
|
||||
CallRoutRulesKey: servicePath,
|
||||
ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
|
||||
ServiceMetaKey: this.metadata,
|
||||
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,
|
||||
ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
|
||||
ServiceMetaKey: this.metadata,
|
||||
})
|
||||
return c.Go(ctx, string(serviceMethod), args, reply, done)
|
||||
}
|
||||
|
@ -10,9 +10,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
ServiceMetaKey = "smeta"
|
||||
ServiceAddrKey = "addr"
|
||||
CallRoutRulesKey = "callrules"
|
||||
ServiceClusterTag = "ctag"
|
||||
ServiceMetaKey = "smeta"
|
||||
ServiceAddrKey = "addr"
|
||||
CallRoutRulesKey = "callrules"
|
||||
)
|
||||
|
||||
const RpcX_ShakeHands = "RpcX_ShakeHands" //握手
|
||||
@ -26,6 +27,8 @@ type (
|
||||
UnregisterAll() (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)
|
||||
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
|
||||
)
|
||||
|
||||
func OnInit(config map[string]interface{}, option ...Option) (err error) {
|
||||
var options Options
|
||||
if options, err = newOptions(config, option...); err != nil {
|
||||
func OnInit(config map[string]interface{}, opt ...Option) (err error) {
|
||||
var options *Options
|
||||
if options, err = newOptions(config, opt...); err != nil {
|
||||
return
|
||||
}
|
||||
defsys, err = newSys(options)
|
||||
return
|
||||
}
|
||||
|
||||
func NewSys(option ...Option) (sys ISys, err error) {
|
||||
var options Options
|
||||
if options, err = newOptionsByOption(option...); err != nil {
|
||||
func NewSys(opt ...Option) (sys ISys, err error) {
|
||||
var options *Options
|
||||
if options, err = newOptionsByOption(opt...); err != nil {
|
||||
return
|
||||
}
|
||||
sys, err = newSys(options)
|
||||
@ -92,6 +95,12 @@ func smetaToServiceNode(meta string) (node *ServiceNode, err error) {
|
||||
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 {
|
||||
err = fmt.Errorf("no found sid")
|
||||
return
|
||||
|
@ -85,37 +85,45 @@ func SetLog(v log.ILog) Option {
|
||||
}
|
||||
}
|
||||
|
||||
func newOptions(config map[string]interface{}, opts ...Option) (Options, error) {
|
||||
options := Options{
|
||||
func newOptions(config map[string]interface{}, opts ...Option) (options *Options, err error) {
|
||||
options = &Options{
|
||||
AutoConnect: true,
|
||||
SerializeType: protocol.MsgPack,
|
||||
Debug: true,
|
||||
Log: log.Clone(log.SetLoglayer(2)),
|
||||
}
|
||||
if config != nil {
|
||||
mapstructure.Decode(config, &options)
|
||||
mapstructure.Decode(config, options)
|
||||
}
|
||||
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 {
|
||||
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
|
||||
}
|
||||
|
||||
func newOptionsByOption(opts ...Option) (Options, error) {
|
||||
options := Options{
|
||||
func newOptionsByOption(opts ...Option) (options *Options, err error) {
|
||||
options = &Options{
|
||||
AutoConnect: true,
|
||||
SerializeType: protocol.MsgPack,
|
||||
Debug: true,
|
||||
Log: log.Clone(log.SetLoglayer(2)),
|
||||
}
|
||||
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 {
|
||||
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
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"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 服务端
|
||||
sys, err = newService(options)
|
||||
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) {
|
||||
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)
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ func newSelector(fn func(map[string]*ServiceNode)) *Selector {
|
||||
}
|
||||
|
||||
type ServiceNode struct {
|
||||
ServiceTag string `json:"stag"` //服务集群标签
|
||||
ServiceId string `json:"sid"` //服务id
|
||||
ServiceType string `json:"stype"` //服务类型
|
||||
Version string `json:"version"` //服务版本
|
||||
|
@ -18,12 +18,12 @@ import (
|
||||
"github.com/smallnest/rpcx/share"
|
||||
)
|
||||
|
||||
func newService(options Options) (sys *Service, err error) {
|
||||
func newService(options *Options) (sys *Service, err error) {
|
||||
sys = &Service{
|
||||
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(),
|
||||
selector: newSelector(nil),
|
||||
selectors: make(map[string]client.Selector),
|
||||
clients: make(map[string]net.Conn),
|
||||
clientmeta: make(map[string]string),
|
||||
pending: make(map[uint64]*client.Call),
|
||||
@ -46,10 +46,10 @@ func newService(options Options) (sys *Service, err error) {
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
options Options
|
||||
options *Options
|
||||
metadata string
|
||||
server *server.Server
|
||||
selector client.Selector
|
||||
selectors map[string]client.Selector
|
||||
clientmutex sync.Mutex
|
||||
clients map[string]net.Conn
|
||||
clientmeta map[string]string
|
||||
@ -100,7 +100,7 @@ func (this *Service) Call(ctx context.Context, servicePath string, serviceMethod
|
||||
)
|
||||
seq := new(uint64)
|
||||
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
|
||||
}
|
||||
select {
|
||||
@ -130,26 +130,79 @@ 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) {
|
||||
_, _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
|
||||
}
|
||||
|
||||
//监听客户端链接到服务上 保存客户端的连接对象
|
||||
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)
|
||||
if addr, ok := req_metadata[ServiceAddrKey]; ok {
|
||||
if _, ok = this.clientmeta[addr]; !ok {
|
||||
if smeta, ok := req_metadata[ServiceMetaKey]; ok {
|
||||
servers := make(map[string]string)
|
||||
this.clientmutex.Lock()
|
||||
this.clientmeta[addr] = smeta
|
||||
this.clients[addr] = ctx.Value(server.RemoteConnContextKey).(net.Conn)
|
||||
for k, v := range this.clientmeta {
|
||||
servers[k] = v
|
||||
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 _, ok = this.clientmeta[addr]; !ok {
|
||||
if smeta, ok := req_metadata[ServiceMetaKey]; ok {
|
||||
servers := make(map[string]string)
|
||||
this.clientmutex.Lock()
|
||||
this.clientmeta[addr] = smeta
|
||||
this.clients[addr] = ctx.Value(server.RemoteConnContextKey).(net.Conn)
|
||||
for k, v := range this.clientmeta {
|
||||
servers[k] = v
|
||||
}
|
||||
this.clientmutex.Unlock()
|
||||
selector.UpdateServer(servers)
|
||||
this.Debugf("fond new node addr:%s smeta:%s \n", addr, smeta)
|
||||
}
|
||||
this.clientmutex.Unlock()
|
||||
this.selector.UpdateServer(servers)
|
||||
this.Debugf("fond new node addr:%s smeta:%s \n", addr, smeta)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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 (
|
||||
spath []string
|
||||
clientaddr string
|
||||
metadata map[string]string
|
||||
selector client.Selector
|
||||
ok bool
|
||||
)
|
||||
if servicePath == "" {
|
||||
@ -259,9 +313,10 @@ func (this *Service) call(ctx context.Context, servicePath string, serviceMethod
|
||||
return
|
||||
}
|
||||
metadata = map[string]string{
|
||||
CallRoutRulesKey: servicePath,
|
||||
ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
|
||||
ServiceMetaKey: this.metadata,
|
||||
ServiceClusterTag: clusterTag,
|
||||
CallRoutRulesKey: servicePath,
|
||||
ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
|
||||
ServiceMetaKey: this.metadata,
|
||||
}
|
||||
spath = strings.Split(servicePath, "/")
|
||||
ctx = context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{
|
||||
@ -269,7 +324,10 @@ func (this *Service) call(ctx context.Context, servicePath string, serviceMethod
|
||||
ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
|
||||
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)
|
||||
return
|
||||
}
|
||||
|
@ -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 (
|
||||
configure *cfg.Game_equip
|
||||
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)
|
||||
update = make(map[string]*pb.DB_Equipment)
|
||||
change = make([]*pb.DB_Equipment, len(equipments))
|
||||
for k, v := range cIds {
|
||||
iskeep = false
|
||||
for _, equipment := range equipments {
|
||||
if equipment.CId == k && equipment.IsInitialState {
|
||||
update[equipment.Id] = equipment
|
||||
change = append(change, equipment)
|
||||
equipment.OverlayNum += v
|
||||
iskeep = true
|
||||
break
|
||||
@ -94,9 +96,10 @@ func (this *modelEquipmentComp) AddEquipments(uId string, cIds map[int32]uint32)
|
||||
if !iskeep {
|
||||
if c, ok := configure.GetDataMap()[k]; ok {
|
||||
if equipment, err := this.newEquipment(uId, c, v); err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
} else {
|
||||
add[equipment.Id] = equipment
|
||||
change = append(change, equipment)
|
||||
}
|
||||
}
|
||||
}
|
@ -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) {
|
||||
var err error
|
||||
if err = this.modelEquipment.AddEquipments(uid, cIds); err != nil {
|
||||
var (
|
||||
err error
|
||||
change []*pb.DB_Equipment
|
||||
)
|
||||
if change, err = this.modelEquipment.AddEquipments(uid, cIds); err != nil {
|
||||
log.Errorf("err%v", err)
|
||||
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
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/utils"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@ -64,13 +65,13 @@ func (this *Agent) readLoop() {
|
||||
locp:
|
||||
for {
|
||||
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()
|
||||
break locp
|
||||
}
|
||||
|
||||
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()
|
||||
break locp
|
||||
} 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() {
|
||||
@ -111,7 +112,7 @@ locp:
|
||||
if ok {
|
||||
data, err = proto.Marshal(msg)
|
||||
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()
|
||||
}
|
||||
} 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,28 +214,58 @@ func (this *Agent) Close() {
|
||||
|
||||
//分发用户消息
|
||||
func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) {
|
||||
reply := &pb.RPCMessageReply{}
|
||||
log.Debugf("agent:%s uId:%s MessageDistribution msg:%s.%s", this.sessionId, this.uId, msg.MainType, msg.SubType)
|
||||
var (
|
||||
reply *pb.RPCMessageReply = &pb.RPCMessageReply{}
|
||||
serviceTag string = ""
|
||||
servicePath string = comm.Service_Worker
|
||||
rule string
|
||||
ok bool
|
||||
)
|
||||
|
||||
servicePath := comm.Service_Worker
|
||||
if rule, ok := this.gateway.GetMsgDistribute(msg.MainType, msg.SubType); ok {
|
||||
servicePath = rule
|
||||
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 {
|
||||
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
|
||||
} else {
|
||||
this.gateway.Errorf("messageDistribution rule is empty!")
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if len(this.wId) > 0 {
|
||||
if len(this.wId) > 0 { //已经绑定worker 服务器
|
||||
servicePath = fmt.Sprintf("%s/%s", comm.Service_Worker, this.wId)
|
||||
}
|
||||
}
|
||||
if err = this.gateway.Service().RpcCall(context.Background(), 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 {
|
||||
log.Errorf("agent:%s uId:%s MessageDistribution err:%v", this.sessionId, this.uId, err)
|
||||
return
|
||||
|
||||
if len(serviceTag) == 0 {
|
||||
if err = this.gateway.Service().RpcCall(context.Background(), 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
|
||||
}
|
||||
} 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 {
|
||||
data, _ := anypb.New(&pb.NotifyErrorNotifyPush{ReqMainType: msg.MainType, ReqSubType: msg.SubType, Code: pb.ErrorCode(reply.Code.Number())})
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"go_dreamfactory/lego/base"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
)
|
||||
|
||||
type (
|
||||
@ -22,6 +23,7 @@ type (
|
||||
// IGateway 网关模块 接口定义
|
||||
IGateway interface {
|
||||
core.IModule
|
||||
log.Ilogf
|
||||
Service() base.IRPCXService
|
||||
Connect(a IAgent)
|
||||
DisConnect(a IAgent)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
|
||||
"go_dreamfactory/lego/base"
|
||||
@ -22,6 +23,7 @@ func NewModule() core.IModule {
|
||||
|
||||
type Gateway struct {
|
||||
cbase.ModuleBase
|
||||
options *Options
|
||||
service base.IRPCXService // rpcx服务接口 主要client->server
|
||||
wsService *WSServiceComp // websocket服务 监听websocket连接
|
||||
agentMgr *AgentMgrComp // 客户端websocket连接管理
|
||||
@ -46,6 +48,7 @@ func (this *Gateway) Service() base.IRPCXService {
|
||||
// Init 模块初始化函数
|
||||
func (this *Gateway) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||
err = this.ModuleBase.Init(service, module, options)
|
||||
this.options = options.(*Options)
|
||||
this.service = service.(base.IRPCXService)
|
||||
return
|
||||
}
|
||||
@ -98,3 +101,35 @@ func (this *Gateway) DisConnect(a IAgent) {
|
||||
func (this *Gateway) GetMsgDistribute(mtype, stype string) (rule string, ok bool) {
|
||||
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...)
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package gateway
|
||||
|
||||
import (
|
||||
"go_dreamfactory/lego/utils/mapstructure"
|
||||
"go_dreamfactory/modules"
|
||||
)
|
||||
|
||||
/*
|
||||
@ -10,7 +11,7 @@ import (
|
||||
|
||||
type (
|
||||
Options struct {
|
||||
Debug bool //日志开关
|
||||
modules.Options
|
||||
GinDebug bool //web引擎日志开关
|
||||
ListenPort int //websocket 监听端口
|
||||
}
|
||||
@ -19,6 +20,9 @@ type (
|
||||
// LoadConfig 配置文件序列化为Options
|
||||
func (this *Options) LoadConfig(settings map[string]interface{}) (err error) {
|
||||
if settings != nil {
|
||||
if err = this.Options.LoadConfig(settings); err != nil {
|
||||
return
|
||||
}
|
||||
err = mapstructure.Decode(settings, this)
|
||||
}
|
||||
return
|
||||
|
@ -23,7 +23,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ItemsGetlistReq)
|
||||
tempgrids []*pb.DB_UserItemData
|
||||
grids []*pb.DB_UserItemData
|
||||
modifys []*pb.DB_UserItemData
|
||||
dels []string
|
||||
dels []*pb.DB_UserItemData
|
||||
)
|
||||
defer func() {
|
||||
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 {
|
||||
tempgrids = this.module.configure.GetPackItemByType(items, req.IType)
|
||||
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))
|
||||
nt = time.Now().Unix()
|
||||
for _, v := range tempgrids {
|
||||
if v.ETime > 0 && v.ETime < nt { //已经过期
|
||||
dels = append(dels, v.GridId)
|
||||
dels = append(dels, v)
|
||||
} else {
|
||||
grids = append(grids, v)
|
||||
if v.IsNewItem {
|
||||
|
@ -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 {
|
||||
this.module.Errorf("err:%v", err)
|
||||
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 (
|
||||
itmes []*pb.DB_UserItemData
|
||||
add []*pb.DB_UserItemData
|
||||
del []string
|
||||
del []*pb.DB_UserItemData
|
||||
update []*pb.DB_UserItemData
|
||||
leftnum int64
|
||||
)
|
||||
@ -121,6 +125,7 @@ func (this *ModelItemsComp) Pack_AddItemToUserPack(uId string, itemId int32, add
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
change = make([]*pb.DB_UserItemData, len(itmes))
|
||||
add, update, del, leftnum = this.pack_addItemToUserPack(itmes, itemId, addnum)
|
||||
if leftnum < 0 {
|
||||
err = ItemNotEnoughError
|
||||
@ -134,29 +139,31 @@ func (this *ModelItemsComp) Pack_AddItemToUserPack(uId string, itemId int32, add
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
change = append(change, add...)
|
||||
}
|
||||
if len(del) > 0 {
|
||||
if err = this.Pack_DeleteUserPack(uId, del...); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
change = append(change, del...)
|
||||
}
|
||||
if len(update) > 0 {
|
||||
if err = this.Pack_UpdateUserPack(uId, update...); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
change = append(change, update...)
|
||||
}
|
||||
|
||||
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 (
|
||||
itmes []*pb.DB_UserItemData
|
||||
add []*pb.DB_UserItemData
|
||||
del []string
|
||||
del []*pb.DB_UserItemData
|
||||
update []*pb.DB_UserItemData
|
||||
leftnum int64
|
||||
)
|
||||
@ -164,6 +171,7 @@ func (this *ModelItemsComp) Pack_AddItemsToUserPack(uId string, items map[int32]
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
change = make([]*pb.DB_UserItemData, len(itmes))
|
||||
for k, v := range items {
|
||||
add, update, del, leftnum = this.pack_addItemToUserPack(itmes, k, v)
|
||||
if leftnum < 0 {
|
||||
@ -178,18 +186,21 @@ func (this *ModelItemsComp) Pack_AddItemsToUserPack(uId string, items map[int32]
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
change = append(change, add...)
|
||||
}
|
||||
if len(del) > 0 {
|
||||
if err = this.Pack_DeleteUserPack(uId, del...); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
change = append(change, del...)
|
||||
}
|
||||
if len(update) > 0 {
|
||||
if err = this.Pack_UpdateUserPack(uId, update...); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
change = append(change, update...)
|
||||
}
|
||||
}
|
||||
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 (
|
||||
err error
|
||||
conf *cfg.Game_itemData
|
||||
@ -253,7 +264,7 @@ func (this *ModelItemsComp) pack_addItemToUserPack(items []*pb.DB_UserItemData,
|
||||
isNew = true
|
||||
leftnum = int64(addnum)
|
||||
add = make([]*pb.DB_UserItemData, 0)
|
||||
del = make([]string, 0)
|
||||
del = make([]*pb.DB_UserItemData, 0)
|
||||
update = make([]*pb.DB_UserItemData, 0)
|
||||
|
||||
for _, v := range items {
|
||||
@ -263,7 +274,7 @@ func (this *ModelItemsComp) pack_addItemToUserPack(items []*pb.DB_UserItemData,
|
||||
if num < 0 {
|
||||
leftnum += int64(v.Amount)
|
||||
v.Amount = 0
|
||||
del = append(del, v.GridId)
|
||||
del = append(del, v)
|
||||
} else if num > 0 && num < int64(v.Amount) {
|
||||
leftnum = 0
|
||||
v.Amount = uint32(num)
|
||||
@ -285,7 +296,7 @@ func (this *ModelItemsComp) pack_addItemToUserPack(items []*pb.DB_UserItemData,
|
||||
} else if num == 0 {
|
||||
leftnum = 0
|
||||
v.Amount = 0
|
||||
del = append(del, v.GridId)
|
||||
del = append(del, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
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)
|
||||
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)
|
||||
if err == ItemNotEnoughError {
|
||||
code = pb.ErrorCode_ItemsNoEnough
|
||||
@ -74,15 +77,21 @@ func (this *Items) AddItem(source *comm.ModuleCallSource, uId string, itemid, ad
|
||||
} else {
|
||||
code = pb.ErrorCode_Unknown
|
||||
}
|
||||
return
|
||||
}
|
||||
this.itemsChangePush(uId, change) //推送道具背包变化
|
||||
return
|
||||
}
|
||||
|
||||
///添加多个物品到背包 (可以加物品和减物品)
|
||||
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)
|
||||
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)
|
||||
if err == ItemNotEnoughError {
|
||||
code = pb.ErrorCode_ItemsNoEnough
|
||||
@ -91,8 +100,20 @@ func (this *Items) AddItems(source *comm.ModuleCallSource, uId string, items map
|
||||
} else {
|
||||
code = pb.ErrorCode_Unknown
|
||||
}
|
||||
return
|
||||
}
|
||||
if len(change) > 0 {
|
||||
this.itemsChangePush(uId, change) //推送道具背包变化
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//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
|
||||
}
|
||||
|
@ -257,11 +257,17 @@ func (this *ModuleBase) Warnf(format string, a ...interface{}) {
|
||||
}
|
||||
}
|
||||
func (this *ModuleBase) Errorf(format string, a ...interface{}) {
|
||||
this.options.GetLog().Errorf(fmt.Sprintf("[Module:%s] ", this.module.GetType())+format, a...)
|
||||
if this.options.GetLog() != nil {
|
||||
this.options.GetLog().Errorf(fmt.Sprintf("[Module:%s] ", this.module.GetType())+format, a...)
|
||||
}
|
||||
}
|
||||
func (this *ModuleBase) Panicf(format string, a ...interface{}) {
|
||||
this.options.GetLog().Panicf(fmt.Sprintf("[Module:%s] ", this.module.GetType())+format, a...)
|
||||
if this.options.GetLog() != nil {
|
||||
this.options.GetLog().Panicf(fmt.Sprintf("[Module:%s] ", this.module.GetType())+format, a...)
|
||||
}
|
||||
}
|
||||
func (this *ModuleBase) Fatalf(format string, a ...interface{}) {
|
||||
this.options.GetLog().Fatalf(fmt.Sprintf("[Module:%s] ", this.module.GetType())+format, a...)
|
||||
if this.options.GetLog() != nil {
|
||||
this.options.GetLog().Fatalf(fmt.Sprintf("[Module:%s] ", this.module.GetType())+format, a...)
|
||||
}
|
||||
}
|
||||
|
@ -107,6 +107,54 @@ func (x *EquipmentGetListResp) GetEquipments() []*DB_Equipment {
|
||||
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 {
|
||||
state protoimpl.MessageState
|
||||
@ -120,7 +168,7 @@ type EquipmentEquipReq struct {
|
||||
func (x *EquipmentEquipReq) Reset() {
|
||||
*x = EquipmentEquipReq{}
|
||||
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.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -133,7 +181,7 @@ func (x *EquipmentEquipReq) String() string {
|
||||
func (*EquipmentEquipReq) ProtoMessage() {}
|
||||
|
||||
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 {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -146,7 +194,7 @@ func (x *EquipmentEquipReq) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use EquipmentEquipReq.ProtoReflect.Descriptor instead.
|
||||
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 {
|
||||
@ -175,7 +223,7 @@ type EquipmentEquipResp struct {
|
||||
func (x *EquipmentEquipResp) Reset() {
|
||||
*x = EquipmentEquipResp{}
|
||||
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.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -188,7 +236,7 @@ func (x *EquipmentEquipResp) String() string {
|
||||
func (*EquipmentEquipResp) ProtoMessage() {}
|
||||
|
||||
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 {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -201,7 +249,7 @@ func (x *EquipmentEquipResp) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use EquipmentEquipResp.ProtoReflect.Descriptor instead.
|
||||
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 {
|
||||
@ -223,7 +271,7 @@ type EquipmentUpgradeReq struct {
|
||||
func (x *EquipmentUpgradeReq) Reset() {
|
||||
*x = EquipmentUpgradeReq{}
|
||||
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.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -236,7 +284,7 @@ func (x *EquipmentUpgradeReq) String() string {
|
||||
func (*EquipmentUpgradeReq) ProtoMessage() {}
|
||||
|
||||
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 {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -249,7 +297,7 @@ func (x *EquipmentUpgradeReq) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use EquipmentUpgradeReq.ProtoReflect.Descriptor instead.
|
||||
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 {
|
||||
@ -272,7 +320,7 @@ type EquipmentUpgradeResp struct {
|
||||
func (x *EquipmentUpgradeResp) Reset() {
|
||||
*x = EquipmentUpgradeResp{}
|
||||
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.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -285,7 +333,7 @@ func (x *EquipmentUpgradeResp) String() string {
|
||||
func (*EquipmentUpgradeResp) ProtoMessage() {}
|
||||
|
||||
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 {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -298,7 +346,7 @@ func (x *EquipmentUpgradeResp) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use EquipmentUpgradeResp.ProtoReflect.Descriptor instead.
|
||||
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 {
|
||||
@ -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,
|
||||
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,
|
||||
0x0a, 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, 0x75, 0x69, 0x70, 0x52, 0x65, 0x71,
|
||||
0x12, 0x1e, 0x0a, 0x0a, 0x48, 0x65, 0x72, 0x6f, 0x43, 0x61, 0x72, 0x64, 0x49, 0x64, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x48, 0x65, 0x72, 0x6f, 0x43, 0x61, 0x72, 0x64, 0x49, 0x64,
|
||||
0x12, 0x20, 0x0a, 0x0b, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x18,
|
||||
0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74,
|
||||
0x49, 0x64, 0x22, 0x43, 0x0a, 0x12, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x45,
|
||||
0x71, 0x75, 0x69, 0x70, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2d, 0x0a, 0x0a, 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, 0x0a, 0x45, 0x71, 0x75,
|
||||
0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x37, 0x0a, 0x13, 0x45, 0x71, 0x75, 0x69, 0x70,
|
||||
0x6d, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x71, 0x12, 0x20,
|
||||
0x0a, 0x0b, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x0b, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64,
|
||||
0x22, 0x5b, 0x0a, 0x14, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67,
|
||||
0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 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,
|
||||
0x0a, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x44, 0x0a, 0x13, 0x45,
|
||||
0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x75,
|
||||
0x73, 0x68, 0x12, 0x2d, 0x0a, 0x0a, 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, 0x0a, 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,
|
||||
0x75, 0x69, 0x70, 0x52, 0x65, 0x71, 0x12, 0x1e, 0x0a, 0x0a, 0x48, 0x65, 0x72, 0x6f, 0x43, 0x61,
|
||||
0x72, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x48, 0x65, 0x72, 0x6f,
|
||||
0x43, 0x61, 0x72, 0x64, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d,
|
||||
0x65, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x45, 0x71, 0x75,
|
||||
0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x43, 0x0a, 0x12, 0x45, 0x71, 0x75, 0x69,
|
||||
0x70, 0x6d, 0x65, 0x6e, 0x74, 0x45, 0x71, 0x75, 0x69, 0x70, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2d,
|
||||
0x0a, 0x0a, 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, 0x0a, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x37, 0x0a,
|
||||
0x13, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64,
|
||||
0x65, 0x52, 0x65, 0x71, 0x12, 0x20, 0x0a, 0x0b, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e,
|
||||
0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x45, 0x71, 0x75, 0x69, 0x70,
|
||||
0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x5b, 0x0a, 0x14, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d,
|
||||
0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16,
|
||||
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 (
|
||||
@ -362,25 +415,27 @@ func file_equipment_equipment_msg_proto_rawDescGZIP() []byte {
|
||||
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{}{
|
||||
(*EquipmentGetListReq)(nil), // 0: EquipmentGetListReq
|
||||
(*EquipmentGetListResp)(nil), // 1: EquipmentGetListResp
|
||||
(*EquipmentEquipReq)(nil), // 2: EquipmentEquipReq
|
||||
(*EquipmentEquipResp)(nil), // 3: EquipmentEquipResp
|
||||
(*EquipmentUpgradeReq)(nil), // 4: EquipmentUpgradeReq
|
||||
(*EquipmentUpgradeResp)(nil), // 5: EquipmentUpgradeResp
|
||||
(*DB_Equipment)(nil), // 6: DB_Equipment
|
||||
(*EquipmentChangePush)(nil), // 2: EquipmentChangePush
|
||||
(*EquipmentEquipReq)(nil), // 3: EquipmentEquipReq
|
||||
(*EquipmentEquipResp)(nil), // 4: EquipmentEquipResp
|
||||
(*EquipmentUpgradeReq)(nil), // 5: EquipmentUpgradeReq
|
||||
(*EquipmentUpgradeResp)(nil), // 6: EquipmentUpgradeResp
|
||||
(*DB_Equipment)(nil), // 7: DB_Equipment
|
||||
}
|
||||
var file_equipment_equipment_msg_proto_depIdxs = []int32{
|
||||
6, // 0: EquipmentGetListResp.Equipments:type_name -> DB_Equipment
|
||||
6, // 1: EquipmentEquipResp.Equipments:type_name -> DB_Equipment
|
||||
6, // 2: EquipmentUpgradeResp.Equipment:type_name -> DB_Equipment
|
||||
3, // [3:3] is the sub-list for method output_type
|
||||
3, // [3:3] is the sub-list for method input_type
|
||||
3, // [3:3] is the sub-list for extension type_name
|
||||
3, // [3:3] is the sub-list for extension extendee
|
||||
0, // [0:3] is the sub-list for field type_name
|
||||
7, // 0: EquipmentGetListResp.Equipments:type_name -> DB_Equipment
|
||||
7, // 1: EquipmentChangePush.Equipments:type_name -> DB_Equipment
|
||||
7, // 2: EquipmentEquipResp.Equipments:type_name -> DB_Equipment
|
||||
7, // 3: EquipmentUpgradeResp.Equipment:type_name -> DB_Equipment
|
||||
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
|
||||
}
|
||||
|
||||
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{} {
|
||||
switch v := v.(*EquipmentEquipReq); i {
|
||||
switch v := v.(*EquipmentChangePush); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
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{} {
|
||||
switch v := v.(*EquipmentEquipResp); i {
|
||||
switch v := v.(*EquipmentEquipReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
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{} {
|
||||
switch v := v.(*EquipmentUpgradeReq); i {
|
||||
switch v := v.(*EquipmentEquipResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
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{} {
|
||||
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 {
|
||||
case 0:
|
||||
return &v.state
|
||||
@ -469,7 +536,7 @@ func file_equipment_equipment_msg_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_equipment_equipment_msg_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 6,
|
||||
NumMessages: 7,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
@ -116,6 +116,54 @@ func (x *ItemsGetlistResp) GetGrids() []*DB_UserItemData {
|
||||
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 {
|
||||
state protoimpl.MessageState
|
||||
@ -130,7 +178,7 @@ type ItemsUseItemReq struct {
|
||||
func (x *ItemsUseItemReq) Reset() {
|
||||
*x = ItemsUseItemReq{}
|
||||
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.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -143,7 +191,7 @@ func (x *ItemsUseItemReq) String() string {
|
||||
func (*ItemsUseItemReq) ProtoMessage() {}
|
||||
|
||||
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 {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -156,7 +204,7 @@ func (x *ItemsUseItemReq) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use ItemsUseItemReq.ProtoReflect.Descriptor instead.
|
||||
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 {
|
||||
@ -190,7 +238,7 @@ type ItemsUseItemResp struct {
|
||||
func (x *ItemsUseItemResp) Reset() {
|
||||
*x = ItemsUseItemResp{}
|
||||
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.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -203,7 +251,7 @@ func (x *ItemsUseItemResp) String() string {
|
||||
func (*ItemsUseItemResp) ProtoMessage() {}
|
||||
|
||||
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 {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -216,7 +264,7 @@ func (x *ItemsUseItemResp) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use ItemsUseItemResp.ProtoReflect.Descriptor instead.
|
||||
func (*ItemsUseItemResp) Descriptor() ([]byte, []int) {
|
||||
return file_items_items_msg_proto_rawDescGZIP(), []int{3}
|
||||
return file_items_items_msg_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
//出售道具请求sailitem
|
||||
@ -233,7 +281,7 @@ type ItemsSellItemReq struct {
|
||||
func (x *ItemsSellItemReq) Reset() {
|
||||
*x = ItemsSellItemReq{}
|
||||
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.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -246,7 +294,7 @@ func (x *ItemsSellItemReq) String() string {
|
||||
func (*ItemsSellItemReq) ProtoMessage() {}
|
||||
|
||||
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 {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -259,7 +307,7 @@ func (x *ItemsSellItemReq) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use ItemsSellItemReq.ProtoReflect.Descriptor instead.
|
||||
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 {
|
||||
@ -293,7 +341,7 @@ type ItemsSellItemResp struct {
|
||||
func (x *ItemsSellItemResp) Reset() {
|
||||
*x = ItemsSellItemResp{}
|
||||
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.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -306,7 +354,7 @@ func (x *ItemsSellItemResp) String() string {
|
||||
func (*ItemsSellItemResp) ProtoMessage() {}
|
||||
|
||||
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 {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -319,7 +367,7 @@ func (x *ItemsSellItemResp) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use ItemsSellItemResp.ProtoReflect.Descriptor instead.
|
||||
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
|
||||
@ -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,
|
||||
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,
|
||||
0x64, 0x73, 0x22, 0x59, 0x0a, 0x0f, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x55, 0x73, 0x65, 0x49, 0x74,
|
||||
0x65, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a,
|
||||
0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49,
|
||||
0x74, 0x65, 0x6d, 0x49, 0x64, 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, 0x12, 0x0a,
|
||||
0x10, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73,
|
||||
0x70, 0x22, 0x5a, 0x0a, 0x10, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74,
|
||||
0x65, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a,
|
||||
0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49,
|
||||
0x74, 0x65, 0x6d, 0x49, 0x64, 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,
|
||||
0x64, 0x73, 0x22, 0x39, 0x0a, 0x0f, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x43, 0x68, 0x61, 0x6e, 0x67,
|
||||
0x65, 0x50, 0x75, 0x73, 0x68, 0x12, 0x26, 0x0a, 0x05, 0x47, 0x72, 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, 0x64, 0x73, 0x22, 0x59, 0x0a,
|
||||
0x0f, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71,
|
||||
0x12, 0x16, 0x0a, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d,
|
||||
0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64,
|
||||
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, 0x12, 0x0a, 0x10, 0x49, 0x74, 0x65, 0x6d,
|
||||
0x73, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x22, 0x5a, 0x0a, 0x10,
|
||||
0x49, 0x74, 0x65, 0x6d, 0x73, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71,
|
||||
0x12, 0x16, 0x0a, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d,
|
||||
0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64,
|
||||
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 (
|
||||
@ -364,23 +415,25 @@ func file_items_items_msg_proto_rawDescGZIP() []byte {
|
||||
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{}{
|
||||
(*ItemsGetlistReq)(nil), // 0: ItemsGetlistReq
|
||||
(*ItemsGetlistResp)(nil), // 1: ItemsGetlistResp
|
||||
(*ItemsUseItemReq)(nil), // 2: ItemsUseItemReq
|
||||
(*ItemsUseItemResp)(nil), // 3: ItemsUseItemResp
|
||||
(*ItemsSellItemReq)(nil), // 4: ItemsSellItemReq
|
||||
(*ItemsSellItemResp)(nil), // 5: ItemsSellItemResp
|
||||
(*DB_UserItemData)(nil), // 6: DB_UserItemData
|
||||
(*ItemsChangePush)(nil), // 2: ItemsChangePush
|
||||
(*ItemsUseItemReq)(nil), // 3: ItemsUseItemReq
|
||||
(*ItemsUseItemResp)(nil), // 4: ItemsUseItemResp
|
||||
(*ItemsSellItemReq)(nil), // 5: ItemsSellItemReq
|
||||
(*ItemsSellItemResp)(nil), // 6: ItemsSellItemResp
|
||||
(*DB_UserItemData)(nil), // 7: DB_UserItemData
|
||||
}
|
||||
var file_items_items_msg_proto_depIdxs = []int32{
|
||||
6, // 0: ItemsGetlistResp.Grids:type_name -> DB_UserItemData
|
||||
1, // [1:1] is the sub-list for method output_type
|
||||
1, // [1:1] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
7, // 0: ItemsGetlistResp.Grids:type_name -> DB_UserItemData
|
||||
7, // 1: ItemsChangePush.Grids:type_name -> DB_UserItemData
|
||||
2, // [2:2] is the sub-list for method output_type
|
||||
2, // [2:2] is the sub-list for method input_type
|
||||
2, // [2:2] is the sub-list for extension 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() }
|
||||
@ -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{} {
|
||||
switch v := v.(*ItemsUseItemReq); i {
|
||||
switch v := v.(*ItemsChangePush); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
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{} {
|
||||
switch v := v.(*ItemsUseItemResp); i {
|
||||
switch v := v.(*ItemsUseItemReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
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{} {
|
||||
switch v := v.(*ItemsSellItemReq); i {
|
||||
switch v := v.(*ItemsUseItemResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
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{} {
|
||||
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 {
|
||||
case 0:
|
||||
return &v.state
|
||||
@ -469,7 +534,7 @@ func file_items_items_msg_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_items_items_msg_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 6,
|
||||
NumMessages: 7,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
@ -11,6 +11,11 @@ message EquipmentGetListResp {
|
||||
repeated DB_Equipment Equipments = 1; //装备列表
|
||||
}
|
||||
|
||||
//推送装备背包变化
|
||||
message EquipmentChangePush {
|
||||
repeated DB_Equipment Equipments = 1; //装备列表
|
||||
}
|
||||
|
||||
//装备挂在到英雄上
|
||||
message EquipmentEquipReq{
|
||||
string HeroCardId = 1; //英雄卡Id
|
||||
|
@ -12,6 +12,11 @@ message ItemsGetlistResp {
|
||||
repeated DB_UserItemData Grids = 1; //用户背包列表
|
||||
}
|
||||
|
||||
//背包变化推送
|
||||
message ItemsChangePush {
|
||||
repeated DB_UserItemData Grids = 1; //变化数据
|
||||
}
|
||||
|
||||
//使用物品请求
|
||||
message ItemsUseItemReq {
|
||||
string GridId = 1; //格子Id
|
||||
|
@ -28,7 +28,7 @@ func ValidSecretKey(secStr string) bool {
|
||||
|
||||
clientMd5Key := secStr[3:35]
|
||||
rawmsg := secStr[35:]
|
||||
log.Debugf("data base: %s", rawmsg)
|
||||
serverMd5Key := MD5Str(rawmsg) //这里可以再加上客户端和服务端的秘钥再MD5
|
||||
// log.Debugf("data base: %s", rawmsg)
|
||||
serverMd5Key := MD5Str(rawmsg) //这里可以再加上客户端和服务端的秘钥再MD5
|
||||
return strings.EqualFold(strings.ToLower(serverMd5Key), strings.ToLower(clientMd5Key))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user