Compare commits

...

3 Commits

Author SHA1 Message Date
zhaocy
13ef42edcc Merge branch 'zhaocy' into dev
# Conflicts:
#	comm/core.go
2022-06-06 18:45:22 +08:00
zhaocy
e8c9f63901 update Robot 2022-06-06 18:42:03 +08:00
zhaocy
5b7d9f8cea Merge remote-tracking branch 'origin/liwei' into zhaocy 2022-06-06 14:44:34 +08:00
20 changed files with 378 additions and 163 deletions

View File

@ -43,10 +43,8 @@ var runCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
opts := robot.DefaultOpts()
opts.Create = *create
if *create {
opts.Account = *account
}
opts.Create = *create
opts.Account = *account
r := robot.NewRobot(opts)
r.Run()

View File

@ -1,38 +1,49 @@
package robot
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"log"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
)
func (r *Robot) handleLogin(methodName string) {
switch methodName {
func (r *Robot) handleLogin(msg *pb.UserMessage) {
switch msg.SubType {
case "login":
handleLogin(r)
handleLogin(r, msg)
default:
log.Fatal("methodName no exist")
}
}
func handleLogin(r *Robot) {
loginreq := &pb.UserLoginReq{
Name: "aaa",
//处理接口响应数据
func handleLogin(r *Robot, msg *pb.UserMessage) {
rsp := &pb.UserLoginResp{}
if !comm.ProtoDecode(msg, rsp) {
return
}
logindata, _ := proto.Marshal(loginreq)
head := &pb.UserMessage{
ServiceMethod: "login.login",
Data: logindata,
log.Printf("to client: %v", rsp.Data)
}
//处理登录请求
func (r *Robot) AccountLogin() {
//登录
loginReg := &pb.UserLoginReq{
Name: r.Opts.Account,
}
if comm.ProtoEncode(loginreq, head) {
err := r.SendToClient(head.Data)
head := &pb.UserMessage{
MainType: "login",
SubType: "login",
}
if comm.ProtoEncode(loginReg, head) {
data, _ := proto.Marshal(head)
err := r.SendToClient(data)
if err != nil {
fmt.Printf("err:%v\n", err)
log.Fatal(err)
}
}
log.Printf("%s login ", r.Opts.Account)
}

12
cmd/robot/readme.md Normal file
View File

@ -0,0 +1,12 @@
# Robot使用
## 命令行
```sh
#使用已存在的账号测试接口
go run cmd.go run --account yourAccount
```
```sh
#使用新账号测试接口
go run cmd.go run --account newAccount --create true
```

View File

@ -5,7 +5,6 @@ import (
"encoding/json"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/utils"
"io/ioutil"
"log"
"net/http"
@ -44,33 +43,40 @@ func (r *Robot) Run() {
r.AccountLogin()
}
for {
var msg *pb.UserMessage = &pb.UserMessage{}
_, data, err := r.ws.ReadMessage()
if err != nil {
log.Fatal(err)
}
//处理响应
go func() {
for {
var msg *pb.UserMessage = &pb.UserMessage{}
_, data, err := r.ws.ReadMessage()
if err != nil {
log.Println(err)
}
if err = proto.Unmarshal(data, msg); err != nil {
log.Fatal(err)
if err = proto.Unmarshal(data, msg); err != nil {
log.Fatal(err)
}
r.handleMsg(msg)
}
r.handleMsg(msg)
}
}()
select {}
}
func (r *Robot) handleMsg(msg *pb.UserMessage) {
m, f, ok := utils.ParseP(msg.ServiceMethod)
if !ok {
log.Fatal("route error")
}
switch m {
switch msg.MainType {
case "login":
r.handleLogin(f)
r.handleLogin(msg)
case "user":
r.handleUserMsg(msg)
default:
log.Fatal("module route no exist")
}
}
func (r *Robot) onUserLoaded() {
}
func (r *Robot) SendToClient(data []byte) error {
return r.ws.WriteMessage(websocket.BinaryMessage, data)
}
@ -103,7 +109,8 @@ func (r *Robot) AccountRegister() {
}
head := &pb.UserMessage{
ServiceMethod: "login.login",
MainType: "login",
SubType: "login",
}
if comm.ProtoEncode(loginReg, head) {
err = r.SendToClient(head.Data)
@ -113,23 +120,4 @@ func (r *Robot) AccountRegister() {
}
}
}
//登录认证
func (r *Robot) AccountLogin() {
//登录
loginReg := &pb.UserLoginReq{
Name: r.Opts.Account,
}
head := &pb.UserMessage{
ServiceMethod: "login.login",
}
if comm.ProtoEncode(loginReg, head) {
err := r.SendToClient(head.Data)
if err != nil {
log.Fatal(err)
}
}
}

View File

@ -1 +1,39 @@
package robot
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"github.com/liwei1dao/lego/sys/log"
)
func (r *Robot) handleUserMsg(msg *pb.UserMessage) {
switch msg.SubType {
//创建账号
case "create":
case "load":
}
//加载玩家数据
if msg.SubType == "load" {
rsp := &pb.UserLoadRsp{}
if !comm.ProtoDecode(msg, rsp) {
log.Fatal("load user err")
}
if rsp.Data.UserData.UserId != 0 {
r.onUserLoaded()
} else {
log.Debugf("%s不存在", r.Opts.Account)
//创建
}
}
}
func (r *Robot) CreateUser() {
}

View File

@ -16,7 +16,7 @@ const (
const (
SM_GateModule core.M_Modules = "gateway" //gate模块 网关服务模块
SM_WebModule core.M_Modules = "web" //web模块
SM_LoginModule core.M_Modules = "login" //web模块
SM_LoginModule core.M_Modules = "user" //用户模块
SM_PackModule core.M_Modules = "pack" //背包模块
)
@ -43,7 +43,7 @@ type IUserSession interface {
GetGatewayServiceId() string
Build(uid uint32) (err error)
UnBuild(ServiceMethod string, msg proto.Message) (err error)
SendMsg(ServiceMethod string, msg proto.Message) (err error)
SendMsg(mainType, subType string, msg proto.Message) (err error)
Close() (err error)
ToString() string
}
@ -62,7 +62,7 @@ type Message struct {
func ProtoDecode(msg *pb.UserMessage, req proto.Message) (ok bool) {
err := proto.Unmarshal(msg.Data, req)
if err != nil {
log.Errorf("%s %v", msg.ServiceMethod, err)
log.Errorf("%s.%s %v", msg.MainType, msg.SubType, err)
return
}
return true
@ -71,7 +71,7 @@ func ProtoDecode(msg *pb.UserMessage, req proto.Message) (ok bool) {
func ProtoEncode(rsp proto.Message, msg *pb.UserMessage) (ok bool) {
data, err := proto.Marshal(rsp)
if err != nil {
log.Errorf("%s %v", msg.ServiceMethod, err)
log.Errorf("%s.%s %v", msg.MainType, msg.SubType, err)
return
}
msg.Data = data

View File

@ -63,15 +63,17 @@ 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(mainType, subType string, msg proto.Message) (err error) {
reply := &pb.RPCMessageReply{}
data, _ := proto.Marshal(msg)
log.Debugf("SendMsg Data: %v", msg)
if err := this.service.RpcCallById(this.GatewayServiceId, string(Rpc_GatewayAgentSendMsg), context.Background(), &pb.AgentSendMessageReq{
UserSessionId: this.SessionId,
ServiceMethod: ServiceMethod,
MainType: mainType,
SubType: subType,
Data: data,
}, reply); err != nil {
log.Errorf("UserSession:%s UserId:%d SendMsg:%s err:%v", this.SessionId, this.UserId, ServiceMethod, err)
log.Errorf("UserSession:%s UserId:%d SendMsg:%s err:%v", this.SessionId, this.UserId, mainType, err)
}
return
}

View File

@ -10,7 +10,7 @@ import (
type (
IModule interface {
core.IModule
SendMsgToUser(ServiceMethod string, msg proto.Message, user *pb.Cache_UserData) (err error)
SendMsgToUsers(ServiceMethod string, msg proto.Message, user ...*pb.Cache_UserData) (err error)
SendMsgToUser(mainType, subType string, msg proto.Message, user *pb.Cache_UserData) (err error)
SendMsgToUsers(mainType, subType string, msg proto.Message, user ...*pb.Cache_UserData) (err error)
}
)

View File

@ -2,6 +2,7 @@ package gateway
import (
"context"
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"sync"
@ -134,13 +135,13 @@ func (this *Agent) Close() {
//分发用户消息
func (this *Agent) messageDistribution(msg *pb.UserMessage) {
reply := &pb.RPCMessageReply{}
log.Debugf("agent:%s uId:%d MessageDistribution msg:%s", this.sessionId, this.uId, msg.ServiceMethod)
log.Debugf("agent:%s uId:%d MessageDistribution msg:%s.%s", this.sessionId, this.uId, msg.MainType, msg.SubType)
if err := this.gateway.Service().RpcCallByType("worker", string(comm.Rpc_GatewayRoute), context.Background(), &pb.AgentMessage{
Ip: this.IP(),
UserSessionId: this.sessionId,
UserId: this.uId,
GatewayServiceId: this.gateway.Service().GetId(),
Method: msg.ServiceMethod,
Method: fmt.Sprintf("%s.%s", msg.MainType, msg.SubType),
Message: msg.Data,
}, reply); err != nil {
log.Errorf("agent:%s uId:%d MessageDistribution err:%v", this.sessionId, this.uId, err)

View File

@ -53,8 +53,9 @@ func (this *AgentMgr_Comp) UnBuild(ctx context.Context, args *pb.AgentUnBuildReq
func (this *AgentMgr_Comp) SendMsgToAgent(ctx context.Context, args *pb.AgentSendMessageReq, reply *pb.RPCMessageReply) error {
if a, ok := this.agents.Load(args.UserSessionId); ok {
a.(IAgent).WriteMsg(&pb.UserMessage{
ServiceMethod: args.ServiceMethod,
Data: args.Data,
MainType: args.MainType,
SubType: args.SubType,
Data: args.Data,
})
} else {
reply.Code = int32(comm.ErrorCode_UserSessionNobeing)
@ -66,8 +67,9 @@ func (this *AgentMgr_Comp) SendMsgToAgent(ctx context.Context, args *pb.AgentSen
//向多个户发送消息
func (this *AgentMgr_Comp) SendMsgToAgents(ctx context.Context, args *pb.BatchMessageReq, reply *pb.RPCMessageReply) error {
msg := &pb.UserMessage{
ServiceMethod: args.ServiceMethod,
Data: args.Data,
MainType: args.MainType,
SubType: args.SubType,
Data: args.Data,
}
for _, v := range args.UserSessionIds {
if a, ok := this.agents.Load(v); ok {
@ -80,8 +82,9 @@ func (this *AgentMgr_Comp) SendMsgToAgents(ctx context.Context, args *pb.BatchMe
//向所有户发送消息
func (this *AgentMgr_Comp) SendMsgToAllAgent(ctx context.Context, args *pb.BroadCastMessageReq, reply *pb.RPCMessageReply) error {
msg := &pb.UserMessage{
ServiceMethod: args.ServiceMethod,
Data: args.Data,
MainType: args.MainType,
SubType: args.SubType,
Data: args.Data,
}
this.agents.Range(func(key, value any) bool {
value.(IAgent).WriteMsg(msg)

View File

@ -40,8 +40,9 @@ func Test_WebSocket(t *testing.T) {
}
logindata, _ := proto.Marshal(loginreq)
message := &pb.UserMessage{
ServiceMethod: "login.login",
Data: logindata,
MainType: "login",
SubType: "login",
Data: logindata,
}
data, _ := proto.Marshal(message)
err = ws.WriteMessage(websocket.BinaryMessage, data)

View File

@ -23,20 +23,21 @@ func (this *ModuleBase) Init(service core.IService, module core.IModule, options
return
}
func (this *ModuleBase) SendMsgToUser(ServiceMethod string, msg proto.Message, user *pb.Cache_UserData) (err error) {
func (this *ModuleBase) SendMsgToUser(mainType, subType string, msg proto.Message, user *pb.Cache_UserData) (err error) {
reply := &pb.RPCMessageReply{}
data, _ := proto.Marshal(msg)
if _, err = this.service.RpcGoById(user.GatewayServiceId, string(comm.Rpc_GatewayAgentSendMsg), context.Background(), &pb.AgentSendMessageReq{
UserSessionId: user.SessionId,
ServiceMethod: ServiceMethod,
MainType: mainType,
SubType: subType,
Data: data,
}, reply); err != nil {
log.Errorf("SendMsgToUser%d:%s [%s] err:%v", user.UserData.UserId, user.SessionId, ServiceMethod, err)
log.Errorf("SendMsgToUser%d:%s [%s.%s] err:%v", user.UserData.UserId, user.SessionId, mainType, subType, err)
}
return
}
func (this *ModuleBase) SendMsgToUsers(ServiceMethod string, msg proto.Message, user ...*pb.Cache_UserData) (err error) {
func (this *ModuleBase) SendMsgToUsers(mainType, subType string, msg proto.Message, user ...*pb.Cache_UserData) (err error) {
var (
gateways map[string][]string = make(map[string][]string)
gateway []string
@ -54,10 +55,11 @@ func (this *ModuleBase) SendMsgToUsers(ServiceMethod string, msg proto.Message,
for k, v := range gateways {
if _, err = this.service.RpcGoById(k, string(comm.Rpc_GatewayAgentSendMsg), context.Background(), &pb.BatchMessageReq{
UserSessionIds: v,
ServiceMethod: ServiceMethod,
MainType: mainType,
SubType: subType,
Data: data,
}, reply); err != nil {
log.Errorf("SendMsgToUsers:%s->%s err:%v", k, ServiceMethod, err)
log.Errorf("SendMsgToUsers:%s->%s.%s err:%v", k, mainType, subType, err)
}
}
return

View File

@ -1,4 +1,4 @@
package login
package user
import (
"context"
@ -47,13 +47,19 @@ func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req
return err
}
session.SendMsg("loginRsp", &pb.UserLoginResp{
session.SendMsg("login", "login", &pb.UserLoginResp{
Code: comm.ErrorCode_Success,
Data: &pb.Cache_UserData{
UserData: &pb.DB_UserData{
UserId: db_user.UserId,
},
},
})
return nil
}
//注销
func (this *LoginComp) Logout(ctx context.Context, session comm.IUserSession, rsp *pb.UserLoginReq) error {
log.Debugf("User - Logout: session:%v rsp:%v", session.ToString(), rsp)

View File

@ -1,4 +1,4 @@
package login
package user
import (
"go_dreamfactory/comm"
@ -8,20 +8,20 @@ import (
)
func NewModule() core.IModule {
m := new(Login)
m := new(User)
return m
}
type Login struct {
type User struct {
modules.ModuleBase
user_comp *LoginComp
login_comp *LoginComp
}
func (this *Login) GetType() core.M_Modules {
func (this *User) GetType() core.M_Modules {
return comm.SM_LoginModule
}
func (this *Login) OnInstallComp() {
func (this *User) OnInstallComp() {
this.ModuleBase.OnInstallComp()
this.user_comp = this.RegisterComp(new(LoginComp)).(*LoginComp)
this.login_comp = this.RegisterComp(new(LoginComp)).(*LoginComp)
}

17
modules/user/user_comp.go Normal file
View File

@ -0,0 +1,17 @@
package user
import (
"context"
"go_dreamfactory/comm"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
)
type UserComp struct {
modules.MComp_GateComp
}
//创角
func (this *UserComp) CreateUser(ctx context.Context, session comm.IUserSession, req *pb.UserLoginReq) error {
return nil
}

View File

@ -16,6 +16,7 @@ import (
type Api_Comp struct {
cbase.ModuleCompBase
options *Options
module *Web
gin gin.ISys
}

View File

@ -26,8 +26,9 @@ type UserMessage struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ServiceMethod string `protobuf:"bytes,1,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` //服务名
Data []byte `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,omitempty"`
MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType,omitempty"`
SubType string `protobuf:"bytes,2,opt,name=SubType,proto3" json:"SubType,omitempty"`
Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"`
}
func (x *UserMessage) Reset() {
@ -62,9 +63,16 @@ func (*UserMessage) Descriptor() ([]byte, []int) {
return file_comm_proto_rawDescGZIP(), []int{0}
}
func (x *UserMessage) GetServiceMethod() string {
func (x *UserMessage) GetMainType() string {
if x != nil {
return x.ServiceMethod
return x.MainType
}
return ""
}
func (x *UserMessage) GetSubType() string {
if x != nil {
return x.SubType
}
return ""
}
@ -331,8 +339,9 @@ type AgentSendMessageReq struct {
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"`
MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType,omitempty"`
SubType string `protobuf:"bytes,3,opt,name=SubType,proto3" json:"SubType,omitempty"`
Data []byte `protobuf:"bytes,4,opt,name=Data,proto3" json:"Data,omitempty"`
}
func (x *AgentSendMessageReq) Reset() {
@ -374,9 +383,16 @@ func (x *AgentSendMessageReq) GetUserSessionId() string {
return ""
}
func (x *AgentSendMessageReq) GetServiceMethod() string {
func (x *AgentSendMessageReq) GetMainType() string {
if x != nil {
return x.ServiceMethod
return x.MainType
}
return ""
}
func (x *AgentSendMessageReq) GetSubType() string {
if x != nil {
return x.SubType
}
return ""
}
@ -395,8 +411,9 @@ type BatchMessageReq struct {
unknownFields protoimpl.UnknownFields
UserSessionIds []string `protobuf:"bytes,1,rep,name=UserSessionIds,proto3" json:"UserSessionIds,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"`
MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType,omitempty"`
SubType string `protobuf:"bytes,3,opt,name=SubType,proto3" json:"SubType,omitempty"`
Data []byte `protobuf:"bytes,4,opt,name=Data,proto3" json:"Data,omitempty"`
}
func (x *BatchMessageReq) Reset() {
@ -438,9 +455,16 @@ func (x *BatchMessageReq) GetUserSessionIds() []string {
return nil
}
func (x *BatchMessageReq) GetServiceMethod() string {
func (x *BatchMessageReq) GetMainType() string {
if x != nil {
return x.ServiceMethod
return x.MainType
}
return ""
}
func (x *BatchMessageReq) GetSubType() string {
if x != nil {
return x.SubType
}
return ""
}
@ -458,8 +482,9 @@ type BroadCastMessageReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ServiceMethod string `protobuf:"bytes,1,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` //服务名
Data []byte `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,omitempty"`
MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType,omitempty"` //服务名
SubType string `protobuf:"bytes,2,opt,name=SubType,proto3" json:"SubType,omitempty"`
Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"`
}
func (x *BroadCastMessageReq) Reset() {
@ -494,9 +519,16 @@ func (*BroadCastMessageReq) Descriptor() ([]byte, []int) {
return file_comm_proto_rawDescGZIP(), []int{7}
}
func (x *BroadCastMessageReq) GetServiceMethod() string {
func (x *BroadCastMessageReq) GetMainType() string {
if x != nil {
return x.ServiceMethod
return x.MainType
}
return ""
}
func (x *BroadCastMessageReq) GetSubType() string {
if x != nil {
return x.SubType
}
return ""
}
@ -559,11 +591,12 @@ 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,
0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x57, 0x0a, 0x0b,
0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x4d,
0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d,
0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79,
0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70,
0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 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,
@ -588,31 +621,34 @@ var file_comm_proto_rawDesc = []byte{
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,
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,
0x6e, 0x49, 0x64, 0x22, 0x85, 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, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a,
0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18,
0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x83, 0x01, 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, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54,
0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54,
0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a,
0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74,
0x61, 0x22, 0x5f, 0x0a, 0x13, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, 0x65,
0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e,
0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e,
0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12,
0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 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 (

View File

@ -3,8 +3,9 @@ option go_package = ".;pb";
//
message UserMessage {
string ServiceMethod =1; //
bytes Data = 2;
string MainType =1;
string SubType = 2;
bytes Data = 3;
}
//
@ -36,21 +37,24 @@ message AgentUnBuildReq {
//
message AgentSendMessageReq {
string UserSessionId = 1;
string ServiceMethod = 2; //
bytes Data = 3;
string MainType = 2;
string SubType = 3;
bytes Data = 4;
}
//
message BatchMessageReq {
repeated string UserSessionIds = 1;
string ServiceMethod = 2;
bytes Data = 3;
string MainType = 2;
string SubType = 3;
bytes Data = 4;
}
//广
message BroadCastMessageReq {
string ServiceMethod = 1; //
bytes Data = 2;
string MainType = 1; //
string SubType = 2;
bytes Data = 3;
}
//

View File

@ -1,12 +1,15 @@
syntax = "proto3";
option go_package = ".;pb";
import "user_db.proto";
message UserLoginReq {
string Name = 1;
}
message UserLoginResp {
int32 Code = 1;
Cache_UserData data = 2;
}
@ -16,4 +19,17 @@ message UserRegisterReq{
message UserRegisterRsp{
int32 Code = 1;
}
message UserLoadRsp {
Cache_UserData data = 1;
}
message UserCreateReq{
string NickName = 1;//
int32 gender = 2; //
}
message UserCreateRsp{
}

View File

@ -72,7 +72,8 @@ type UserLoginResp struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"`
Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"`
Data *Cache_UserData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *UserLoginResp) Reset() {
@ -114,6 +115,13 @@ func (x *UserLoginResp) GetCode() int32 {
return 0
}
func (x *UserLoginResp) GetData() *Cache_UserData {
if x != nil {
return x.Data
}
return nil
}
type UserRegisterReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -208,21 +216,75 @@ func (x *UserRegisterRsp) GetCode() int32 {
return 0
}
type UserLoadRsp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data *Cache_UserData `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *UserLoadRsp) Reset() {
*x = UserLoadRsp{}
if protoimpl.UnsafeEnabled {
mi := &file_user_msg_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UserLoadRsp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UserLoadRsp) ProtoMessage() {}
func (x *UserLoadRsp) ProtoReflect() protoreflect.Message {
mi := &file_user_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 UserLoadRsp.ProtoReflect.Descriptor instead.
func (*UserLoadRsp) Descriptor() ([]byte, []int) {
return file_user_msg_proto_rawDescGZIP(), []int{4}
}
func (x *UserLoadRsp) GetData() *Cache_UserData {
if x != nil {
return x.Data
}
return nil
}
var File_user_msg_proto protoreflect.FileDescriptor
var file_user_msg_proto_rawDesc = []byte{
0x0a, 0x0e, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x22, 0x22, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71,
0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x4e, 0x61, 0x6d, 0x65, 0x22, 0x23, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69,
0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x2b, 0x0a, 0x0f, 0x55, 0x73, 0x65,
0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07,
0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61,
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x25, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65,
0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x42, 0x06, 0x5a,
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x1a, 0x0d, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
0x22, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x12,
0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e,
0x61, 0x6d, 0x65, 0x22, 0x48, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e,
0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01,
0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61,
0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55,
0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a,
0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71,
0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x25, 0x0a, 0x0f, 0x55, 0x73,
0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x70, 0x12, 0x12, 0x0a,
0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64,
0x65, 0x22, 0x32, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x73, 0x70,
0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f,
0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52,
0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -237,19 +299,23 @@ func file_user_msg_proto_rawDescGZIP() []byte {
return file_user_msg_proto_rawDescData
}
var file_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_user_msg_proto_goTypes = []interface{}{
(*UserLoginReq)(nil), // 0: UserLoginReq
(*UserLoginResp)(nil), // 1: UserLoginResp
(*UserRegisterReq)(nil), // 2: UserRegisterReq
(*UserRegisterRsp)(nil), // 3: UserRegisterRsp
(*UserLoadRsp)(nil), // 4: UserLoadRsp
(*Cache_UserData)(nil), // 5: Cache_UserData
}
var file_user_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
5, // 0: UserLoginResp.data:type_name -> Cache_UserData
5, // 1: UserLoadRsp.data:type_name -> Cache_UserData
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_user_msg_proto_init() }
@ -257,6 +323,7 @@ func file_user_msg_proto_init() {
if File_user_msg_proto != nil {
return
}
file_user_db_proto_init()
if !protoimpl.UnsafeEnabled {
file_user_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UserLoginReq); i {
@ -306,6 +373,18 @@ func file_user_msg_proto_init() {
return nil
}
}
file_user_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UserLoadRsp); 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{
@ -313,7 +392,7 @@ func file_user_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_user_msg_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumMessages: 5,
NumExtensions: 0,
NumServices: 0,
},