上传协议优化

This commit is contained in:
liwei1dao 2022-06-06 18:46:28 +08:00
parent 3e39b41446
commit c25df3e397
11 changed files with 468 additions and 127 deletions

View File

@ -96,7 +96,7 @@ func (r *Robot) AccountRegister() {
regRsp := &pb.UserRegisterRsp{}
err = jsoniter.Unmarshal(body, regRsp)
if regRsp.Code == comm.ErrorCode_Success { //注册成功
if regRsp.Code == int32(pb.ErrorCode_Success) { //注册成功
//登录
loginReg := &pb.UserLoginReq{
Name: regReq.Account,

View File

@ -1,36 +0,0 @@
package comm
///内置错误码 0-1000 请外部应用服务不要占用
const (
ErrorCode_Success int32 = 0 //成功
ErrorCode_NoFindService int32 = 10 //没有找到远程服务器
ErrorCode_RpcFuncExecutionError int32 = 11 //Rpc方法执行错误
ErrorCode_CacheReadError int32 = 12 //缓存读取失败
ErrorCode_SqlExecutionError int32 = 13 //数据库执行错误
ErrorCode_ReqParameterError int32 = 14 //请求参数错误
ErrorCode_SignError int32 = 15 //签名错误
ErrorCode_InsufficientPermissions int32 = 16 //权限不足
ErrorCode_NoLogin int32 = 17 //未登录
ErrorCode_UserSessionNobeing int32 = 18 //用户不存在
)
var ErrorCodeMsg = map[int32]string{
ErrorCode_Success: "成功",
ErrorCode_NoFindService: "没有找到远程服务器",
ErrorCode_RpcFuncExecutionError: "Rpc方法执行错误",
ErrorCode_CacheReadError: "缓存读取失败",
ErrorCode_SqlExecutionError: "数据库执行错误",
ErrorCode_ReqParameterError: "请求参数错误",
ErrorCode_SignError: "签名错误",
ErrorCode_InsufficientPermissions: "权限不足",
ErrorCode_NoLogin: "未登录",
ErrorCode_UserSessionNobeing: "用户不存在",
}
func GetErrorCodeMsg(code int32) string {
if v, ok := ErrorCodeMsg[code]; ok {
return v
} else {
return "未描述"
}
}

View File

@ -63,12 +63,13 @@ func (this *UserSession) UnBuild(ServiceMethod string, msg proto.Message) (err e
return
}
func (this *UserSession) SendMsg(ServiceMethod string, msg proto.Message) (err error) {
func (this *UserSession) SendMsg(ServiceMethod string, code pb.ErrorCode, msg proto.Message) (err error) {
reply := &pb.RPCMessageReply{}
data, _ := proto.Marshal(msg)
if err := this.service.RpcCallById(this.GatewayServiceId, string(Rpc_GatewayAgentSendMsg), context.Background(), &pb.AgentSendMessageReq{
UserSessionId: this.SessionId,
ServiceMethod: ServiceMethod,
Code: code,
Data: data,
}, reply); err != nil {
log.Errorf("UserSession:%s UserId:%d SendMsg:%s err:%v", this.SessionId, this.UserId, ServiceMethod, err)

View File

@ -2,7 +2,6 @@ package gateway
import (
"context"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"sync"
@ -32,8 +31,8 @@ func (this *AgentMgr_Comp) Build(ctx context.Context, args *pb.AgentBuildReq, re
if a, ok := this.agents.Load(args.UserSessionId); ok {
a.(IAgent).Build(args.UserId)
} else {
reply.Code = int32(comm.ErrorCode_UserSessionNobeing)
reply.Msg = comm.GetErrorCodeMsg(comm.ErrorCode_UserSessionNobeing)
reply.Code = pb.ErrorCode_UserSessionNobeing
reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
}
return nil
}
@ -43,8 +42,8 @@ func (this *AgentMgr_Comp) UnBuild(ctx context.Context, args *pb.AgentUnBuildReq
if a, ok := this.agents.Load(args.UserSessionId); ok {
a.(IAgent).UnBuild()
} else {
reply.Code = int32(comm.ErrorCode_UserSessionNobeing)
reply.Msg = comm.GetErrorCodeMsg(comm.ErrorCode_UserSessionNobeing)
reply.Code = pb.ErrorCode_UserSessionNobeing
reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
}
return nil
}
@ -57,8 +56,8 @@ func (this *AgentMgr_Comp) SendMsgToAgent(ctx context.Context, args *pb.AgentSen
Data: args.Data,
})
} else {
reply.Code = int32(comm.ErrorCode_UserSessionNobeing)
reply.Msg = comm.GetErrorCodeMsg(comm.ErrorCode_UserSessionNobeing)
reply.Code = pb.ErrorCode_UserSessionNobeing
reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
}
return nil
}
@ -95,8 +94,8 @@ func (this *AgentMgr_Comp) CloseAgent(ctx context.Context, args *pb.AgentCloseeR
if a, ok := this.agents.Load(args.UserSessionId); ok {
a.(IAgent).Close()
} else {
reply.Code = int32(comm.ErrorCode_UserSessionNobeing)
reply.Msg = comm.GetErrorCodeMsg(comm.ErrorCode_UserSessionNobeing)
reply.Code = pb.ErrorCode_UserSessionNobeing
reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
}
return nil
}

View File

@ -14,6 +14,10 @@ import (
const (
QueryUserPackReq = "pack.queryuserpackreq"
QueryUserPackResp = "pack.queryuserpackresp"
UseItemReq = "pack.useitemreq"
UseItemResp = "pack.useitemresp"
SellItemReq = "pack.sellitemreq"
SellItemResp = "pack.sellitemresp"
)
type Api_Comp struct {
@ -53,5 +57,37 @@ func (this *Api_Comp) QueryUserPackReq(ctx context.Context, session comm.IUserSe
}
}
}
return nil
return
}
//使用道具
func (this *Api_Comp) UseItemReq(ctx context.Context, session comm.IUserSession, req *pb.UseItemReq) (err error) {
var (
code pb.ErrorCode
)
defer func() {
session.SendMsg(UseItemResp, &pb.UseItemResp{Code: code})
}()
if session.GetUserId() == 0 {
code = pb.ErrorCode_NoLogin
return
}
return
}
//出售道具
func (this *Api_Comp) SellItemReq(ctx context.Context, session comm.IUserSession, req *pb.QueryUserPackReq) (err error) {
var (
code pb.ErrorCode
)
defer func() {
session.SendMsg(SellItemResp, &pb.SellItemResp{Code: code})
}()
if session.GetUserId() == 0 {
code = pb.ErrorCode_NoLogin
return
}
return
}

View File

@ -14,3 +14,7 @@ func (this *Configure_Comp) Init(service core.IService, module core.IModule, com
this.ModuleCompBase.Init(service, module, comp, options)
return
}
func (this *Configure_Comp) GetItemConfigureData(id uint32) {
}

View File

@ -170,8 +170,8 @@ type RPCMessageReply struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"`
Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"`
Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
}
func (x *RPCMessageReply) Reset() {
@ -206,11 +206,11 @@ func (*RPCMessageReply) Descriptor() ([]byte, []int) {
return file_comm_proto_rawDescGZIP(), []int{2}
}
func (x *RPCMessageReply) GetCode() int32 {
func (x *RPCMessageReply) GetCode() ErrorCode {
if x != nil {
return x.Code
}
return 0
return ErrorCode_Success
}
func (x *RPCMessageReply) GetMsg() string {
@ -330,9 +330,10 @@ type AgentSendMessageReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserSessionId string `protobuf:"bytes,1,opt,name=UserSessionId,proto3" json:"UserSessionId,omitempty"`
ServiceMethod string `protobuf:"bytes,2,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` //服务名
Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"`
UserSessionId string `protobuf:"bytes,1,opt,name=UserSessionId,proto3" json:"UserSessionId,omitempty"`
ServiceMethod string `protobuf:"bytes,2,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` //服务名
Code ErrorCode `protobuf:"varint,3,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"`
Data []byte `protobuf:"bytes,4,opt,name=Data,proto3" json:"Data,omitempty"`
}
func (x *AgentSendMessageReq) Reset() {
@ -381,6 +382,13 @@ func (x *AgentSendMessageReq) GetServiceMethod() string {
return ""
}
func (x *AgentSendMessageReq) GetCode() ErrorCode {
if x != nil {
return x.Code
}
return ErrorCode_Success
}
func (x *AgentSendMessageReq) GetData() []byte {
if x != nil {
return x.Data
@ -559,60 +567,64 @@ func (x *AgentCloseeReq) GetUserSessionId() string {
var File_comm_proto protoreflect.FileDescriptor
var file_comm_proto_rawDesc = []byte{
0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x47, 0x0a, 0x0b,
0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x53,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f,
0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52,
0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0xba, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x4d,
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65,
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55,
0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06,
0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x73,
0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10,
0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64,
0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73,
0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x22, 0x37, 0x0a, 0x0f, 0x52, 0x50, 0x43, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x22, 0x4d, 0x0a, 0x0d, 0x41,
0x67, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d,
0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01,
0x28, 0x0d, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x0f, 0x41, 0x67,
0x65, 0x6e, 0x74, 0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a,
0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f,
0x6e, 0x49, 0x64, 0x22, 0x75, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64,
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73,
0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x65, 0x72,
0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x47, 0x0a,
0x0b, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68,
0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c,
0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0xba, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74,
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53,
0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d,
0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a,
0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55,
0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49,
0x64, 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28,
0x09, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73,
0x73, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73,
0x61, 0x67, 0x65, 0x22, 0x43, 0x0a, 0x0f, 0x52, 0x50, 0x43, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65,
0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x22, 0x4d, 0x0a, 0x0d, 0x41, 0x67, 0x65, 0x6e,
0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65,
0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12,
0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52,
0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x0f, 0x41, 0x67, 0x65, 0x6e, 0x74,
0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73,
0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64,
0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f,
0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03,
0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x73, 0x0a, 0x0f, 0x42, 0x61,
0x74, 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a,
0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x18,
0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69,
0x6f, 0x6e, 0x49, 0x64, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44,
0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22,
0x4f, 0x0a, 0x13, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73,
0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04,
0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61,
0x22, 0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x65, 0x52,
0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f,
0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53,
0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x22, 0x95, 0x01, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65,
0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72,
0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x24,
0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65,
0x74, 0x68, 0x6f, 0x64, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01,
0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04,
0x43, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01,
0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x73, 0x0a, 0x0f, 0x42, 0x61, 0x74, 0x63,
0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, 0x0e, 0x55,
0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x18, 0x01, 0x20,
0x03, 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
0x49, 0x64, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65,
0x74, 0x68, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74,
0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x4f, 0x0a,
0x13, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d,
0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61,
0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x36,
0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x65, 0x52, 0x65, 0x71,
0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73,
0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -638,13 +650,16 @@ var file_comm_proto_goTypes = []interface{}{
(*BatchMessageReq)(nil), // 6: BatchMessageReq
(*BroadCastMessageReq)(nil), // 7: BroadCastMessageReq
(*AgentCloseeReq)(nil), // 8: AgentCloseeReq
(ErrorCode)(0), // 9: ErrorCode
}
var file_comm_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
9, // 0: RPCMessageReply.Code:type_name -> ErrorCode
9, // 1: AgentSendMessageReq.Code:type_name -> ErrorCode
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_comm_proto_init() }
@ -652,6 +667,7 @@ func file_comm_proto_init() {
if File_comm_proto != nil {
return
}
file_errorcode_proto_init()
if !protoimpl.UnsafeEnabled {
file_comm_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UserMessage); i {

View File

@ -188,6 +188,214 @@ func (x *QueryUserPackResp) GetItems() []*ItemAmount {
return nil
}
//使用物品请求
type UseItemReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ItemId uint32 `protobuf:"varint,2,opt,name=ItemId,proto3" json:"ItemId,omitempty"`
Amount uint32 `protobuf:"varint,3,opt,name=Amount,proto3" json:"Amount,omitempty"`
}
func (x *UseItemReq) Reset() {
*x = UseItemReq{}
if protoimpl.UnsafeEnabled {
mi := &file_pack_msg_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UseItemReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UseItemReq) ProtoMessage() {}
func (x *UseItemReq) ProtoReflect() protoreflect.Message {
mi := &file_pack_msg_proto_msgTypes[3]
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 UseItemReq.ProtoReflect.Descriptor instead.
func (*UseItemReq) Descriptor() ([]byte, []int) {
return file_pack_msg_proto_rawDescGZIP(), []int{3}
}
func (x *UseItemReq) GetItemId() uint32 {
if x != nil {
return x.ItemId
}
return 0
}
func (x *UseItemReq) GetAmount() uint32 {
if x != nil {
return x.Amount
}
return 0
}
//使用物品请求 回应
type UseItemResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"`
}
func (x *UseItemResp) Reset() {
*x = UseItemResp{}
if protoimpl.UnsafeEnabled {
mi := &file_pack_msg_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UseItemResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UseItemResp) ProtoMessage() {}
func (x *UseItemResp) ProtoReflect() protoreflect.Message {
mi := &file_pack_msg_proto_msgTypes[4]
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 UseItemResp.ProtoReflect.Descriptor instead.
func (*UseItemResp) Descriptor() ([]byte, []int) {
return file_pack_msg_proto_rawDescGZIP(), []int{4}
}
func (x *UseItemResp) GetCode() ErrorCode {
if x != nil {
return x.Code
}
return ErrorCode_Success
}
//出售道具请求
type SellItemReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ItemId uint32 `protobuf:"varint,2,opt,name=ItemId,proto3" json:"ItemId,omitempty"`
Amount uint32 `protobuf:"varint,3,opt,name=Amount,proto3" json:"Amount,omitempty"`
}
func (x *SellItemReq) Reset() {
*x = SellItemReq{}
if protoimpl.UnsafeEnabled {
mi := &file_pack_msg_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SellItemReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SellItemReq) ProtoMessage() {}
func (x *SellItemReq) ProtoReflect() protoreflect.Message {
mi := &file_pack_msg_proto_msgTypes[5]
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 SellItemReq.ProtoReflect.Descriptor instead.
func (*SellItemReq) Descriptor() ([]byte, []int) {
return file_pack_msg_proto_rawDescGZIP(), []int{5}
}
func (x *SellItemReq) GetItemId() uint32 {
if x != nil {
return x.ItemId
}
return 0
}
func (x *SellItemReq) GetAmount() uint32 {
if x != nil {
return x.Amount
}
return 0
}
//出售道具请求 回应
type SellItemResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"`
}
func (x *SellItemResp) Reset() {
*x = SellItemResp{}
if protoimpl.UnsafeEnabled {
mi := &file_pack_msg_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SellItemResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SellItemResp) ProtoMessage() {}
func (x *SellItemResp) ProtoReflect() protoreflect.Message {
mi := &file_pack_msg_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SellItemResp.ProtoReflect.Descriptor instead.
func (*SellItemResp) Descriptor() ([]byte, []int) {
return file_pack_msg_proto_rawDescGZIP(), []int{6}
}
func (x *SellItemResp) GetCode() ErrorCode {
if x != nil {
return x.Code
}
return ErrorCode_Success
}
var File_pack_msg_proto protoreflect.FileDescriptor
var file_pack_msg_proto_rawDesc = []byte{
@ -208,8 +416,21 @@ var file_pack_msg_proto_rawDesc = []byte{
0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x21,
0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e,
0x49, 0x74, 0x65, 0x6d, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d,
0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
0x73, 0x22, 0x3c, 0x0a, 0x0a, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x12,
0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52,
0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e,
0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22,
0x2d, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e,
0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45,
0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x3d,
0x0a, 0x0b, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a,
0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x49,
0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18,
0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2e, 0x0a,
0x0c, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a,
0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72,
0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x42, 0x06, 0x5a,
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -224,23 +445,29 @@ func file_pack_msg_proto_rawDescGZIP() []byte {
return file_pack_msg_proto_rawDescData
}
var file_pack_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_pack_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_pack_msg_proto_goTypes = []interface{}{
(*ItemAmount)(nil), // 0: ItemAmount
(*QueryUserPackReq)(nil), // 1: QueryUserPackReq
(*QueryUserPackResp)(nil), // 2: QueryUserPackResp
(ItemType)(0), // 3: ItemType
(ErrorCode)(0), // 4: ErrorCode
(*UseItemReq)(nil), // 3: UseItemReq
(*UseItemResp)(nil), // 4: UseItemResp
(*SellItemReq)(nil), // 5: SellItemReq
(*SellItemResp)(nil), // 6: SellItemResp
(ItemType)(0), // 7: ItemType
(ErrorCode)(0), // 8: ErrorCode
}
var file_pack_msg_proto_depIdxs = []int32{
3, // 0: QueryUserPackReq.IType:type_name -> ItemType
4, // 1: QueryUserPackResp.Code:type_name -> ErrorCode
7, // 0: QueryUserPackReq.IType:type_name -> ItemType
8, // 1: QueryUserPackResp.Code:type_name -> ErrorCode
0, // 2: QueryUserPackResp.Items:type_name -> ItemAmount
3, // [3:3] is the sub-list for method output_type
3, // [3:3] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
8, // 3: UseItemResp.Code:type_name -> ErrorCode
8, // 4: SellItemResp.Code:type_name -> ErrorCode
5, // [5:5] is the sub-list for method output_type
5, // [5:5] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
}
func init() { file_pack_msg_proto_init() }
@ -287,6 +514,54 @@ func file_pack_msg_proto_init() {
return nil
}
}
file_pack_msg_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UseItemReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_pack_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UseItemResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_pack_msg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SellItemReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_pack_msg_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SellItemResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -294,7 +569,7 @@ func file_pack_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_pack_msg_proto_rawDesc,
NumEnums: 0,
NumMessages: 3,
NumMessages: 7,
NumExtensions: 0,
NumServices: 0,
},

View File

@ -1,5 +1,6 @@
syntax = "proto3";
option go_package = ".;pb";
import "errorcode.proto";
//
message UserMessage {
@ -19,7 +20,7 @@ message AgentMessage {
//RPC
message RPCMessageReply {
int32 Code = 1;
ErrorCode Code = 1;
string Msg = 2;
}
@ -37,7 +38,8 @@ message AgentUnBuildReq {
message AgentSendMessageReq {
string UserSessionId = 1;
string ServiceMethod = 2; //
bytes Data = 3;
ErrorCode Code = 3;
bytes Data = 4;
}
//

View File

@ -20,3 +20,25 @@ message QueryUserPackResp {
ErrorCode Code = 1;
repeated ItemAmount Items = 2;
}
//使
message UseItemReq {
uint32 ItemId = 2;
uint32 Amount = 3;
}
//使
message UseItemResp {
ErrorCode Code = 1;
}
//
message SellItemReq {
uint32 ItemId = 2;
uint32 Amount = 3;
}
//
message SellItemResp {
ErrorCode Code = 1;
}

22
pb/unitls.go Normal file
View File

@ -0,0 +1,22 @@
package pb
var ErrorCodeMsg = map[ErrorCode]string{
ErrorCode_Success: "成功",
ErrorCode_NoFindService: "没有找到远程服务器",
ErrorCode_RpcFuncExecutionError: "Rpc方法执行错误",
ErrorCode_CacheReadError: "缓存读取失败",
ErrorCode_SqlExecutionError: "数据库执行错误",
ErrorCode_ReqParameterError: "请求参数错误",
ErrorCode_SignError: "签名错误",
ErrorCode_InsufficientPermissions: "权限不足",
ErrorCode_NoLogin: "未登录",
ErrorCode_UserSessionNobeing: "用户不存在",
}
func GetErrorCodeMsg(code ErrorCode) string {
if v, ok := ErrorCodeMsg[code]; ok {
return v
} else {
return "未描述"
}
}