go_dreamfactory/modules/robot/core.go
2023-08-23 16:14:10 +08:00

49 lines
1.2 KiB
Go

package robot
import (
"go_dreamfactory/lego/core"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"google.golang.org/protobuf/proto"
)
//客户端端
type IClient interface {
Init(addr string, client IClient) (err error)
Heartbeat()
Receive(msg *pb.UserMessage) (err error)
WriteMsg(msg *pb.UserMessage) (err error)
SendMessage(mtype, stype string, msg proto.Message) (err error)
Close()
OnClose()
}
//机器人
type IRobot interface {
IClient
Account() string
ServerId() string
SetData(key string, data interface{})
GetData(key string) interface{}
DoTask(taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData, module core.M_Modules) (err error)
}
//机器人模块
type IModuleRobot interface {
//接收到回应和推送消息
Receive(robot IRobot, stype string, message proto.Message) (err error)
//错误码接收
ErrReceive(robot IRobot, stype string, code pb.ErrorCode) (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"`
}