update
This commit is contained in:
parent
65f841e958
commit
9b7f8f3ffe
@ -45,6 +45,7 @@ type ModuleRtask struct {
|
||||
api *apiComp
|
||||
configure *configureComp
|
||||
handleMap sync.Map //map[int32]*rtaskCondi //任务校验处理器
|
||||
condIds []int32
|
||||
}
|
||||
|
||||
func NewModule() core.IModule {
|
||||
@ -270,7 +271,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondHandle)
|
||||
}
|
||||
|
||||
// 处理触发的任务
|
||||
func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType comm.TaskType, params ...int32) (condIds []int32, code pb.ErrorCode) {
|
||||
func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType comm.TaskType, params ...int32) (code pb.ErrorCode) {
|
||||
uid := session.GetUserId()
|
||||
|
||||
var handles []*rtaskCondHandle
|
||||
@ -305,7 +306,7 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType com
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
condIds = append(condIds, conf.Id)
|
||||
this.condIds = append(this.condIds, conf.Id)
|
||||
}
|
||||
}
|
||||
|
||||
@ -323,7 +324,11 @@ func (this *ModuleRtask) TriggerTask(uid string, taskParams ...*comm.TaskParam)
|
||||
if err != nil {
|
||||
this.Error("TriggerTask userlock err!", log.Field{Key: "err", Value: err.Error()})
|
||||
}
|
||||
defer lock.Unlock()
|
||||
defer func() {
|
||||
this.condIds = []int32{}
|
||||
|
||||
lock.Unlock()
|
||||
}()
|
||||
|
||||
record := &pb.DBRtaskRecord{Uid: uid}
|
||||
if err := this.modelRtaskRecord.Get(uid, record); err != nil {
|
||||
@ -339,23 +344,16 @@ func (this *ModuleRtask) TriggerTask(uid string, taskParams ...*comm.TaskParam)
|
||||
|
||||
this.modelRtaskRecord.record = record
|
||||
|
||||
var (
|
||||
condIds []int32
|
||||
)
|
||||
for _, tp := range taskParams {
|
||||
this.Debug("任务触发",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "type", Value: tp.TT},
|
||||
log.Field{Key: "params", Value: tp.Params})
|
||||
|
||||
ids, code := this.processOneTask(session, tp.TT, tp.Params...)
|
||||
code := this.processOneTask(session, tp.TT, tp.Params...)
|
||||
if code != pb.ErrorCode_Success {
|
||||
// this.Error("任务处理", log.Field{Key: "uid", Value: uid}, log.Field{Key: "code", Value: code})
|
||||
}
|
||||
|
||||
condIds = append(condIds, ids...)
|
||||
|
||||
this.Debug("已处理的任务", log.Field{Key: "condIds", Value: ids})
|
||||
comm.PuttaskParam(tp)
|
||||
}
|
||||
|
||||
@ -365,7 +363,7 @@ func (this *ModuleRtask) TriggerTask(uid string, taskParams ...*comm.TaskParam)
|
||||
|
||||
this.modelRtaskRecord.Change(uid, update)
|
||||
|
||||
for _, condId := range condIds {
|
||||
for _, condId := range this.condIds {
|
||||
//任务完成则推送
|
||||
if code := this.CheckCondi(uid, condId); code == pb.ErrorCode_Success {
|
||||
module, err := this.service.GetModule(comm.ModuleWorldtask)
|
||||
@ -467,6 +465,10 @@ func (this *ModuleRtask) ChangeCondi(uid string, data map[int32]*pb.RtaskData) e
|
||||
return nil
|
||||
}
|
||||
|
||||
type TaskProcessResp struct {
|
||||
CondIds []int32
|
||||
}
|
||||
|
||||
// 接收区服worker发起的秘境事件
|
||||
func (this *ModuleRtask) Rpc_ModuleRtaskSendTask(ctx context.Context, args *pb.RPCRTaskReq, reply *pb.EmptyResp) (err error) {
|
||||
this.Debug("Rpc_ModuleRtaskSendTask",
|
||||
@ -487,7 +489,7 @@ func (this *ModuleRtask) Rpc_ModuleRtaskSendTask(ctx context.Context, args *pb.R
|
||||
return
|
||||
} else {
|
||||
this.processOneTask(session, comm.TaskType(args.TaskType), args.Param...)
|
||||
// session.Push()
|
||||
session.Push()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user