This commit is contained in:
zhaocy 2022-07-14 17:46:04 +08:00
commit 3fccabd82b
61 changed files with 1301 additions and 379 deletions

View File

@ -26,9 +26,9 @@ type (
//查询用户背包多个物品数量 //查询用户背包多个物品数量
QueryItemsAmount(source *ModuleCallSource, uId string, itemid ...int32) (result map[int32]uint32) QueryItemsAmount(source *ModuleCallSource, uId string, itemid ...int32) (result map[int32]uint32)
///添加单个物品到背包 (可以加物品和减物品) ///添加单个物品到背包 (可以加物品和减物品)
AddItem(source *ModuleCallSource, uId string, itemid, addnum int32) (code pb.ErrorCode) AddItem(source *ModuleCallSource, uId string, itemid, addnum int32, bPush bool) (code pb.ErrorCode)
///添加多个物品到背包 (可以加物品和减物品) ///添加多个物品到背包 (可以加物品和减物品)
AddItems(source *ModuleCallSource, uId string, items map[int32]int32) (code pb.ErrorCode) AddItems(source *ModuleCallSource, uId string, items map[int32]int32, bPush bool) (code pb.ErrorCode)
} }
//英雄 //英雄
@ -36,7 +36,7 @@ type (
//查询用户卡片数量 //查询用户卡片数量
QueryHeroAmount(uId string, heroCfgId int32) (amount uint32) QueryHeroAmount(uId string, heroCfgId int32) (amount uint32)
//创建新英雄 //创建新英雄
CreateHero(uid string, heroCfgId ...int32) error CreateHero(uid string, bPush bool, heroCfgId ...int32) error
// 获取英雄 // 获取英雄
// heroId 英雄ID // heroId 英雄ID
@ -55,8 +55,8 @@ type (
GetUserSession(uid string) *pb.CacheUser GetUserSession(uid string) *pb.CacheUser
//查询用户属性值 例如 金币 经验 //查询用户属性值 例如 金币 经验
QueryAttributeValue(uid string, attr string) (value int32) QueryAttributeValue(uid string, attr string) (value int32)
//添加/减少属性值 //添加/减少属性值 第四个参数控制是否推送给前端
AddAttributeValue(uid string, attr string, add int32) (code pb.ErrorCode) AddAttributeValue(uid string, attr string, add int32, bPush bool) (code pb.ErrorCode)
} }
//武器模块 //武器模块
IEquipment interface { IEquipment interface {
@ -65,7 +65,7 @@ type (
//查询服务资源数量 参数武器配置id //查询服务资源数量 参数武器配置id
QueryEquipmentAmount(source *ModuleCallSource, uid string, equipmentId int32) (amount uint32) QueryEquipmentAmount(source *ModuleCallSource, uid string, equipmentId int32) (amount uint32)
//添加新武器 //添加新武器
AddNewEquipments(source *ModuleCallSource, uid string, cIds map[int32]uint32) (code pb.ErrorCode) AddNewEquipments(source *ModuleCallSource, uid string, cIds map[int32]uint32, bPush bool) (code pb.ErrorCode)
} }
IStory interface { IStory interface {
// 修改章节信息 // 修改章节信息

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

@ -89,3 +89,21 @@ func (this *Redis) UnLock(key string) (err error) {
err = this.Delete(key) err = this.Delete(key)
return return
} }
//lua Script
func (this *Redis) NewScript(src string) *redis.StringCmd {
script := redis.NewScript(src)
return script.Load(this.getContext(), this.client)
}
func (this *Redis) Eval(script string, keys []string, args ...interface{}) *redis.Cmd {
return this.client.Eval(this.getContext(), script, keys, args...)
}
func (this *Redis) EvalSha(sha1 string, keys []string, args ...interface{}) *redis.Cmd {
return this.client.EvalSha(this.getContext(), sha1, keys, args...)
}
func (this *Redis) ScriptExists(hashes ...string) *redis.BoolSliceCmd {
return this.client.ScriptExists(this.getContext(), hashes...)
}
func (this *Redis) ScriptLoad(script string) *redis.StringCmd {
return this.client.ScriptLoad(this.getContext(), script)
}

View File

@ -16,6 +16,7 @@ type (
Pipeline(ctx context.Context, fn func(pipe redis.Pipeliner) error) (err error) Pipeline(ctx context.Context, fn func(pipe redis.Pipeliner) error) (err error)
TxPipelined(ctx context.Context, fn func(pipe redis.Pipeliner) error) (err error) TxPipelined(ctx context.Context, fn func(pipe redis.Pipeliner) error) (err error)
Watch(ctx context.Context, fn func(*redis.Tx) error, keys ...string) (err error) Watch(ctx context.Context, fn func(*redis.Tx) error, keys ...string) (err error)
/*Key*/ /*Key*/
Delete(key string) (err error) Delete(key string) (err error)
ExistsKey(key string) (iskeep bool, err error) ExistsKey(key string) (iskeep bool, err error)
@ -112,6 +113,12 @@ type (
ZScore(key string, member string) (result float64, err error) ZScore(key string, member string) (result float64, err error)
ZUnionStore(dest string, store *redis.ZStore) (result int64, err error) ZUnionStore(dest string, store *redis.ZStore) (result int64, err error)
ZScan(key string, _cursor uint64, match string, count int64) (keys []string, cursor uint64, err error) ZScan(key string, _cursor uint64, match string, count int64) (keys []string, cursor uint64, err error)
/*Lua Script*/
NewScript(src string) *redis.StringCmd
Eval(script string, keys []string, args ...interface{}) *redis.Cmd
EvalSha(sha1 string, keys []string, args ...interface{}) *redis.Cmd
ScriptExists(hashes ...string) *redis.BoolSliceCmd
} }
ISys interface { ISys interface {
@ -445,3 +452,17 @@ func ZUnionStore(dest string, store *redis.ZStore) (result int64, err error) {
func ZScan(key string, _cursor uint64, match string, count int64) (keys []string, cursor uint64, err error) { func ZScan(key string, _cursor uint64, match string, count int64) (keys []string, cursor uint64, err error) {
return defsys.ZScan(key, _cursor, match, count) return defsys.ZScan(key, _cursor, match, count)
} }
/*Lua Script*/
func NewScript(src string) *redis.StringCmd {
return defsys.NewScript(src)
}
func Eval(script string, keys []string, args ...interface{}) *redis.Cmd {
return defsys.Eval(script, keys, args...)
}
func EvalSha(sha1 string, keys []string, args ...interface{}) *redis.Cmd {
return defsys.Eval(sha1, keys, args...)
}
func ScriptExists(hashes ...string) *redis.BoolSliceCmd {
return defsys.ScriptExists(hashes...)
}

View File

@ -45,7 +45,6 @@ func (this *Redis) init() (err error) {
} }
return return
} }
func (this *Redis) Close() (err error) { func (this *Redis) Close() (err error) {
return this.client.Close() return this.client.Close()
} }
@ -67,15 +66,12 @@ func (this *Redis) Lock(key string, outTime int) (result bool, err error) {
func (this *Redis) UnLock(key string) (err error) { func (this *Redis) UnLock(key string) (err error) {
return this.client.UnLock(key) return this.client.UnLock(key)
} }
func (this *Redis) Delete(key string) (err error) { func (this *Redis) Delete(key string) (err error) {
return this.client.Delete(key) return this.client.Delete(key)
} }
func (this *Redis) ExistsKey(key string) (iskeep bool, err error) { func (this *Redis) ExistsKey(key string) (iskeep bool, err error) {
return this.client.ExistsKey(key) return this.client.ExistsKey(key)
} }
func (this *Redis) Expire(key string, expire time.Duration) (err error) { func (this *Redis) Expire(key string, expire time.Duration) (err error) {
return this.client.Expire(key, expire) return this.client.Expire(key, expire)
} }
@ -106,8 +102,6 @@ func (this *Redis) RenameNX(oldkey string, newkey string) (err error) {
func (this *Redis) Keys(pattern string) (keys []string, err error) { func (this *Redis) Keys(pattern string) (keys []string, err error) {
return this.client.Keys(pattern) return this.client.Keys(pattern)
} }
///获取键类型
func (this *Redis) Type(key string) (ty string, err error) { func (this *Redis) Type(key string) (ty string, err error) {
return this.client.Type(key) return this.client.Type(key)
} }
@ -355,6 +349,20 @@ func (this *Redis) ZScan(key string, _cursor uint64, match string, count int64)
return this.client.ZScan(key, _cursor, match, count) return this.client.ZScan(key, _cursor, match, count)
} }
//lua Script
func (this *Redis) NewScript(src string) *redis.StringCmd {
return this.client.NewScript(src)
}
func (this *Redis) Eval(script string, keys []string, args ...interface{}) *redis.Cmd {
return this.client.Eval(script, keys, args...)
}
func (this *Redis) EvalSha(sha1 string, keys []string, args ...interface{}) *redis.Cmd {
return this.client.EvalSha(sha1, keys, args...)
}
func (this *Redis) ScriptExists(hashes ...string) *redis.BoolSliceCmd {
return this.client.ScriptExists(hashes...)
}
//Codec--------------------------------------------------------------------------------------------------------------------------------------- //Codec---------------------------------------------------------------------------------------------------------------------------------------
func (this *Redis) Marshal(v interface{}) ([]byte, error) { func (this *Redis) Marshal(v interface{}) ([]byte, error) {
if this.options.Codec != nil { if this.options.Codec != nil {

View File

@ -88,3 +88,21 @@ func (this *Redis) UnLock(key string) (err error) {
err = this.Delete(key) err = this.Delete(key)
return return
} }
//lua Script
func (this *Redis) NewScript(src string) *redis.StringCmd {
script := redis.NewScript(src)
return script.Load(this.getContext(), this.client)
}
func (this *Redis) Eval(script string, keys []string, args ...interface{}) *redis.Cmd {
return this.client.Eval(this.getContext(), script, keys, args...)
}
func (this *Redis) EvalSha(sha1 string, keys []string, args ...interface{}) *redis.Cmd {
return this.client.EvalSha(this.getContext(), sha1, keys, args...)
}
func (this *Redis) ScriptExists(hashes ...string) *redis.BoolSliceCmd {
return this.client.ScriptExists(this.getContext(), hashes...)
}
func (this *Redis) ScriptLoad(script string) *redis.StringCmd {
return this.client.ScriptLoad(this.getContext(), script)
}

View File

@ -3,6 +3,7 @@ package redis_test
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"log"
"os" "os"
"sync" "sync"
"testing" "testing"
@ -181,25 +182,56 @@ func Test_Redis_Encoder_int(t *testing.T) {
} }
func Test_Redis_Encoder_Hash(t *testing.T) { func Test_Redis_Encoder_Hash(t *testing.T) {
// err := redis.HMSet("test:1005", &TestData{Name: "liwei1dao", Agr: 12, Sub: &TestAny{SubName: "test", Age: 20}})
// fmt.Printf("err:%v\n", err)
// data := &TestData{}
// err = redis.HGetAll("test:1005", data)
// fmt.Printf("data:%v err:%v\n", data, err)
// redis.HSet("test:1003", "Name", "eeee")
name := "" name := ""
err := redis.HGet("test:103", "name", &name) err := redis.HGet("test:103", "name", &name)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
fmt.Println(name) fmt.Println(name)
}
// data1 := map[string]*TestData{"li_1": {Name: "liwei2dao", Agr: 56}, "li_2": {Name: "liwei3dao", Agr: 78}}
// err := redis.HMSet("test:1004", data1) //测试redis lua 脚本
// fmt.Printf("err:%v\n", err) func Test_Redis_Lua(t *testing.T) {
// data2 := make(map[string]*TestData) script := redis.NewScript(`
// err = redis.HGetAll("test:1004", data2) local goodsSurplus
// fmt.Printf("data2:%v err:%v\n", data2, err) local flag
local existUserIds = tostring(KEYS[1])
local memberUid = tonumber(ARGV[1])
local goodsSurplusKey = tostring(KEYS[2])
local hasBuy = redis.call("sIsMember", existUserIds, memberUid)
if hasBuy ~= 0 then
return 0
end
goodsSurplus = redis.call("GET", goodsSurplusKey)
if goodsSurplus == false then
return 0
end
-- 没有剩余可抢购物品
goodsSurplus = tonumber(goodsSurplus)
if goodsSurplus <= 0 then
return 0
end
flag = redis.call("SADD", existUserIds, memberUid)
flag = redis.call("DECR", goodsSurplusKey)
return 1
`)
sha, err := script.Result()
if err != nil {
log.Fatalln(err)
}
ret := redis.EvalSha(sha, []string{
"hadBuyUids",
"goodsSurplus",
}, "userId")
if result, err := ret.Result(); err != nil {
log.Fatalf("Execute Redis fail: %v", err.Error())
} else {
fmt.Println("")
fmt.Printf("userid: %s, result: %d", "userId", result)
}
} }

View File

@ -18,32 +18,34 @@ 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),
conns: make(map[string]net.Conn), otherClusterClients: make(map[string]map[string]client.XClient),
connecting: make(map[string]struct{}), conns: make(map[string]net.Conn),
serviceMap: make(map[string]*service), connecting: make(map[string]struct{}),
msgChan: make(chan *protocol.Message, 1000), serviceMap: make(map[string]*service),
msgChan: make(chan *protocol.Message, 1000),
} }
return return
} }
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
connsMapMu sync.RWMutex otherClusterClients map[string]map[string]client.XClient //其他集群客户端
conns map[string]net.Conn connsMapMu sync.RWMutex
connectMapMu sync.RWMutex conns map[string]net.Conn
connecting map[string]struct{} connectMapMu sync.RWMutex
serviceMapMu sync.RWMutex connecting map[string]struct{}
serviceMap map[string]*service serviceMapMu sync.RWMutex
msgChan chan *protocol.Message // 接收rpcXServer推送消息 serviceMap map[string]*service
msgChan chan *protocol.Message // 接收rpcXServer推送消息
} }
// DoMessage 服务端消息处理 // DoMessage 服务端消息处理
@ -132,9 +134,10 @@ 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{
CallRoutRulesKey: servicePath, ServiceClusterTag: this.options.ServiceTag,
ServiceAddrKey: "tcp@" + this.options.ServiceAddr, CallRoutRulesKey: servicePath,
ServiceMetaKey: this.metadata, ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
ServiceMetaKey: this.metadata,
}) })
err = c.Call(ctx, serviceMethod, args, reply) err = c.Call(ctx, serviceMethod, args, reply)
return return
@ -164,9 +167,93 @@ 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{
CallRoutRulesKey: servicePath, ServiceClusterTag: this.options.ServiceTag,
ServiceAddrKey: "tcp@" + this.options.ServiceAddr, CallRoutRulesKey: servicePath,
ServiceMetaKey: this.metadata, 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) return c.Go(ctx, string(serviceMethod), args, reply, done)
} }

View File

@ -10,9 +10,10 @@ import (
) )
const ( const (
ServiceMetaKey = "smeta" ServiceClusterTag = "ctag"
ServiceAddrKey = "addr" ServiceMetaKey = "smeta"
CallRoutRulesKey = "callrules" ServiceAddrKey = "addr"
CallRoutRulesKey = "callrules"
) )
const RpcX_ShakeHands = "RpcX_ShakeHands" //握手 const RpcX_ShakeHands = "RpcX_ShakeHands" //握手
@ -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,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) { 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 addr, ok := req_metadata[ServiceAddrKey]; ok { if stag, ok = req_metadata[ServiceClusterTag]; ok {
if _, ok = this.clientmeta[addr]; !ok { if selector, ok = this.selectors[stag]; !ok {
if smeta, ok := req_metadata[ServiceMetaKey]; ok { this.selectors[stag] = newSelector(nil)
servers := make(map[string]string) selector = this.selectors[stag]
this.clientmutex.Lock() }
this.clientmeta[addr] = smeta if addr, ok := req_metadata[ServiceAddrKey]; ok {
this.clients[addr] = ctx.Value(server.RemoteConnContextKey).(net.Conn) if _, ok = this.clientmeta[addr]; !ok {
for k, v := range this.clientmeta { if smeta, ok := req_metadata[ServiceMetaKey]; ok {
servers[k] = v 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 ( 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,9 +313,10 @@ func (this *Service) call(ctx context.Context, servicePath string, serviceMethod
return return
} }
metadata = map[string]string{ metadata = map[string]string{
CallRoutRulesKey: servicePath, ServiceClusterTag: clusterTag,
ServiceAddrKey: "tcp@" + this.options.ServiceAddr, CallRoutRulesKey: servicePath,
ServiceMetaKey: this.metadata, ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
ServiceMetaKey: this.metadata,
} }
spath = strings.Split(servicePath, "/") spath = strings.Split(servicePath, "/")
ctx = context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{ 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, 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

@ -71,7 +71,7 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade
} }
} }
if issucc { if issucc {
if code = this.module.CheckConsumeRes(session.GetUserId(), intensify.Need); code != pb.ErrorCode_Success { if code = this.module.CheckConsumeRes(session.GetUserId(), intensify.Need, true); code != pb.ErrorCode_Success {
return return
} }
modifyequipments = make([]*pb.DB_Equipment, 0) modifyequipments = make([]*pb.DB_Equipment, 0)

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

@ -80,11 +80,28 @@ 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, bPush bool) (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 && bPush {
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

@ -102,7 +102,7 @@ func Test_Module_AddNewEquipments(t *testing.T) {
Module: "Test", Module: "Test",
FuncName: "Test_Module", FuncName: "Test_Module",
Describe: "摸底测试", Describe: "摸底测试",
}, "0_62b16dda909b2f8faeff788d", map[int32]uint32{10001: 1}) }, "0_62b16dda909b2f8faeff788d", map[int32]uint32{10001: 1}, true)
log.Debugf("Test_Module Code:%d", code) log.Debugf("Test_Module Code:%d", code)
} }

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,28 +214,58 @@ 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 {
servicePath = rule 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 { } else {
if len(this.wId) > 0 { 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 err = this.gateway.Service().RpcCall(context.Background(), servicePath, string(comm.Rpc_GatewayRoute), &pb.AgentMessage{
Ip: this.IP(), if len(serviceTag) == 0 {
UserSessionId: this.sessionId, if err = this.gateway.Service().RpcCall(context.Background(), servicePath, string(comm.Rpc_GatewayRoute), &pb.AgentMessage{
UserId: this.uId, Ip: this.IP(),
GatewayServiceId: this.gateway.Service().GetId(), UserSessionId: this.sessionId,
MainType: msg.MainType, UserId: this.uId,
SubType: msg.SubType, GatewayServiceId: this.gateway.Service().GetId(),
Message: msg.Data, MainType: msg.MainType,
}, reply); err != nil { SubType: msg.SubType,
log.Errorf("agent:%s uId:%s MessageDistribution err:%v", this.sessionId, this.uId, err) Message: msg.Data,
return }, 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 { if reply.Code != pb.ErrorCode_Success {

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

@ -54,7 +54,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
return return
} }
// 消耗校验 // 消耗校验
code = this.module.CheckConsumeRes(session.GetUserId(), awakenData.Phaseneed) code = this.module.CheckConsumeRes(session.GetUserId(), awakenData.Phaseneed, true)
if code != pb.ErrorCode_Success { if code != pb.ErrorCode_Success {
return return
} }

View File

@ -27,7 +27,7 @@ func (this *apiComp) Chouka(session comm.IUserSession, req *pb.HeroChoukaReq) (c
}() }()
heroCfgIds := req.HeroIds heroCfgIds := req.HeroIds
if err := this.module.modelHero.createMultiHero(session.GetUserId(), heroCfgIds...); err != nil { if err := this.module.modelHero.createMultiHero(session.GetUserId(), false, heroCfgIds...); err != nil {
code = pb.ErrorCode_HeroCreate code = pb.ErrorCode_HeroCreate
return return
} }

View File

@ -93,7 +93,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
return return
} }
// 消耗校验 // 消耗校验
code = this.module.CheckConsumeRes(session.GetUserId(), resonConfig.Need) code = this.module.CheckConsumeRes(session.GetUserId(), resonConfig.Need, true)
if code != pb.ErrorCode_Success { if code != pb.ErrorCode_Success {
return return
} }
@ -117,7 +117,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
return return
} }
for i := 0; i < int(v.N); i++ { // 有多少张加多少次 for i := 0; i < int(v.N); i++ { // 有多少张加多少次
this.module.modelHero.createOneHero(session.GetUserId(), int32(value)) this.module.modelHero.createOneHero(session.GetUserId(), int32(value), true)
} }
} }
} }

View File

@ -56,7 +56,7 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroReson
return return
} }
// 消耗校验 // 消耗校验
code = this.module.CheckConsumeRes(session.GetUserId(), _costConfig.Var) code = this.module.CheckConsumeRes(session.GetUserId(), _costConfig.Var, true)
if code != pb.ErrorCode_Success { if code != pb.ErrorCode_Success {
return return
} }

View File

@ -113,7 +113,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr
} }
// 消耗道具 // 消耗道具
code = this.module.ModuleUser.AddAttributeValue(session.GetUserId(), "gold", -target.Gold) // 减少金币 code = this.module.ModuleUser.AddAttributeValue(session.GetUserId(), "gold", -target.Gold, true) // 减少金币
if code != pb.ErrorCode_Success { if code != pb.ErrorCode_Success {
this.module.Errorf("cost gold failed ,count = %d", target.Gold) this.module.Errorf("cost gold failed ,count = %d", target.Gold)
code = pb.ErrorCode_GoldNoEnough code = pb.ErrorCode_GoldNoEnough

View File

@ -129,7 +129,7 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
} }
// 消耗道具 // 消耗道具
for _, v := range costRes { for _, v := range costRes {
code = this.module.CheckConsumeRes(session.GetUserId(), v) code = this.module.CheckConsumeRes(session.GetUserId(), v, true)
if code != pb.ErrorCode_Success { if code != pb.ErrorCode_Success {
return return
} }

View File

@ -70,7 +70,7 @@ func TestMain(m *testing.M) {
//创建一个英雄s //创建一个英雄s
func TestCreateOneHero(t *testing.T) { func TestCreateOneHero(t *testing.T) {
err := module.modelHero.createOneHero("u1", 25001) err := module.modelHero.createOneHero("u1", 25001, true)
fmt.Println(err) fmt.Println(err)
} }

View File

@ -85,7 +85,7 @@ func (this *ModelHero) initHeroSkill(hero *pb.DBHero) []*pb.SkillData {
} }
//创建一个指定的英雄 //创建一个指定的英雄
func (this *ModelHero) createOneHero(uid string, heroCfgId int32) (err error) { func (this *ModelHero) createOneHero(uid string, heroCfgId int32, bPush bool) (err error) {
hero := this.initHero(uid, heroCfgId) hero := this.initHero(uid, heroCfgId)
if hero != nil { if hero != nil {
if err = this.moduleHero.modelHero.AddList(uid, hero.Id, hero); err != nil { if err = this.moduleHero.modelHero.AddList(uid, hero.Id, hero); err != nil {
@ -93,16 +93,24 @@ func (this *ModelHero) createOneHero(uid string, heroCfgId int32) (err error) {
return return
} }
} }
// 创建英雄成功 向客户端推送数据
if bPush {
if session, ok := this.moduleHero.GetUserSession(uid); ok {
session.SendMsg(string(this.moduleHero.GetType()), "addhero", &pb.AddNewHeroPush{Hero: hero})
err = session.Push()
}
}
return nil return nil
} }
//创建多个指定的英雄 heroCfgIds可填入多个英雄ID //创建多个指定的英雄 heroCfgIds可填入多个英雄ID
func (this *ModelHero) createMultiHero(uid string, heroCfgIds ...int32) error { func (this *ModelHero) createMultiHero(uid string, bPush bool, heroCfgIds ...int32) error {
heroes := this.moduleHero.modelHero.getHeroList(uid) heroes := this.moduleHero.modelHero.getHeroList(uid)
if len(heroes) == 0 { if len(heroes) == 0 {
for _, v := range heroCfgIds { for _, v := range heroCfgIds {
if err := this.createOneHero(uid, v); err != nil { if err := this.createOneHero(uid, v, bPush); err != nil {
return err return err
} }
} }
@ -126,7 +134,7 @@ func (this *ModelHero) createMultiHero(uid string, heroCfgIds ...int32) error {
return err return err
} }
} else { } else {
if err := this.createOneHero(uid, v); err != nil { if err := this.createOneHero(uid, v, bPush); err != nil {
return err return err
} }
} }

View File

@ -39,8 +39,8 @@ func (this *Hero) OnInstallComp() {
} }
//创建新英雄 //创建新英雄
func (this *Hero) CreateHero(uid string, heroCfgId ...int32) error { func (this *Hero) CreateHero(uid string, bPush bool, heroCfgId ...int32) error {
return this.modelHero.createMultiHero(uid, heroCfgId...) return this.modelHero.createMultiHero(uid, bPush, heroCfgId...)
} }
//获取英雄 //获取英雄

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,7 +125,8 @@ func (this *ModelItemsComp) Pack_AddItemToUserPack(uId string, itemId int32, add
this.module.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} }
add, update, del, leftnum = this.pack_addItemToUserPack(itmes, itemId, addnum) change = make([]*pb.DB_UserItemData, len(itmes))
add, update, del, leftnum = this.pack_addItemToUserPack(uId, itmes, itemId, addnum)
if leftnum < 0 { if leftnum < 0 {
err = ItemNotEnoughError err = ItemNotEnoughError
return return
@ -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,8 +171,9 @@ 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(uId, itmes, k, v)
if leftnum < 0 { if leftnum < 0 {
err = ItemNotEnoughError err = ItemNotEnoughError
return return
@ -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(uid string, 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)
} }
} }
} }
@ -312,6 +323,7 @@ func (this *ModelItemsComp) pack_addItemToUserPack(items []*pb.DB_UserItemData,
if leftnum <= int64(conf.Maxnum) { if leftnum <= int64(conf.Maxnum) {
grid := &pb.DB_UserItemData{ grid := &pb.DB_UserItemData{
GridId: primitive.NewObjectID().Hex(), GridId: primitive.NewObjectID().Hex(),
UId: uid,
ItemId: itemId, ItemId: itemId,
Amount: uint32(leftnum), Amount: uint32(leftnum),
CTime: time.Now().Unix(), CTime: time.Now().Unix(),
@ -325,6 +337,7 @@ func (this *ModelItemsComp) pack_addItemToUserPack(items []*pb.DB_UserItemData,
leftnum -= int64(conf.Maxnum) leftnum -= int64(conf.Maxnum)
grid := &pb.DB_UserItemData{ grid := &pb.DB_UserItemData{
GridId: primitive.NewObjectID().Hex(), GridId: primitive.NewObjectID().Hex(),
UId: uid,
ItemId: itemId, ItemId: itemId,
Amount: uint32(conf.Maxnum), Amount: uint32(conf.Maxnum),
CTime: time.Now().Unix(), CTime: time.Now().Unix(),

View File

@ -62,10 +62,13 @@ 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, bPush bool) (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,24 @@ func (this *Items) AddItem(source *comm.ModuleCallSource, uId string, itemid, ad
} else { } else {
code = pb.ErrorCode_Unknown code = pb.ErrorCode_Unknown
} }
return
} }
if bPush {
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, bPush bool) (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 +103,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 && bPush {
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

@ -94,6 +94,6 @@ func Test_Modules_AddItems(t *testing.T) {
Module: "Test", Module: "Test",
FuncName: "Test_Modules_AddItems", FuncName: "Test_Modules_AddItems",
Describe: "测试模块接口", Describe: "测试模块接口",
}, "0_62c259916d8cf3e4e06311a8", map[int32]int32{10001: 1000}) }, "0_62c259916d8cf3e4e06311a8", map[int32]int32{10001: 1000}, true)
log.Debugf("Test_Modules_AddItems code:%v", code) log.Debugf("Test_Modules_AddItems code:%v", code)
} }

View File

@ -46,7 +46,7 @@ func (this *apiComp) GetUserMailAttachment(session comm.IUserSession, req *pb.Ma
} }
res = append(res, d) res = append(res, d)
} }
code = this.module.api.module.CheckConsumeRes(session.GetUserId(), res) // 领取附件 code = this.module.api.module.CheckConsumeRes(session.GetUserId(), res, true) // 领取附件
if code == pb.ErrorCode_Success { if code == pb.ErrorCode_Success {
// 修改状态 // 修改状态
this.module.modelMail.Mail_UpdateMailAttachmentState(req.ObjID) this.module.modelMail.Mail_UpdateMailAttachmentState(req.ObjID)

View File

@ -36,17 +36,18 @@ func (this *Mail) OnInstallComp() {
this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp) this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp)
} }
// mail := &pb.DBMailData{
// ObjId: primitive.NewObjectID().Hex(),
// Uid: uId,
// Title: "系统邮件",
// Contex: "恭喜获得专属礼包一份",
// CreateTime: uint64(time.Now().Unix()),
// DueTime: uint64(time.Now().Unix()) + 30*24*3600, // 30天需要走配置文件
// Check: false,
// Reward: false,
// }
func (this *Mail) CreateNewMail(uId string, mail *pb.DBMailData) bool { func (this *Mail) CreateNewMail(uId string, mail *pb.DBMailData) bool {
// mail := &pb.DBMailData{
// ObjId: primitive.NewObjectID().Hex(),
// Uid: uId,
// Title: "系统邮件",
// Contex: "恭喜获得专属礼包一份",
// CreateTime: uint64(time.Now().Unix()),
// DueTime: uint64(time.Now().Unix()) + 30*24*3600, // 30天需要走配置文件
// Check: false,
// Reward: false,
// }
if mail == nil { if mail == nil {
return false return false
} }
@ -55,12 +56,16 @@ func (this *Mail) CreateNewMail(uId string, mail *pb.DBMailData) bool {
this.ModuleBase.Errorf("create mail failed") this.ModuleBase.Errorf("create mail failed")
} }
// 通知玩家 // 通知玩家
var _cache = &pb.CacheUser{} this.AddNewMailPush(uId, mail)
err = this.modelMail.MCompModel.Get(uId, _cache)
if err == nil {
return false
}
this.SendMsgToUser(string(this.GetType()), "newmail", mail, _cache)
return true return true
} }
// 获得新邮件 推送给玩家
func (this *Mail) AddNewMailPush(uid string, mail *pb.DBMailData) (err error) {
if session, ok := this.GetUserSession(uid); ok {
session.SendMsg(string(this.GetType()), "newmail", &pb.MailGetNewMailPush{Mail: mail})
err = session.Push()
}
return
}

View File

@ -1,9 +1,5 @@
package mgolog package mgolog
import (
"go_dreamfactory/lego/core"
)
const ( const (
WriteMaxNum uint32 = 1000 //一次性最处理条数 WriteMaxNum uint32 = 1000 //一次性最处理条数
ErrorMaxNum uint32 = 5 // 数据库操作最大失败次数 ErrorMaxNum uint32 = 5 // 数据库操作最大失败次数
@ -13,7 +9,3 @@ const (
var ( var (
ErrorLogCount = make(map[string]uint32, 0) ErrorLogCount = make(map[string]uint32, 0)
) )
const (
DB_ModelTable core.SqlTable = "model_log"
)

View File

@ -22,7 +22,7 @@ type DB_Comp struct {
func (this *DB_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { func (this *DB_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.MCompModel.Init(service, module, comp, options) this.MCompModel.Init(service, module, comp, options)
this.task = make(chan string, TaskMaxNum) this.task = make(chan string, TaskMaxNum)
this.TableName = "model_log"
return return
} }
@ -60,12 +60,12 @@ func (this *DB_Comp) PushUserTask(uid string) {
func (this *DB_Comp) Model_UpdateDBByLog(uid string) (err error) { func (this *DB_Comp) Model_UpdateDBByLog(uid string) (err error) {
var _data *mongo.Cursor var _data *mongo.Cursor
if uid == "" { if uid == "" {
_data, err = this.DB.Find(DB_ModelTable, bson.M{}, options.Find().SetLimit(int64(WriteMaxNum))) _data, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{}, options.Find().SetLimit(int64(WriteMaxNum)))
if err != nil { if err != nil {
return err return err
} }
} else { } else {
_data, err = this.DB.Find(DB_ModelTable, bson.M{"uid": uid}, options.Find()) _data, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{"uid": uid}, options.Find())
if err != nil { if err != nil {
return err return err
} }
@ -97,7 +97,7 @@ func (this *DB_Comp) Model_UpdateDBByLog(uid string) (err error) {
ErrorLogCount[data.ID]++ ErrorLogCount[data.ID]++
if ErrorLogCount[data.ID] >= ErrorMaxNum { // 实在是写失败了那就删除吧 if ErrorLogCount[data.ID] >= ErrorMaxNum { // 实在是写失败了那就删除吧
log.Errorf("insert db err max num %s db err:%v", data.ID, err) log.Errorf("insert db err max num %s db err:%v", data.ID, err)
_, err = this.DB.DeleteOne(DB_ModelTable, bson.M{"_id": data.ID}) _, err = this.DB.DeleteOne(core.SqlTable(this.TableName), bson.M{"_id": data.ID})
if err != nil { if err != nil {
log.Errorf("insert %s db err:%+v", data.ID, err) log.Errorf("insert %s db err:%+v", data.ID, err)
} }
@ -125,7 +125,7 @@ func (this *DB_Comp) Model_UpdateDBByLog(uid string) (err error) {
ErrorLogCount[data.ID]++ ErrorLogCount[data.ID]++
if ErrorLogCount[data.ID] >= ErrorMaxNum { // 实在是写失败了那就删除吧 if ErrorLogCount[data.ID] >= ErrorMaxNum { // 实在是写失败了那就删除吧
log.Errorf("del db err max num %s db err:%v", data.ID, err) log.Errorf("del db err max num %s db err:%v", data.ID, err)
_, err = this.DB.DeleteOne(DB_ModelTable, bson.M{"_id": data.ID}) _, err = this.DB.DeleteOne(core.SqlTable(this.TableName), bson.M{"_id": data.ID})
if err != nil { if err != nil {
log.Errorf("insert %s db err:%+v", data.ID, err) log.Errorf("insert %s db err:%+v", data.ID, err)
} }
@ -154,7 +154,7 @@ func (this *DB_Comp) Model_UpdateDBByLog(uid string) (err error) {
ErrorLogCount[data.ID]++ ErrorLogCount[data.ID]++
if ErrorLogCount[data.ID] >= ErrorMaxNum { // 超过一定次数写失败了那就删除吧 if ErrorLogCount[data.ID] >= ErrorMaxNum { // 超过一定次数写失败了那就删除吧
log.Errorf("update db err max num %s db err:%v", data.ID, err) log.Errorf("update db err max num %s db err:%v", data.ID, err)
_, err = this.DB.DeleteOne(DB_ModelTable, bson.M{"_id": data.ID}) _, err = this.DB.DeleteOne(core.SqlTable(this.TableName), bson.M{"_id": data.ID})
if err != nil { if err != nil {
log.Errorf("insert %s db err:%+v", data.ID, err) log.Errorf("insert %s db err:%+v", data.ID, err)
} }
@ -166,7 +166,7 @@ func (this *DB_Comp) Model_UpdateDBByLog(uid string) (err error) {
} }
if len(_delID) > 0 { if len(_delID) > 0 {
_, err = this.DB.DeleteMany(DB_ModelTable, bson.M{"_id": bson.M{"$in": _delID}}, options.Delete()) // 批量删除已处理的数据 _, err = this.DB.DeleteMany(core.SqlTable(this.TableName), bson.M{"_id": bson.M{"$in": _delID}}, options.Delete()) // 批量删除已处理的数据
if err != nil { if err != nil {
log.Errorf("del err %v", err) log.Errorf("del err %v", err)
} }
@ -178,7 +178,7 @@ func (this *DB_Comp) Model_UpdateDBByLog(uid string) (err error) {
// 写入日志数据 // 写入日志数据
func (this *DB_Comp) Model_InsertDBByLog(data *comm.Autogenerated) (err error) { func (this *DB_Comp) Model_InsertDBByLog(data *comm.Autogenerated) (err error) {
_, err = this.DB.InsertOne(DB_ModelTable, data) _, err = this.DB.InsertOne(core.SqlTable(this.TableName), data)
if err != nil { if err != nil {
log.Errorf("insert model db err %v", err) log.Errorf("insert model db err %v", err)
} }
@ -188,7 +188,7 @@ func (this *DB_Comp) Model_InsertDBByLog(data *comm.Autogenerated) (err error) {
// 查询 当前日志列表还有没有处理完条数 // 查询 当前日志列表还有没有处理完条数
func (this *DB_Comp) Model_TotalCount() int { func (this *DB_Comp) Model_TotalCount() int {
_data, err := this.DB.Find("DB_ModelTable", bson.M{}) _data, err := this.DB.Find(core.SqlTable(this.TableName), bson.M{})
if err == nil { if err == nil {
return _data.RemainingBatchLength() return _data.RemainingBatchLength()
} }

View File

@ -137,7 +137,7 @@ func (this *ModuleBase) SendMsgToUsers(mainType, subType string, msg proto.Messa
} }
//校验消耗资源 //校验消耗资源
func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code pb.ErrorCode) { func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn, bPush bool) (code pb.ErrorCode) {
var ( var (
err error err error
resID int resID int
@ -191,10 +191,10 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code p
for _, v := range res { for _, v := range res {
if v.A == comm.AttrType { //用户属性资源 if v.A == comm.AttrType { //用户属性资源
this.ModuleUser.AddAttributeValue(uid, v.T, -1*v.N) this.ModuleUser.AddAttributeValue(uid, v.T, -1*v.N, bPush)
} else if v.A == comm.ItemType { //道具资源 } else if v.A == comm.ItemType { //道具资源
resID, _ = strconv.Atoi(v.T) resID, _ = strconv.Atoi(v.T)
this.ModuleItems.AddItem(source, uid, int32(resID), -1*v.N) this.ModuleItems.AddItem(source, uid, int32(resID), -1*v.N, bPush)
} }
// else if v.A == comm.HeroType { //卡片资源 // else if v.A == comm.HeroType { //卡片资源
// resID, _ = strconv.Atoi(v.T) // resID, _ = strconv.Atoi(v.T)
@ -210,7 +210,7 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code p
} }
//发放资源 //发放资源
func (this *ModuleBase) DispenseRes(uid string, res []*cfg.Game_atn) (code pb.ErrorCode) { func (this *ModuleBase) DispenseRes(uid string, res []*cfg.Game_atn, bPush bool) (code pb.ErrorCode) {
var ( var (
resID int resID int
) )
@ -221,16 +221,20 @@ func (this *ModuleBase) DispenseRes(uid string, res []*cfg.Game_atn) (code pb.Er
} }
for _, v := range res { for _, v := range res {
if v.A == comm.AttrType { //用户属性资源 if v.A == comm.AttrType { //用户属性资源
this.ModuleUser.AddAttributeValue(uid, v.T, v.N) code = this.ModuleUser.AddAttributeValue(uid, v.T, v.N, bPush)
} else if v.A == comm.ItemType { //道具资源 } else if v.A == comm.ItemType { //道具资源
resID, _ = strconv.Atoi(v.T) resID, _ = strconv.Atoi(v.T)
this.ModuleItems.AddItem(source, uid, int32(resID), v.N) code = this.ModuleItems.AddItem(source, uid, int32(resID), v.N, bPush)
} else if v.A == comm.HeroType { //卡片资源 } else if v.A == comm.HeroType { //卡片资源
resID, _ = strconv.Atoi(v.T) resID, _ = strconv.Atoi(v.T)
this.ModuleHero.CreateHero(uid, int32(resID), v.N) err := this.ModuleHero.CreateHero(uid, bPush, int32(resID))
if err != nil {
code = pb.ErrorCode_HeroMaxCount
}
} else if v.A == comm.EquipmentType { } else if v.A == comm.EquipmentType {
resID, _ = strconv.Atoi(v.T) resID, _ = strconv.Atoi(v.T)
this.ModuleEquipment.AddNewEquipments(source, uid, map[int32]uint32{int32(resID): uint32(v.N)}) code = this.ModuleEquipment.AddNewEquipments(source, uid, map[int32]uint32{int32(resID): uint32(v.N)}, bPush)
} }
} }
return return
@ -253,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{}) {
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{}) { 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{}) { 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...)
}
} }

View File

@ -45,10 +45,10 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ShopBuyReq) (code pb
} }
} }
if code = this.module.CheckConsumeRes(session.GetUserId(), conf.Need); code != pb.ErrorCode_Success { if code = this.module.CheckConsumeRes(session.GetUserId(), conf.Need, true); code != pb.ErrorCode_Success {
return return
} }
if code = this.module.DispenseRes(session.GetUserId(), conf.Iteminfo); code != pb.ErrorCode_Success { if code = this.module.DispenseRes(session.GetUserId(), conf.Iteminfo, true); code != pb.ErrorCode_Success {
return return
} }
shopitem.BuyNum++ shopitem.BuyNum++

View File

@ -94,7 +94,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
} }
if req.IsManualRefresh && shopconf.Rtype == 1 { //可以手动刷新 if req.IsManualRefresh && shopconf.Rtype == 1 { //可以手动刷新
if code = this.module.CheckConsumeRes(session.GetUserId(), shopconf.Rneed); code != pb.ErrorCode_Success { if code = this.module.CheckConsumeRes(session.GetUserId(), shopconf.Rneed, true); code != pb.ErrorCode_Success {
return return
} }
var _items []*cfg.Game_shopitemData var _items []*cfg.Game_shopitemData

View File

@ -2,6 +2,7 @@ package story
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/sys/redis"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"sort" "sort"
@ -30,7 +31,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.StoryChallenge
return // 参数校验失败直接返回 return // 参数校验失败直接返回
} }
list, err := this.module.modelStory.getStoryList(session.GetUserId()) list, err := this.module.modelStory.getStoryList(session.GetUserId())
if err != nil { if err != nil && err != redis.RedisNil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
@ -60,7 +61,9 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.StoryChallenge
_data.Id = primitive.NewObjectID().Hex() _data.Id = primitive.NewObjectID().Hex()
_data.ChapterId = int32(req.ChapterId) _data.ChapterId = int32(req.ChapterId)
_mData := make(map[string]interface{}, 0) _mData := make(map[string]interface{}, 0)
_data.Uid = session.GetUserId()
_mData[_data.Id] = _data _mData[_data.Id] = _data
this.module.modelStory.addNewChapter(session.GetUserId(), _mData) this.module.modelStory.addNewChapter(session.GetUserId(), _mData)
curChapter = _data curChapter = _data
//curChapter.StoryId = chaptConfig.Fubendata[0] // 第一次挑战 //curChapter.StoryId = chaptConfig.Fubendata[0] // 第一次挑战
@ -94,6 +97,9 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.StoryChallenge
"branchID": curChapter.BranchID, "branchID": curChapter.BranchID,
} }
err = this.module.modelStory.modifyStoryData(session.GetUserId(), curChapter.Id, update) err = this.module.modelStory.modifyStoryData(session.GetUserId(), curChapter.Id, update)
} else {
code = pb.ErrorCode_ReqParameterError
return
} }
// 发奖 (奖励数据还没配置,后续补充) // 发奖 (奖励数据还没配置,后续补充)
session.SendMsg(string(this.module.GetType()), StoryChallengeResp, &pb.StoryChallengeResp{Data: curChapter}) session.SendMsg(string(this.module.GetType()), StoryChallengeResp, &pb.StoryChallengeResp{Data: curChapter})

View File

@ -50,6 +50,6 @@ func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActive
} }
//派发奖励 //派发奖励
code = this.moduleTask.DispenseRes(session.GetUserId(), conf.Reword) code = this.moduleTask.DispenseRes(session.GetUserId(), conf.Reword, true)
return return
} }

View File

@ -38,7 +38,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq)
return return
} }
//奖励 //奖励
if code = this.moduleTask.CheckConsumeRes(session.GetUserId(), conf.Reword); code != pb.ErrorCode_Success { if code = this.moduleTask.CheckConsumeRes(session.GetUserId(), conf.Reword, true); code != pb.ErrorCode_Success {
return return
} }

View File

@ -69,7 +69,7 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c
//初始化英雄卡 //初始化英雄卡
if val := this.module.configure.GetGlobalConf("init_hero"); val != "" { if val := this.module.configure.GetGlobalConf("init_hero"); val != "" {
defaultHero := utils.TrInt32(val) defaultHero := utils.TrInt32(val)
err = this.hero.CreateHero(session.GetUserId(), defaultHero...) err = this.hero.CreateHero(session.GetUserId(), true, defaultHero...)
if err != nil { if err != nil {
code = pb.ErrorCode_HeroInitCreat code = pb.ErrorCode_HeroInitCreat
return return

View File

@ -41,7 +41,7 @@ func (this *apiComp) AddRes(session comm.IUserSession, req *pb.UserAddResReq) (c
N: req.Res.N, N: req.Res.N,
} }
res = append(res, atn) res = append(res, atn)
code = this.module.DispenseRes(session.GetUserId(), res) code = this.module.DispenseRes(session.GetUserId(), res, true)
rsp.Res = req.Res rsp.Res = req.Res
return return
} }

View File

@ -74,7 +74,7 @@ func (this *User) QueryAttributeValue(uid string, attr string) (value int32) {
} }
//用户资源 //用户资源
func (this *User) AddAttributeValue(uid string, attr string, add int32) (code pb.ErrorCode) { func (this *User) AddAttributeValue(uid string, attr string, add int32, bPush bool) (code pb.ErrorCode) {
if add == 0 { if add == 0 {
log.Errorf("attr no changed,uid: %s attr: %s add: %d", uid, attr, add) log.Errorf("attr no changed,uid: %s attr: %s add: %d", uid, attr, add)
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
@ -86,6 +86,13 @@ func (this *User) AddAttributeValue(uid string, attr string, add int32) (code pb
return return
} }
_change := &pb.UserResChangePush{
Gold: user.Gold,
Exp: user.Exp,
Lv: user.Lv,
Vip: user.Vip,
Diamond: user.Diamond,
}
update := make(map[string]interface{}) update := make(map[string]interface{})
switch attr { switch attr {
case comm.ResGold: case comm.ResGold:
@ -95,6 +102,7 @@ func (this *User) AddAttributeValue(uid string, attr string, add int32) (code pb
return return
} }
} }
_change.Gold += add
update[comm.ResGold] = user.Gold + add update[comm.ResGold] = user.Gold + add
case comm.ResExp: case comm.ResExp:
if add < 0 { if add < 0 {
@ -103,6 +111,7 @@ func (this *User) AddAttributeValue(uid string, attr string, add int32) (code pb
return return
} }
} }
_change.Exp += add
update[comm.ResExp] = user.Exp + add update[comm.ResExp] = user.Exp + add
case comm.ResDiamond: case comm.ResDiamond:
if add < 0 { if add < 0 {
@ -111,6 +120,7 @@ func (this *User) AddAttributeValue(uid string, attr string, add int32) (code pb
return return
} }
} }
_change.Diamond += add
update[comm.ResDiamond] = user.Diamond + add update[comm.ResDiamond] = user.Diamond + add
} }
@ -121,5 +131,24 @@ func (this *User) AddAttributeValue(uid string, attr string, add int32) (code pb
log.Errorf("AddAttributeValue err:%v", err) log.Errorf("AddAttributeValue err:%v", err)
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
} }
data := &pb.UserResChangePush{}
var _cache = &pb.CacheUser{}
err := this.modelUser.MCompModel.Get(uid, _cache)
if err != nil {
this.SendMsgToUser(string(this.GetType()), "addres", data, _cache)
}
if bPush {
this.UserChangePush(uid, _change) // 推送玩家数据变化
}
return
}
//推送玩家账号信息变化消息
func (this *User) UserChangePush(uid string, resChange *pb.UserResChangePush) (err error) {
if session, ok := this.ModuleBase.GetUserSession(uid); ok {
session.SendMsg(string(this.GetType()), "userchange", resChange)
err = session.Push()
}
return return
} }

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

@ -83,6 +83,7 @@ const (
ErrorCode_HeroEquipUpdate ErrorCode = 1311 // 更新装备失败 ErrorCode_HeroEquipUpdate ErrorCode = 1311 // 更新装备失败
ErrorCode_HeroMaxAwaken ErrorCode = 1312 // 达到最大觉醒等级 ErrorCode_HeroMaxAwaken ErrorCode = 1312 // 达到最大觉醒等级
ErrorCode_HeroIsLock ErrorCode = 1313 // 英雄被锁定不能被消耗 ErrorCode_HeroIsLock ErrorCode = 1313 // 英雄被锁定不能被消耗
ErrorCode_HeroMaxCount ErrorCode = 1314 // 英雄达到最大数量
// equipment // equipment
ErrorCode_EquipmentOnFoundEquipment ErrorCode = 1400 // 未找到武器 ErrorCode_EquipmentOnFoundEquipment ErrorCode = 1400 // 未找到武器
ErrorCode_EquipmentLvlimitReached ErrorCode = 1401 // 武器等级已达上限 ErrorCode_EquipmentLvlimitReached ErrorCode = 1401 // 武器等级已达上限
@ -158,6 +159,7 @@ var (
1311: "HeroEquipUpdate", 1311: "HeroEquipUpdate",
1312: "HeroMaxAwaken", 1312: "HeroMaxAwaken",
1313: "HeroIsLock", 1313: "HeroIsLock",
1314: "HeroMaxCount",
1400: "EquipmentOnFoundEquipment", 1400: "EquipmentOnFoundEquipment",
1401: "EquipmentLvlimitReached", 1401: "EquipmentLvlimitReached",
1500: "StoryNotFindChapter", 1500: "StoryNotFindChapter",
@ -227,6 +229,7 @@ var (
"HeroEquipUpdate": 1311, "HeroEquipUpdate": 1311,
"HeroMaxAwaken": 1312, "HeroMaxAwaken": 1312,
"HeroIsLock": 1313, "HeroIsLock": 1313,
"HeroMaxCount": 1314,
"EquipmentOnFoundEquipment": 1400, "EquipmentOnFoundEquipment": 1400,
"EquipmentLvlimitReached": 1401, "EquipmentLvlimitReached": 1401,
"StoryNotFindChapter": 1500, "StoryNotFindChapter": 1500,
@ -272,7 +275,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
var file_errorcode_proto_rawDesc = []byte{ var file_errorcode_proto_rawDesc = []byte{
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2a, 0xf4, 0x0a, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x6f, 0x2a, 0x87, 0x0b, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d,
0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12,
0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
@ -344,23 +347,24 @@ var file_errorcode_proto_rawDesc = []byte{
0x45, 0x71, 0x75, 0x69, 0x70, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x10, 0x9f, 0x0a, 0x12, 0x12, 0x45, 0x71, 0x75, 0x69, 0x70, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x10, 0x9f, 0x0a, 0x12, 0x12,
0x0a, 0x0d, 0x48, 0x65, 0x72, 0x6f, 0x4d, 0x61, 0x78, 0x41, 0x77, 0x61, 0x6b, 0x65, 0x6e, 0x10, 0x0a, 0x0d, 0x48, 0x65, 0x72, 0x6f, 0x4d, 0x61, 0x78, 0x41, 0x77, 0x61, 0x6b, 0x65, 0x6e, 0x10,
0xa0, 0x0a, 0x12, 0x0f, 0x0a, 0x0a, 0x48, 0x65, 0x72, 0x6f, 0x49, 0x73, 0x4c, 0x6f, 0x63, 0x6b, 0xa0, 0x0a, 0x12, 0x0f, 0x0a, 0x0a, 0x48, 0x65, 0x72, 0x6f, 0x49, 0x73, 0x4c, 0x6f, 0x63, 0x6b,
0x10, 0xa1, 0x0a, 0x12, 0x1e, 0x0a, 0x19, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x10, 0xa1, 0x0a, 0x12, 0x11, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x4d, 0x61, 0x78, 0x43, 0x6f,
0x4f, 0x6e, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x75, 0x6e, 0x74, 0x10, 0xa2, 0x0a, 0x12, 0x1e, 0x0a, 0x19, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d,
0x10, 0xf8, 0x0a, 0x12, 0x1c, 0x0a, 0x17, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x4f, 0x6e, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d,
0x4c, 0x76, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x61, 0x63, 0x68, 0x65, 0x64, 0x10, 0xf9, 0x65, 0x6e, 0x74, 0x10, 0xf8, 0x0a, 0x12, 0x1c, 0x0a, 0x17, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d,
0x0a, 0x12, 0x18, 0x0a, 0x13, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x4e, 0x6f, 0x74, 0x46, 0x69, 0x6e, 0x65, 0x6e, 0x74, 0x4c, 0x76, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x61, 0x63, 0x68, 0x65,
0x64, 0x43, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72, 0x10, 0xdc, 0x0b, 0x12, 0x12, 0x0a, 0x0d, 0x53, 0x64, 0x10, 0xf9, 0x0a, 0x12, 0x18, 0x0a, 0x13, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x4e, 0x6f, 0x74,
0x74, 0x6f, 0x72, 0x79, 0x49, 0x44, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10, 0xdd, 0x0b, 0x12, 0x46, 0x69, 0x6e, 0x64, 0x43, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72, 0x10, 0xdc, 0x0b, 0x12, 0x12,
0x0d, 0x0a, 0x08, 0x54, 0x61, 0x73, 0x6b, 0x49, 0x6e, 0x69, 0x74, 0x10, 0xc0, 0x0c, 0x12, 0x0e, 0x0a, 0x0d, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x44, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10,
0x0a, 0x09, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x65, 0x74, 0x10, 0xc1, 0x0c, 0x12, 0x0f, 0xdd, 0x0b, 0x12, 0x0d, 0x0a, 0x08, 0x54, 0x61, 0x73, 0x6b, 0x49, 0x6e, 0x69, 0x74, 0x10, 0xc0,
0x0a, 0x0a, 0x54, 0x61, 0x73, 0x6b, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x10, 0xc2, 0x0c, 0x12, 0x0c, 0x12, 0x0e, 0x0a, 0x09, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x65, 0x74, 0x10, 0xc1,
0x11, 0x0a, 0x0c, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x10, 0x0c, 0x12, 0x0f, 0x0a, 0x0a, 0x54, 0x61, 0x73, 0x6b, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x10,
0xc3, 0x0c, 0x12, 0x13, 0x0a, 0x0e, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0xc2, 0x0c, 0x12, 0x11, 0x0a, 0x0c, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76,
0x49, 0x6e, 0x69, 0x74, 0x10, 0xc6, 0x0c, 0x12, 0x16, 0x0a, 0x11, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x65, 0x64, 0x10, 0xc3, 0x0c, 0x12, 0x13, 0x0a, 0x0e, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74,
0x63, 0x74, 0x69, 0x76, 0x65, 0x4e, 0x6f, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x10, 0xc4, 0x0c, 0x12, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x69, 0x74, 0x10, 0xc6, 0x0c, 0x12, 0x16, 0x0a, 0x11, 0x54, 0x61,
0x17, 0x0a, 0x12, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x4e, 0x6f, 0x65, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x4e, 0x6f, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x10,
0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xc5, 0x0c, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0xc4, 0x0c, 0x12, 0x17, 0x0a, 0x12, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4e, 0x6f, 0x65, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xc5, 0x0c, 0x42, 0x06, 0x5a, 0x04, 0x2e,
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (

61
pb/forum_db.pb.go Normal file
View File

@ -0,0 +1,61 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v3.20.0
// source: forum/forum_db.proto
package pb
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
var File_forum_forum_db_proto protoreflect.FileDescriptor
var file_forum_forum_db_proto_rawDesc = []byte{
0x0a, 0x14, 0x66, 0x6f, 0x72, 0x75, 0x6d, 0x2f, 0x66, 0x6f, 0x72, 0x75, 0x6d, 0x5f, 0x64, 0x62,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var file_forum_forum_db_proto_goTypes = []interface{}{}
var file_forum_forum_db_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_forum_forum_db_proto_init() }
func file_forum_forum_db_proto_init() {
if File_forum_forum_db_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_forum_forum_db_proto_rawDesc,
NumEnums: 0,
NumMessages: 0,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_forum_forum_db_proto_goTypes,
DependencyIndexes: file_forum_forum_db_proto_depIdxs,
}.Build()
File_forum_forum_db_proto = out.File
file_forum_forum_db_proto_rawDesc = nil
file_forum_forum_db_proto_goTypes = nil
file_forum_forum_db_proto_depIdxs = nil
}

61
pb/forum_msg.pb.go Normal file
View File

@ -0,0 +1,61 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v3.20.0
// source: forum/forum_msg.proto
package pb
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
var File_forum_forum_msg_proto protoreflect.FileDescriptor
var file_forum_forum_msg_proto_rawDesc = []byte{
0x0a, 0x15, 0x66, 0x6f, 0x72, 0x75, 0x6d, 0x2f, 0x66, 0x6f, 0x72, 0x75, 0x6d, 0x5f, 0x6d, 0x73,
0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var file_forum_forum_msg_proto_goTypes = []interface{}{}
var file_forum_forum_msg_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_forum_forum_msg_proto_init() }
func file_forum_forum_msg_proto_init() {
if File_forum_forum_msg_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_forum_forum_msg_proto_rawDesc,
NumEnums: 0,
NumMessages: 0,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_forum_forum_msg_proto_goTypes,
DependencyIndexes: file_forum_forum_msg_proto_depIdxs,
}.Build()
File_forum_forum_msg_proto = out.File
file_forum_forum_msg_proto_rawDesc = nil
file_forum_forum_msg_proto_goTypes = nil
file_forum_forum_msg_proto_depIdxs = nil
}

View File

@ -1323,6 +1323,54 @@ func (x *HeroLockResp) GetHero() *DBHero {
return nil return nil
} }
// 增加新英雄推送
type AddNewHeroPush struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Hero *DBHero `protobuf:"bytes,1,opt,name=hero,proto3" json:"hero"` // 英雄对象
}
func (x *AddNewHeroPush) Reset() {
*x = AddNewHeroPush{}
if protoimpl.UnsafeEnabled {
mi := &file_hero_hero_msg_proto_msgTypes[25]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *AddNewHeroPush) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddNewHeroPush) ProtoMessage() {}
func (x *AddNewHeroPush) ProtoReflect() protoreflect.Message {
mi := &file_hero_hero_msg_proto_msgTypes[25]
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 AddNewHeroPush.ProtoReflect.Descriptor instead.
func (*AddNewHeroPush) Descriptor() ([]byte, []int) {
return file_hero_hero_msg_proto_rawDescGZIP(), []int{25}
}
func (x *AddNewHeroPush) GetHero() *DBHero {
if x != nil {
return x.Hero
}
return nil
}
var File_hero_hero_msg_proto protoreflect.FileDescriptor var File_hero_hero_msg_proto protoreflect.FileDescriptor
var file_hero_hero_msg_proto_rawDesc = []byte{ var file_hero_hero_msg_proto_rawDesc = []byte{
@ -1444,8 +1492,11 @@ var file_hero_hero_msg_proto_rawDesc = []byte{
0x65, 0x72, 0x6f, 0x69, 0x64, 0x22, 0x2b, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x4c, 0x6f, 0x63, 0x65, 0x72, 0x6f, 0x69, 0x64, 0x22, 0x2b, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x4c, 0x6f, 0x63,
0x6b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1b, 0x0a, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1b, 0x0a, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65,
0x72, 0x6f, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x72, 0x6f, 0x22, 0x2d, 0x0a, 0x0e, 0x41, 0x64, 0x64, 0x4e, 0x65, 0x77, 0x48, 0x65, 0x72, 0x6f,
0x6f, 0x33, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1b, 0x0a, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72,
0x6f, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
} }
var ( var (
@ -1460,7 +1511,7 @@ func file_hero_hero_msg_proto_rawDescGZIP() []byte {
return file_hero_hero_msg_proto_rawDescData return file_hero_hero_msg_proto_rawDescData
} }
var file_hero_hero_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 27) var file_hero_hero_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 28)
var file_hero_hero_msg_proto_goTypes = []interface{}{ var file_hero_hero_msg_proto_goTypes = []interface{}{
(*HeroInfoReq)(nil), // 0: HeroInfoReq (*HeroInfoReq)(nil), // 0: HeroInfoReq
(*HeroInfoResp)(nil), // 1: HeroInfoResp (*HeroInfoResp)(nil), // 1: HeroInfoResp
@ -1487,32 +1538,34 @@ var file_hero_hero_msg_proto_goTypes = []interface{}{
(*HeroProperty)(nil), // 22: HeroProperty (*HeroProperty)(nil), // 22: HeroProperty
(*HeroLockReq)(nil), // 23: HeroLockReq (*HeroLockReq)(nil), // 23: HeroLockReq
(*HeroLockResp)(nil), // 24: HeroLockResp (*HeroLockResp)(nil), // 24: HeroLockResp
nil, // 25: HeroProperty.PropertyEntry (*AddNewHeroPush)(nil), // 25: AddNewHeroPush
nil, // 26: HeroProperty.AddPropertyEntry nil, // 26: HeroProperty.PropertyEntry
(*DBHero)(nil), // 27: DBHero nil, // 27: HeroProperty.AddPropertyEntry
(*DBHero)(nil), // 28: DBHero
} }
var file_hero_hero_msg_proto_depIdxs = []int32{ var file_hero_hero_msg_proto_depIdxs = []int32{
27, // 0: HeroInfoResp.base:type_name -> DBHero 28, // 0: HeroInfoResp.base:type_name -> DBHero
27, // 1: HeroListResp.list:type_name -> DBHero 28, // 1: HeroListResp.list:type_name -> DBHero
27, // 2: HeroStrengthenUplvResp.hero:type_name -> DBHero 28, // 2: HeroStrengthenUplvResp.hero:type_name -> DBHero
7, // 3: HeroStrengthenUpStarReq.hero:type_name -> CostCardData 7, // 3: HeroStrengthenUpStarReq.hero:type_name -> CostCardData
7, // 4: HeroStrengthenUpStarReq.heroRace:type_name -> CostCardData 7, // 4: HeroStrengthenUpStarReq.heroRace:type_name -> CostCardData
27, // 5: HeroStrengthenUpStarResp.hero:type_name -> DBHero 28, // 5: HeroStrengthenUpStarResp.hero:type_name -> DBHero
27, // 6: HeroStrengthenUpSkillResp.hero:type_name -> DBHero 28, // 6: HeroStrengthenUpSkillResp.hero:type_name -> DBHero
27, // 7: HeroResonanceResp.hero:type_name -> DBHero 28, // 7: HeroResonanceResp.hero:type_name -> DBHero
27, // 8: HeroResonanceResp.upStarCard:type_name -> DBHero 28, // 8: HeroResonanceResp.upStarCard:type_name -> DBHero
27, // 9: HeroResonanceResetResp.hero:type_name -> DBHero 28, // 9: HeroResonanceResetResp.hero:type_name -> DBHero
27, // 10: HeroResonanceUseEnergyResp.hero:type_name -> DBHero 28, // 10: HeroResonanceUseEnergyResp.hero:type_name -> DBHero
27, // 11: HeroAwakenResp.hero:type_name -> DBHero 28, // 11: HeroAwakenResp.hero:type_name -> DBHero
27, // 12: HeroChoukaResp.heroes:type_name -> DBHero 28, // 12: HeroChoukaResp.heroes:type_name -> DBHero
25, // 13: HeroProperty.property:type_name -> HeroProperty.PropertyEntry 26, // 13: HeroProperty.property:type_name -> HeroProperty.PropertyEntry
26, // 14: HeroProperty.addProperty:type_name -> HeroProperty.AddPropertyEntry 27, // 14: HeroProperty.addProperty:type_name -> HeroProperty.AddPropertyEntry
27, // 15: HeroLockResp.hero:type_name -> DBHero 28, // 15: HeroLockResp.hero:type_name -> DBHero
16, // [16:16] is the sub-list for method output_type 28, // 16: AddNewHeroPush.hero:type_name -> DBHero
16, // [16:16] is the sub-list for method input_type 17, // [17:17] is the sub-list for method output_type
16, // [16:16] is the sub-list for extension type_name 17, // [17:17] is the sub-list for method input_type
16, // [16:16] is the sub-list for extension extendee 17, // [17:17] is the sub-list for extension type_name
0, // [0:16] is the sub-list for field type_name 17, // [17:17] is the sub-list for extension extendee
0, // [0:17] is the sub-list for field type_name
} }
func init() { file_hero_hero_msg_proto_init() } func init() { file_hero_hero_msg_proto_init() }
@ -1822,6 +1875,18 @@ func file_hero_hero_msg_proto_init() {
return nil return nil
} }
} }
file_hero_hero_msg_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AddNewHeroPush); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@ -1829,7 +1894,7 @@ func file_hero_hero_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_hero_hero_msg_proto_rawDesc, RawDescriptor: file_hero_hero_msg_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 27, NumMessages: 28,
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

@ -66,6 +66,7 @@ enum ErrorCode {
HeroEquipUpdate = 1311; // HeroEquipUpdate = 1311; //
HeroMaxAwaken = 1312; // HeroMaxAwaken = 1312; //
HeroIsLock = 1313; // HeroIsLock = 1313; //
HeroMaxCount = 1314; //
// equipment // equipment
EquipmentOnFoundEquipment = 1400; // EquipmentOnFoundEquipment = 1400; //

View File

@ -125,3 +125,8 @@ message HeroLockReq{
message HeroLockResp{ message HeroLockResp{
DBHero hero = 1; // DBHero hero = 1; //
} }
//
message AddNewHeroPush{
DBHero hero = 1; //
}

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

@ -39,3 +39,11 @@ message UserAddResResp {
UserAssets res = 1; // UserAssets res = 1; //
} }
//
message UserResChangePush{
int32 gold = 1; //@go_tags(`bson:"gold"`)
int32 exp = 2; //@go_tags(`bson:"exp"`)
int32 lv = 3; //@go_tags(`bson:"lv"`)
int32 vip = 4; //@go_tags(`bson:"vip"`) vip
int32 diamond = 5; //@go_tags(`bson:"diamond"`)
}

View File

@ -461,6 +461,86 @@ func (x *UserAddResResp) GetRes() *UserAssets {
return nil return nil
} }
// 玩家资源变更推送
type UserResChangePush struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Gold int32 `protobuf:"varint,1,opt,name=gold,proto3" json:"gold" bson:"gold"` //金币
Exp int32 `protobuf:"varint,2,opt,name=exp,proto3" json:"exp" bson:"exp"` //经验
Lv int32 `protobuf:"varint,3,opt,name=lv,proto3" json:"lv" bson:"lv"` //等级
Vip int32 `protobuf:"varint,4,opt,name=vip,proto3" json:"vip" bson:"vip"` // vip
Diamond int32 `protobuf:"varint,5,opt,name=diamond,proto3" json:"diamond" bson:"diamond"` // 钻石
}
func (x *UserResChangePush) Reset() {
*x = UserResChangePush{}
if protoimpl.UnsafeEnabled {
mi := &file_user_user_msg_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UserResChangePush) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UserResChangePush) ProtoMessage() {}
func (x *UserResChangePush) ProtoReflect() protoreflect.Message {
mi := &file_user_user_msg_proto_msgTypes[9]
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 UserResChangePush.ProtoReflect.Descriptor instead.
func (*UserResChangePush) Descriptor() ([]byte, []int) {
return file_user_user_msg_proto_rawDescGZIP(), []int{9}
}
func (x *UserResChangePush) GetGold() int32 {
if x != nil {
return x.Gold
}
return 0
}
func (x *UserResChangePush) GetExp() int32 {
if x != nil {
return x.Exp
}
return 0
}
func (x *UserResChangePush) GetLv() int32 {
if x != nil {
return x.Lv
}
return 0
}
func (x *UserResChangePush) GetVip() int32 {
if x != nil {
return x.Vip
}
return 0
}
func (x *UserResChangePush) GetDiamond() int32 {
if x != nil {
return x.Diamond
}
return 0
}
var File_user_user_msg_proto protoreflect.FileDescriptor var File_user_user_msg_proto protoreflect.FileDescriptor
var file_user_user_msg_proto_rawDesc = []byte{ var file_user_user_msg_proto_rawDesc = []byte{
@ -496,8 +576,16 @@ var file_user_user_msg_proto_rawDesc = []byte{
0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x03, 0x72, 0x65, 0x73, 0x22, 0x2f, 0x0a, 0x0e, 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x03, 0x72, 0x65, 0x73, 0x22, 0x2f, 0x0a, 0x0e,
0x55, 0x73, 0x65, 0x72, 0x41, 0x64, 0x64, 0x52, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x55, 0x73, 0x65, 0x72, 0x41, 0x64, 0x64, 0x52, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d,
0x0a, 0x03, 0x72, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x0a, 0x03, 0x72, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73,
0x65, 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x03, 0x72, 0x65, 0x73, 0x42, 0x06, 0x5a, 0x65, 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x03, 0x72, 0x65, 0x73, 0x22, 0x75, 0x0a,
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x11, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x75,
0x73, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x67, 0x6f, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
0x52, 0x04, 0x67, 0x6f, 0x6c, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x78, 0x70, 0x18, 0x02, 0x20,
0x01, 0x28, 0x05, 0x52, 0x03, 0x65, 0x78, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x03,
0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x69, 0x70, 0x18,
0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x76, 0x69, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x69,
0x61, 0x6d, 0x6f, 0x6e, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x64, 0x69, 0x61,
0x6d, 0x6f, 0x6e, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -512,28 +600,29 @@ func file_user_user_msg_proto_rawDescGZIP() []byte {
return file_user_user_msg_proto_rawDescData return file_user_user_msg_proto_rawDescData
} }
var file_user_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_user_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_user_user_msg_proto_goTypes = []interface{}{ var file_user_user_msg_proto_goTypes = []interface{}{
(*UserLoginReq)(nil), // 0: UserLoginReq (*UserLoginReq)(nil), // 0: UserLoginReq
(*UserLoginResp)(nil), // 1: UserLoginResp (*UserLoginResp)(nil), // 1: UserLoginResp
(*UserRegisterReq)(nil), // 2: UserRegisterReq (*UserRegisterReq)(nil), // 2: UserRegisterReq
(*UserRegisterResp)(nil), // 3: UserRegisterResp (*UserRegisterResp)(nil), // 3: UserRegisterResp
(*UserLoadResp)(nil), // 4: UserLoadResp (*UserLoadResp)(nil), // 4: UserLoadResp
(*UserCreateReq)(nil), // 5: UserCreateReq (*UserCreateReq)(nil), // 5: UserCreateReq
(*UserCreateResp)(nil), // 6: UserCreateResp (*UserCreateResp)(nil), // 6: UserCreateResp
(*UserAddResReq)(nil), // 7: UserAddResReq (*UserAddResReq)(nil), // 7: UserAddResReq
(*UserAddResResp)(nil), // 8: UserAddResResp (*UserAddResResp)(nil), // 8: UserAddResResp
(*DBUser)(nil), // 9: DBUser (*UserResChangePush)(nil), // 9: UserResChangePush
(ErrorCode)(0), // 10: ErrorCode (*DBUser)(nil), // 10: DBUser
(*CacheUser)(nil), // 11: CacheUser (ErrorCode)(0), // 11: ErrorCode
(*UserAssets)(nil), // 12: UserAssets (*CacheUser)(nil), // 12: CacheUser
(*UserAssets)(nil), // 13: UserAssets
} }
var file_user_user_msg_proto_depIdxs = []int32{ var file_user_user_msg_proto_depIdxs = []int32{
9, // 0: UserLoginResp.data:type_name -> DBUser 10, // 0: UserLoginResp.data:type_name -> DBUser
10, // 1: UserRegisterResp.Code:type_name -> ErrorCode 11, // 1: UserRegisterResp.Code:type_name -> ErrorCode
11, // 2: UserLoadResp.data:type_name -> CacheUser 12, // 2: UserLoadResp.data:type_name -> CacheUser
12, // 3: UserAddResReq.res:type_name -> UserAssets 13, // 3: UserAddResReq.res:type_name -> UserAssets
12, // 4: UserAddResResp.res:type_name -> UserAssets 13, // 4: UserAddResResp.res:type_name -> UserAssets
5, // [5:5] is the sub-list for method output_type 5, // [5:5] is the sub-list for method output_type
5, // [5:5] is the sub-list for method input_type 5, // [5:5] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name 5, // [5:5] is the sub-list for extension type_name
@ -658,6 +747,18 @@ func file_user_user_msg_proto_init() {
return nil return nil
} }
} }
file_user_user_msg_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UserResChangePush); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@ -665,7 +766,7 @@ func file_user_user_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_user_user_msg_proto_rawDesc, RawDescriptor: file_user_user_msg_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 9, NumMessages: 10,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

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))
} }