Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
8b228a7cd0
@ -56,7 +56,6 @@ type Agent struct {
|
|||||||
closeSignal chan bool
|
closeSignal chan bool
|
||||||
state int32 //状态 0 关闭 1 运行 2 关闭中
|
state int32 //状态 0 关闭 1 运行 2 关闭中
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
hlock sync.RWMutex
|
|
||||||
protoMsg map[string]int64
|
protoMsg map[string]int64
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,33 +95,28 @@ locp:
|
|||||||
var code pb.ErrorCode
|
var code pb.ErrorCode
|
||||||
code, err = this.secAuth(msg)
|
code, err = this.secAuth(msg)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
this.gateway.Debugf("----------2 agent:%s uId:%s MainType:%s SubType:%s ", this.sessionId, this.uId, msg.MainType, msg.SubType)
|
// this.gateway.Debugf("----------2 agent:%s uId:%s MainType:%s SubType:%s ", this.sessionId, this.uId, msg.MainType, msg.SubType)
|
||||||
if this.uId != "" {
|
|
||||||
key := this.uId + msg.MainType + msg.SubType // 加锁
|
|
||||||
if v, ok := this.protoMsg[key]; ok {
|
|
||||||
if v != 0 && configure.Now().Unix()-v < 2 {
|
|
||||||
// 返回错误码
|
|
||||||
this.hlock.Lock()
|
|
||||||
this.protoMsg[key] = configure.Now().Unix()
|
|
||||||
this.hlock.Unlock()
|
|
||||||
data, _ := anypb.New(&pb.NotifyErrorNotifyPush{
|
|
||||||
ReqMainType: msg.MainType,
|
|
||||||
ReqSubType: msg.SubType,
|
|
||||||
Arg: msg.Data,
|
|
||||||
Code: pb.ErrorCode_InsufficientPermissions})
|
|
||||||
err = this.WriteMsg(&pb.UserMessage{
|
|
||||||
MainType: comm.MainTypeNotify,
|
|
||||||
SubType: comm.SubTypeErrorNotify,
|
|
||||||
Data: data,
|
|
||||||
})
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.hlock.Lock()
|
|
||||||
this.protoMsg[key] = configure.Now().Unix()
|
|
||||||
this.hlock.Unlock()
|
|
||||||
|
|
||||||
|
key := msg.MainType + msg.SubType // 加锁
|
||||||
|
if v, ok := this.protoMsg[key]; ok {
|
||||||
|
if v != 0 && configure.Now().Unix()-v < 2 {
|
||||||
|
// 返回错误码
|
||||||
|
this.protoMsg[key] = configure.Now().Unix()
|
||||||
|
data, _ := anypb.New(&pb.NotifyErrorNotifyPush{
|
||||||
|
ReqMainType: msg.MainType,
|
||||||
|
ReqSubType: msg.SubType,
|
||||||
|
Arg: msg.Data,
|
||||||
|
Code: pb.ErrorCode_InsufficientPermissions})
|
||||||
|
err = this.WriteMsg(&pb.UserMessage{
|
||||||
|
MainType: comm.MainTypeNotify,
|
||||||
|
SubType: comm.SubTypeErrorNotify,
|
||||||
|
Data: data,
|
||||||
|
})
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
this.protoMsg[key] = configure.Now().Unix()
|
||||||
|
|
||||||
if err := this.messageDistribution(msg); err != nil {
|
if err := this.messageDistribution(msg); err != nil {
|
||||||
this.gateway.Errorf("messageDistribution err:%v", err)
|
this.gateway.Errorf("messageDistribution err:%v", err)
|
||||||
go this.Close()
|
go this.Close()
|
||||||
@ -372,14 +366,9 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) {
|
|||||||
log.Field{Key: "req", Value: fmt.Sprintf("%s:%s %v", req.MainType, req.SubType, req.Message.String())},
|
log.Field{Key: "req", Value: fmt.Sprintf("%s:%s %v", req.MainType, req.SubType, req.Message.String())},
|
||||||
log.Field{Key: "reply", Value: reply.String()},
|
log.Field{Key: "reply", Value: reply.String()},
|
||||||
)
|
)
|
||||||
|
key := msg.MainType + msg.SubType
|
||||||
if this.uId != "" {
|
if v, ok := this.protoMsg[key]; ok && v != 0 { // 发送消息 协议解锁
|
||||||
key := this.uId + msg.MainType + msg.SubType
|
v = 0
|
||||||
this.hlock.Lock()
|
|
||||||
if v, ok := this.protoMsg[key]; ok && v != 0 { // 发送消息 协议解锁
|
|
||||||
v = 0
|
|
||||||
}
|
|
||||||
this.hlock.Unlock()
|
|
||||||
}
|
}
|
||||||
if reply.Code != pb.ErrorCode_Success {
|
if reply.Code != pb.ErrorCode_Success {
|
||||||
data, _ := anypb.New(&pb.NotifyErrorNotifyPush{
|
data, _ := anypb.New(&pb.NotifyErrorNotifyPush{
|
||||||
|
@ -154,7 +154,7 @@ func (this *Mail) SendMailByCid(session comm.IUserSession, cid string, res []*pb
|
|||||||
|
|
||||||
// 获取额外配置
|
// 获取额外配置
|
||||||
conf := this.configure.GetMailConf(cid)
|
conf := this.configure.GetMailConf(cid)
|
||||||
if conf != nil {
|
if conf == nil {
|
||||||
this.Errorf("can't found mail by cid: %s", cid)
|
this.Errorf("can't found mail by cid: %s", cid)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user