go_dreamfactory/modules/robot/core.go
2023-09-07 15:45:42 +08:00

72 lines
1.7 KiB
Go

package robot
import (
"go_dreamfactory/lego/core"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"google.golang.org/protobuf/proto"
)
//监控
type IRobotMonitor interface {
//成功
AddSuccClient(robot *Robot)
//失败
AddFailClient(robot *Robot, err error)
//结束
RobotFinishedTest(robot *Robot)
//报表
OutReport()
}
//客户端端
type IClient interface {
Init(addr string, client IClient) (err error)
Heartbeat()
Receive(msg *pb.UserMessage) (err error)
WriteMsg(msg *pb.UserMessage) (err error)
Close()
OnClose()
}
//机器人
type IRobot interface {
IClient
Account() string
ServerId() string
GetModule(module core.M_Modules) IModuleRobot
SendMessage(mtype, stype string, msg proto.Message) (resp proto.Message, errdata *pb.ErrorData)
SendTaskMessage(task, comdi int32, mtype, stype string, msg proto.Message) (resp proto.Message, errdata *pb.ErrorData)
DoTask(taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData, module core.M_Modules) (err error)
}
//机器人模块
type IModuleRobot interface {
Init() (err error)
//接收到回应和推送消息
Receive(robot IRobot, stype string, message proto.Message) (err error)
//执行流水线任务
DoPipeline(robot IRobot) (err error)
//执行任务
DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error)
}
type SecBuild struct {
Account string `json:"account"`
ServerId string `json:"serverId"`
TimeStamp int64 `json:"timestamp"`
}
type MessageResp struct {
resp proto.Message
errdata *pb.ErrorData
}
type Pipeline struct {
Module string //模块名
Exenum int32 //执行次数
CurrNum int32 //当前已执行次数
ErrNotStop bool //遇到错误是否中断
}