Merge branch 'zhaocy' into dev
# Conflicts: # comm/core.go
This commit is contained in:
commit
13ef42edcc
@ -44,9 +44,7 @@ var runCmd = &cobra.Command{
|
|||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
opts := robot.DefaultOpts()
|
opts := robot.DefaultOpts()
|
||||||
opts.Create = *create
|
opts.Create = *create
|
||||||
if *create {
|
opts.Account = *account
|
||||||
opts.Account = *account
|
|
||||||
}
|
|
||||||
|
|
||||||
r := robot.NewRobot(opts)
|
r := robot.NewRobot(opts)
|
||||||
r.Run()
|
r.Run()
|
||||||
|
@ -1,38 +1,49 @@
|
|||||||
package robot
|
package robot
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *Robot) handleLogin(methodName string) {
|
func (r *Robot) handleLogin(msg *pb.UserMessage) {
|
||||||
switch methodName {
|
switch msg.SubType {
|
||||||
case "login":
|
case "login":
|
||||||
handleLogin(r)
|
handleLogin(r, msg)
|
||||||
default:
|
default:
|
||||||
log.Fatal("methodName no exist")
|
log.Fatal("methodName no exist")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleLogin(r *Robot) {
|
//处理接口响应数据
|
||||||
loginreq := &pb.UserLoginReq{
|
func handleLogin(r *Robot, msg *pb.UserMessage) {
|
||||||
Name: "aaa",
|
rsp := &pb.UserLoginResp{}
|
||||||
|
if !comm.ProtoDecode(msg, rsp) {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
logindata, _ := proto.Marshal(loginreq)
|
log.Printf("to client: %v", rsp.Data)
|
||||||
head := &pb.UserMessage{
|
}
|
||||||
ServiceMethod: "login.login",
|
|
||||||
Data: logindata,
|
//处理登录请求
|
||||||
|
func (r *Robot) AccountLogin() {
|
||||||
|
//登录
|
||||||
|
loginReg := &pb.UserLoginReq{
|
||||||
|
Name: r.Opts.Account,
|
||||||
}
|
}
|
||||||
|
|
||||||
if comm.ProtoEncode(loginreq, head) {
|
head := &pb.UserMessage{
|
||||||
err := r.SendToClient(head.Data)
|
MainType: "login",
|
||||||
|
SubType: "login",
|
||||||
|
}
|
||||||
|
if comm.ProtoEncode(loginReg, head) {
|
||||||
|
data, _ := proto.Marshal(head)
|
||||||
|
err := r.SendToClient(data)
|
||||||
if err != nil {
|
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
12
cmd/robot/readme.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Robot使用
|
||||||
|
|
||||||
|
## 命令行
|
||||||
|
```sh
|
||||||
|
#使用已存在的账号测试接口
|
||||||
|
go run cmd.go run --account yourAccount
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
#使用新账号测试接口
|
||||||
|
go run cmd.go run --account newAccount --create true
|
||||||
|
```
|
@ -5,7 +5,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -44,33 +43,40 @@ func (r *Robot) Run() {
|
|||||||
r.AccountLogin()
|
r.AccountLogin()
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
//处理响应
|
||||||
var msg *pb.UserMessage = &pb.UserMessage{}
|
go func() {
|
||||||
_, data, err := r.ws.ReadMessage()
|
for {
|
||||||
if err != nil {
|
var msg *pb.UserMessage = &pb.UserMessage{}
|
||||||
log.Fatal(err)
|
_, data, err := r.ws.ReadMessage()
|
||||||
}
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
if err = proto.Unmarshal(data, msg); err != nil {
|
if err = proto.Unmarshal(data, msg); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
r.handleMsg(msg)
|
||||||
}
|
}
|
||||||
r.handleMsg(msg)
|
}()
|
||||||
}
|
|
||||||
|
select {}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Robot) handleMsg(msg *pb.UserMessage) {
|
func (r *Robot) handleMsg(msg *pb.UserMessage) {
|
||||||
m, f, ok := utils.ParseP(msg.ServiceMethod)
|
switch msg.MainType {
|
||||||
if !ok {
|
|
||||||
log.Fatal("route error")
|
|
||||||
}
|
|
||||||
switch m {
|
|
||||||
case "login":
|
case "login":
|
||||||
r.handleLogin(f)
|
r.handleLogin(msg)
|
||||||
|
case "user":
|
||||||
|
r.handleUserMsg(msg)
|
||||||
default:
|
default:
|
||||||
log.Fatal("module route no exist")
|
log.Fatal("module route no exist")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Robot) onUserLoaded() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Robot) SendToClient(data []byte) error {
|
func (r *Robot) SendToClient(data []byte) error {
|
||||||
return r.ws.WriteMessage(websocket.BinaryMessage, data)
|
return r.ws.WriteMessage(websocket.BinaryMessage, data)
|
||||||
}
|
}
|
||||||
@ -103,7 +109,8 @@ func (r *Robot) AccountRegister() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
head := &pb.UserMessage{
|
head := &pb.UserMessage{
|
||||||
ServiceMethod: "login.login",
|
MainType: "login",
|
||||||
|
SubType: "login",
|
||||||
}
|
}
|
||||||
if comm.ProtoEncode(loginReg, head) {
|
if comm.ProtoEncode(loginReg, head) {
|
||||||
err = r.SendToClient(head.Data)
|
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1 +1,39 @@
|
|||||||
package robot
|
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() {
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -16,7 +16,7 @@ const (
|
|||||||
const (
|
const (
|
||||||
SM_GateModule core.M_Modules = "gateway" //gate模块 网关服务模块
|
SM_GateModule core.M_Modules = "gateway" //gate模块 网关服务模块
|
||||||
SM_WebModule core.M_Modules = "web" //web模块
|
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" //背包模块
|
SM_PackModule core.M_Modules = "pack" //背包模块
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ type IUserSession interface {
|
|||||||
GetGatewayServiceId() string
|
GetGatewayServiceId() string
|
||||||
Build(uid uint32) (err error)
|
Build(uid uint32) (err error)
|
||||||
UnBuild(ServiceMethod string, msg proto.Message) (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)
|
Close() (err error)
|
||||||
ToString() string
|
ToString() string
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ type Message struct {
|
|||||||
func ProtoDecode(msg *pb.UserMessage, req proto.Message) (ok bool) {
|
func ProtoDecode(msg *pb.UserMessage, req proto.Message) (ok bool) {
|
||||||
err := proto.Unmarshal(msg.Data, req)
|
err := proto.Unmarshal(msg.Data, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("%s %v", msg.ServiceMethod, err)
|
log.Errorf("%s.%s %v", msg.MainType, msg.SubType, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return true
|
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) {
|
func ProtoEncode(rsp proto.Message, msg *pb.UserMessage) (ok bool) {
|
||||||
data, err := proto.Marshal(rsp)
|
data, err := proto.Marshal(rsp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("%s %v", msg.ServiceMethod, err)
|
log.Errorf("%s.%s %v", msg.MainType, msg.SubType, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg.Data = data
|
msg.Data = data
|
||||||
|
@ -63,15 +63,17 @@ func (this *UserSession) UnBuild(ServiceMethod string, msg proto.Message) (err e
|
|||||||
return
|
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{}
|
reply := &pb.RPCMessageReply{}
|
||||||
data, _ := proto.Marshal(msg)
|
data, _ := proto.Marshal(msg)
|
||||||
|
log.Debugf("SendMsg Data: %v", msg)
|
||||||
if err := this.service.RpcCallById(this.GatewayServiceId, string(Rpc_GatewayAgentSendMsg), context.Background(), &pb.AgentSendMessageReq{
|
if err := this.service.RpcCallById(this.GatewayServiceId, string(Rpc_GatewayAgentSendMsg), context.Background(), &pb.AgentSendMessageReq{
|
||||||
UserSessionId: this.SessionId,
|
UserSessionId: this.SessionId,
|
||||||
ServiceMethod: ServiceMethod,
|
MainType: mainType,
|
||||||
|
SubType: subType,
|
||||||
Data: data,
|
Data: data,
|
||||||
}, reply); err != nil {
|
}, 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
|
return
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
type (
|
type (
|
||||||
IModule interface {
|
IModule interface {
|
||||||
core.IModule
|
core.IModule
|
||||||
SendMsgToUser(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(ServiceMethod string, msg proto.Message, user ...*pb.Cache_UserData) (err error)
|
SendMsgToUsers(mainType, subType string, msg proto.Message, user ...*pb.Cache_UserData) (err error)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -2,6 +2,7 @@ package gateway
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"sync"
|
"sync"
|
||||||
@ -134,13 +135,13 @@ func (this *Agent) Close() {
|
|||||||
//分发用户消息
|
//分发用户消息
|
||||||
func (this *Agent) messageDistribution(msg *pb.UserMessage) {
|
func (this *Agent) messageDistribution(msg *pb.UserMessage) {
|
||||||
reply := &pb.RPCMessageReply{}
|
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{
|
if err := this.gateway.Service().RpcCallByType("worker", string(comm.Rpc_GatewayRoute), context.Background(), &pb.AgentMessage{
|
||||||
Ip: this.IP(),
|
Ip: this.IP(),
|
||||||
UserSessionId: this.sessionId,
|
UserSessionId: this.sessionId,
|
||||||
UserId: this.uId,
|
UserId: this.uId,
|
||||||
GatewayServiceId: this.gateway.Service().GetId(),
|
GatewayServiceId: this.gateway.Service().GetId(),
|
||||||
Method: msg.ServiceMethod,
|
Method: fmt.Sprintf("%s.%s", msg.MainType, msg.SubType),
|
||||||
Message: msg.Data,
|
Message: msg.Data,
|
||||||
}, reply); err != nil {
|
}, reply); err != nil {
|
||||||
log.Errorf("agent:%s uId:%d MessageDistribution err:%v", this.sessionId, this.uId, err)
|
log.Errorf("agent:%s uId:%d MessageDistribution err:%v", this.sessionId, this.uId, err)
|
||||||
|
@ -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 {
|
func (this *AgentMgr_Comp) SendMsgToAgent(ctx context.Context, args *pb.AgentSendMessageReq, reply *pb.RPCMessageReply) error {
|
||||||
if a, ok := this.agents.Load(args.UserSessionId); ok {
|
if a, ok := this.agents.Load(args.UserSessionId); ok {
|
||||||
a.(IAgent).WriteMsg(&pb.UserMessage{
|
a.(IAgent).WriteMsg(&pb.UserMessage{
|
||||||
ServiceMethod: args.ServiceMethod,
|
MainType: args.MainType,
|
||||||
Data: args.Data,
|
SubType: args.SubType,
|
||||||
|
Data: args.Data,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
reply.Code = int32(comm.ErrorCode_UserSessionNobeing)
|
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 {
|
func (this *AgentMgr_Comp) SendMsgToAgents(ctx context.Context, args *pb.BatchMessageReq, reply *pb.RPCMessageReply) error {
|
||||||
msg := &pb.UserMessage{
|
msg := &pb.UserMessage{
|
||||||
ServiceMethod: args.ServiceMethod,
|
MainType: args.MainType,
|
||||||
Data: args.Data,
|
SubType: args.SubType,
|
||||||
|
Data: args.Data,
|
||||||
}
|
}
|
||||||
for _, v := range args.UserSessionIds {
|
for _, v := range args.UserSessionIds {
|
||||||
if a, ok := this.agents.Load(v); ok {
|
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 {
|
func (this *AgentMgr_Comp) SendMsgToAllAgent(ctx context.Context, args *pb.BroadCastMessageReq, reply *pb.RPCMessageReply) error {
|
||||||
msg := &pb.UserMessage{
|
msg := &pb.UserMessage{
|
||||||
ServiceMethod: args.ServiceMethod,
|
MainType: args.MainType,
|
||||||
Data: args.Data,
|
SubType: args.SubType,
|
||||||
|
Data: args.Data,
|
||||||
}
|
}
|
||||||
this.agents.Range(func(key, value any) bool {
|
this.agents.Range(func(key, value any) bool {
|
||||||
value.(IAgent).WriteMsg(msg)
|
value.(IAgent).WriteMsg(msg)
|
||||||
|
@ -40,8 +40,9 @@ func Test_WebSocket(t *testing.T) {
|
|||||||
}
|
}
|
||||||
logindata, _ := proto.Marshal(loginreq)
|
logindata, _ := proto.Marshal(loginreq)
|
||||||
message := &pb.UserMessage{
|
message := &pb.UserMessage{
|
||||||
ServiceMethod: "login.login",
|
MainType: "login",
|
||||||
Data: logindata,
|
SubType: "login",
|
||||||
|
Data: logindata,
|
||||||
}
|
}
|
||||||
data, _ := proto.Marshal(message)
|
data, _ := proto.Marshal(message)
|
||||||
err = ws.WriteMessage(websocket.BinaryMessage, data)
|
err = ws.WriteMessage(websocket.BinaryMessage, data)
|
||||||
|
@ -23,20 +23,21 @@ func (this *ModuleBase) Init(service core.IService, module core.IModule, options
|
|||||||
return
|
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{}
|
reply := &pb.RPCMessageReply{}
|
||||||
data, _ := proto.Marshal(msg)
|
data, _ := proto.Marshal(msg)
|
||||||
if _, err = this.service.RpcGoById(user.GatewayServiceId, string(comm.Rpc_GatewayAgentSendMsg), context.Background(), &pb.AgentSendMessageReq{
|
if _, err = this.service.RpcGoById(user.GatewayServiceId, string(comm.Rpc_GatewayAgentSendMsg), context.Background(), &pb.AgentSendMessageReq{
|
||||||
UserSessionId: user.SessionId,
|
UserSessionId: user.SessionId,
|
||||||
ServiceMethod: ServiceMethod,
|
MainType: mainType,
|
||||||
|
SubType: subType,
|
||||||
Data: data,
|
Data: data,
|
||||||
}, reply); err != nil {
|
}, 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
|
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 (
|
var (
|
||||||
gateways map[string][]string = make(map[string][]string)
|
gateways map[string][]string = make(map[string][]string)
|
||||||
gateway []string
|
gateway []string
|
||||||
@ -54,10 +55,11 @@ func (this *ModuleBase) SendMsgToUsers(ServiceMethod string, msg proto.Message,
|
|||||||
for k, v := range gateways {
|
for k, v := range gateways {
|
||||||
if _, err = this.service.RpcGoById(k, string(comm.Rpc_GatewayAgentSendMsg), context.Background(), &pb.BatchMessageReq{
|
if _, err = this.service.RpcGoById(k, string(comm.Rpc_GatewayAgentSendMsg), context.Background(), &pb.BatchMessageReq{
|
||||||
UserSessionIds: v,
|
UserSessionIds: v,
|
||||||
ServiceMethod: ServiceMethod,
|
MainType: mainType,
|
||||||
|
SubType: subType,
|
||||||
Data: data,
|
Data: data,
|
||||||
}, reply); err != nil {
|
}, 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
|
return
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package login
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -47,13 +47,19 @@ func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
session.SendMsg("loginRsp", &pb.UserLoginResp{
|
session.SendMsg("login", "login", &pb.UserLoginResp{
|
||||||
Code: comm.ErrorCode_Success,
|
Code: comm.ErrorCode_Success,
|
||||||
|
Data: &pb.Cache_UserData{
|
||||||
|
UserData: &pb.DB_UserData{
|
||||||
|
UserId: db_user.UserId,
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//注销
|
||||||
func (this *LoginComp) Logout(ctx context.Context, session comm.IUserSession, rsp *pb.UserLoginReq) error {
|
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)
|
log.Debugf("User - Logout: session:%v rsp:%v", session.ToString(), rsp)
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package login
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
@ -8,20 +8,20 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func NewModule() core.IModule {
|
func NewModule() core.IModule {
|
||||||
m := new(Login)
|
m := new(User)
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
type Login struct {
|
type User struct {
|
||||||
modules.ModuleBase
|
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
|
return comm.SM_LoginModule
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Login) OnInstallComp() {
|
func (this *User) OnInstallComp() {
|
||||||
this.ModuleBase.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
17
modules/user/user_comp.go
Normal 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
|
||||||
|
}
|
@ -16,6 +16,7 @@ import (
|
|||||||
type Api_Comp struct {
|
type Api_Comp struct {
|
||||||
cbase.ModuleCompBase
|
cbase.ModuleCompBase
|
||||||
options *Options
|
options *Options
|
||||||
|
module *Web
|
||||||
gin gin.ISys
|
gin gin.ISys
|
||||||
}
|
}
|
||||||
|
|
||||||
|
128
pb/comm.pb.go
128
pb/comm.pb.go
@ -26,8 +26,9 @@ type UserMessage struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
ServiceMethod string `protobuf:"bytes,1,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` //服务名
|
MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType,omitempty"`
|
||||||
Data []byte `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,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() {
|
func (x *UserMessage) Reset() {
|
||||||
@ -62,9 +63,16 @@ func (*UserMessage) Descriptor() ([]byte, []int) {
|
|||||||
return file_comm_proto_rawDescGZIP(), []int{0}
|
return file_comm_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *UserMessage) GetServiceMethod() string {
|
func (x *UserMessage) GetMainType() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.ServiceMethod
|
return x.MainType
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *UserMessage) GetSubType() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.SubType
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@ -331,8 +339,9 @@ type AgentSendMessageReq struct {
|
|||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
UserSessionId string `protobuf:"bytes,1,opt,name=UserSessionId,proto3" json:"UserSessionId,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"` //服务名
|
MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType,omitempty"`
|
||||||
Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,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() {
|
func (x *AgentSendMessageReq) Reset() {
|
||||||
@ -374,9 +383,16 @@ func (x *AgentSendMessageReq) GetUserSessionId() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *AgentSendMessageReq) GetServiceMethod() string {
|
func (x *AgentSendMessageReq) GetMainType() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.ServiceMethod
|
return x.MainType
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *AgentSendMessageReq) GetSubType() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.SubType
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@ -395,8 +411,9 @@ type BatchMessageReq struct {
|
|||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
UserSessionIds []string `protobuf:"bytes,1,rep,name=UserSessionIds,proto3" json:"UserSessionIds,omitempty"`
|
UserSessionIds []string `protobuf:"bytes,1,rep,name=UserSessionIds,proto3" json:"UserSessionIds,omitempty"`
|
||||||
ServiceMethod string `protobuf:"bytes,2,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"`
|
MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType,omitempty"`
|
||||||
Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,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() {
|
func (x *BatchMessageReq) Reset() {
|
||||||
@ -438,9 +455,16 @@ func (x *BatchMessageReq) GetUserSessionIds() []string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *BatchMessageReq) GetServiceMethod() string {
|
func (x *BatchMessageReq) GetMainType() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.ServiceMethod
|
return x.MainType
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *BatchMessageReq) GetSubType() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.SubType
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@ -458,8 +482,9 @@ type BroadCastMessageReq struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
ServiceMethod string `protobuf:"bytes,1,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` //服务名
|
MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType,omitempty"` //服务名
|
||||||
Data []byte `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,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() {
|
func (x *BroadCastMessageReq) Reset() {
|
||||||
@ -494,9 +519,16 @@ func (*BroadCastMessageReq) Descriptor() ([]byte, []int) {
|
|||||||
return file_comm_proto_rawDescGZIP(), []int{7}
|
return file_comm_proto_rawDescGZIP(), []int{7}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *BroadCastMessageReq) GetServiceMethod() string {
|
func (x *BroadCastMessageReq) GetMainType() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.ServiceMethod
|
return x.MainType
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *BroadCastMessageReq) GetSubType() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.SubType
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@ -559,11 +591,12 @@ func (x *AgentCloseeReq) GetUserSessionId() string {
|
|||||||
var File_comm_proto protoreflect.FileDescriptor
|
var File_comm_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_comm_proto_rawDesc = []byte{
|
var file_comm_proto_rawDesc = []byte{
|
||||||
0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x47, 0x0a, 0x0b,
|
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, 0x24, 0x0a, 0x0d, 0x53,
|
0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x4d,
|
||||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01,
|
0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d,
|
||||||
0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f,
|
0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79,
|
||||||
0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
0x6e, 0x49, 0x64, 0x22, 0x85, 0x01, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e,
|
||||||
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73,
|
0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55,
|
||||||
0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||||
0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64,
|
0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49,
|
||||||
0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f,
|
0x64, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20,
|
||||||
0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a,
|
||||||
0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03,
|
0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
|
||||||
0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x73, 0x0a, 0x0f, 0x42, 0x61,
|
0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18,
|
||||||
0x74, 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a,
|
0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x83, 0x01, 0x0a, 0x0f,
|
||||||
0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x18,
|
0x42, 0x61, 0x74, 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12,
|
||||||
0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69,
|
0x26, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64,
|
||||||
0x6f, 0x6e, 0x49, 0x64, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73,
|
||||||
0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65,
|
0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54,
|
||||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44,
|
0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54,
|
||||||
0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22,
|
0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03,
|
||||||
0x4f, 0x0a, 0x13, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73,
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a,
|
||||||
0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
|
0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74,
|
||||||
0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53,
|
0x61, 0x22, 0x5f, 0x0a, 0x13, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, 0x65,
|
||||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04,
|
0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e,
|
||||||
0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61,
|
0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e,
|
||||||
0x22, 0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x65, 0x52,
|
0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18,
|
||||||
0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f,
|
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12,
|
||||||
0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53,
|
0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61,
|
||||||
0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62,
|
0x74, 0x61, 0x22, 0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65,
|
||||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
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 (
|
var (
|
||||||
|
@ -3,8 +3,9 @@ option go_package = ".;pb";
|
|||||||
|
|
||||||
//用户消息流结构
|
//用户消息流结构
|
||||||
message UserMessage {
|
message UserMessage {
|
||||||
string ServiceMethod =1; //服务名
|
string MainType =1;
|
||||||
bytes Data = 2;
|
string SubType = 2;
|
||||||
|
bytes Data = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
//代理用户转发消息结构
|
//代理用户转发消息结构
|
||||||
@ -36,21 +37,24 @@ message AgentUnBuildReq {
|
|||||||
//向用户代理发送消息请求
|
//向用户代理发送消息请求
|
||||||
message AgentSendMessageReq {
|
message AgentSendMessageReq {
|
||||||
string UserSessionId = 1;
|
string UserSessionId = 1;
|
||||||
string ServiceMethod = 2; //服务名
|
string MainType = 2;
|
||||||
bytes Data = 3;
|
string SubType = 3;
|
||||||
|
bytes Data = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
//发送批量消息
|
//发送批量消息
|
||||||
message BatchMessageReq {
|
message BatchMessageReq {
|
||||||
repeated string UserSessionIds = 1;
|
repeated string UserSessionIds = 1;
|
||||||
string ServiceMethod = 2;
|
string MainType = 2;
|
||||||
bytes Data = 3;
|
string SubType = 3;
|
||||||
|
bytes Data = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
//发送广播消息
|
//发送广播消息
|
||||||
message BroadCastMessageReq {
|
message BroadCastMessageReq {
|
||||||
string ServiceMethod = 1; //服务名
|
string MainType = 1; //服务名
|
||||||
bytes Data = 2;
|
string SubType = 2;
|
||||||
|
bytes Data = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
//关闭用户代理
|
//关闭用户代理
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
option go_package = ".;pb";
|
option go_package = ".;pb";
|
||||||
|
|
||||||
|
import "user_db.proto";
|
||||||
|
|
||||||
message UserLoginReq {
|
message UserLoginReq {
|
||||||
string Name = 1;
|
string Name = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message UserLoginResp {
|
message UserLoginResp {
|
||||||
int32 Code = 1;
|
int32 Code = 1;
|
||||||
|
Cache_UserData data = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -17,3 +20,16 @@ message UserRegisterReq{
|
|||||||
message UserRegisterRsp{
|
message UserRegisterRsp{
|
||||||
int32 Code = 1;
|
int32 Code = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message UserLoadRsp {
|
||||||
|
Cache_UserData data = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message UserCreateReq{
|
||||||
|
string NickName = 1;//昵称
|
||||||
|
int32 gender = 2; //性别
|
||||||
|
}
|
||||||
|
|
||||||
|
message UserCreateRsp{
|
||||||
|
|
||||||
|
}
|
@ -72,7 +72,8 @@ type UserLoginResp struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
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() {
|
func (x *UserLoginResp) Reset() {
|
||||||
@ -114,6 +115,13 @@ func (x *UserLoginResp) GetCode() int32 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *UserLoginResp) GetData() *Cache_UserData {
|
||||||
|
if x != nil {
|
||||||
|
return x.Data
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type UserRegisterReq struct {
|
type UserRegisterReq struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
@ -208,21 +216,75 @@ func (x *UserRegisterRsp) GetCode() int32 {
|
|||||||
return 0
|
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 protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_user_msg_proto_rawDesc = []byte{
|
var file_user_msg_proto_rawDesc = []byte{
|
||||||
0x0a, 0x0e, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
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,
|
0x1a, 0x0d, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
|
||||||
0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
|
0x22, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x12,
|
||||||
0x4e, 0x61, 0x6d, 0x65, 0x22, 0x23, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69,
|
0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e,
|
||||||
0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20,
|
0x61, 0x6d, 0x65, 0x22, 0x48, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e,
|
||||||
0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x2b, 0x0a, 0x0f, 0x55, 0x73, 0x65,
|
0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01,
|
||||||
0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07,
|
0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61,
|
||||||
0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61,
|
0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55,
|
||||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x25, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65,
|
0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a,
|
||||||
0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64,
|
0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71,
|
||||||
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x42, 0x06, 0x5a,
|
0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||||
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
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 (
|
var (
|
||||||
@ -237,19 +299,23 @@ func file_user_msg_proto_rawDescGZIP() []byte {
|
|||||||
return file_user_msg_proto_rawDescData
|
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{}{
|
var file_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
|
||||||
(*UserRegisterRsp)(nil), // 3: UserRegisterRsp
|
(*UserRegisterRsp)(nil), // 3: UserRegisterRsp
|
||||||
|
(*UserLoadRsp)(nil), // 4: UserLoadRsp
|
||||||
|
(*Cache_UserData)(nil), // 5: Cache_UserData
|
||||||
}
|
}
|
||||||
var file_user_msg_proto_depIdxs = []int32{
|
var file_user_msg_proto_depIdxs = []int32{
|
||||||
0, // [0:0] is the sub-list for method output_type
|
5, // 0: UserLoginResp.data:type_name -> Cache_UserData
|
||||||
0, // [0:0] is the sub-list for method input_type
|
5, // 1: UserLoadRsp.data:type_name -> Cache_UserData
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
2, // [2:2] is the sub-list for method output_type
|
||||||
0, // [0:0] is the sub-list for extension extendee
|
2, // [2:2] is the sub-list for method input_type
|
||||||
0, // [0:0] is the sub-list for field type_name
|
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() }
|
func init() { file_user_msg_proto_init() }
|
||||||
@ -257,6 +323,7 @@ func file_user_msg_proto_init() {
|
|||||||
if File_user_msg_proto != nil {
|
if File_user_msg_proto != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
file_user_db_proto_init()
|
||||||
if !protoimpl.UnsafeEnabled {
|
if !protoimpl.UnsafeEnabled {
|
||||||
file_user_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
file_user_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*UserLoginReq); i {
|
switch v := v.(*UserLoginReq); i {
|
||||||
@ -306,6 +373,18 @@ func file_user_msg_proto_init() {
|
|||||||
return nil
|
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{}
|
type x struct{}
|
||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
@ -313,7 +392,7 @@ func file_user_msg_proto_init() {
|
|||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_user_msg_proto_rawDesc,
|
RawDescriptor: file_user_msg_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 4,
|
NumMessages: 5,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 0,
|
NumServices: 0,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user