update
This commit is contained in:
parent
c9869d646c
commit
d54401a3fe
@ -29,7 +29,7 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.FriendAcceptReq)
|
||||
if now-qr.Timestamp > 10 { //大于10s 切磋超时
|
||||
code = pb.ErrorCode_FriendQiecuoTimeout
|
||||
//清除切磋记录
|
||||
this.moduleFriend.ModelFriendQiecuo.Del(req.Uid)
|
||||
// this.moduleFriend.ModelFriendQiecuo.Del(req.Uid)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
|
@ -30,12 +30,6 @@ func (this *apiComp) Qiecuo(session comm.IUserSession, req *pb.FriendQiecuoReq)
|
||||
return
|
||||
}
|
||||
|
||||
//已发送切磋
|
||||
// if qr.Timestamp != 0 {
|
||||
// code = pb.ErrorCode_FriendQiecuoRequested
|
||||
// return
|
||||
// }
|
||||
|
||||
//判断是否切磋中
|
||||
if qr.MatchId != "" {
|
||||
code = pb.ErrorCode_FriendQiecuoing
|
||||
|
@ -44,11 +44,17 @@ func (this *ModelFriendQiecuo) createQiecuoRecord(uid, targetUid string) (*pb.Qi
|
||||
Uid: uid,
|
||||
TargetId: targetUid,
|
||||
Timestamp: configure.Now().Unix(),
|
||||
Status: 1, //已发起
|
||||
}
|
||||
if err := this.Add(uid, qr); err != nil {
|
||||
this.moduleFriend.Errorln(err)
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
//如果目标未接受且在超时时间内,不允许再次发送
|
||||
now := configure.Now().Unix()
|
||||
if qr.Status == 1 && now-qr.Timestamp < 10 {
|
||||
return qr, comm.NewCustomError(pb.ErrorCode_FriendQiecuoRequested)
|
||||
} else {
|
||||
update := map[string]interface{}{
|
||||
"targetId": targetUid,
|
||||
@ -58,6 +64,7 @@ func (this *ModelFriendQiecuo) createQiecuoRecord(uid, targetUid string) (*pb.Qi
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return qr, nil
|
||||
}
|
||||
@ -68,6 +75,7 @@ func (this *ModelFriendQiecuo) updateQiecuoRecord(uid, targetUid, matchId string
|
||||
if qr != nil {
|
||||
update := map[string]interface{}{
|
||||
"matchId": matchId,
|
||||
"status": 2, //已接受
|
||||
}
|
||||
if err := this.Change(uid, update); err != nil {
|
||||
this.moduleFriend.Errorln(err)
|
||||
|
@ -129,6 +129,7 @@ func (this *User) GetCrossUser(uid string) (*pb.DBUser, error) {
|
||||
func (this *User) getRemoteUser(uid string) (*pb.DBUser, error) {
|
||||
reply := &pb.DBUser{}
|
||||
if err := this.getUserFromRemoteDb(uid, reply); err != nil {
|
||||
this.Errorln("getRemoteUser", err)
|
||||
return nil, err
|
||||
}
|
||||
this.Debug("远程用户", log.Field{Key: "uid", Value: uid}, log.Field{Key: "user", Value: reply})
|
||||
@ -563,6 +564,7 @@ func (this *User) getUserFromRemoteDb(uid string, rsp *pb.DBUser) error {
|
||||
this.Errorln("Get User:", err)
|
||||
return err
|
||||
}
|
||||
this.Debug("Get", log.Field{Key: "rsp",Value: rsp})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -227,6 +227,7 @@ type QiecuoRecord struct {
|
||||
|
||||
Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid" bson:"uid"` //切磋发起人
|
||||
TargetId string `protobuf:"bytes,2,opt,name=targetId,proto3" json:"targetId" bson:"targetId"` //切磋接受人
|
||||
Status int32 `protobuf:"varint,3,opt,name=status,proto3" json:"status" bson:"status"` //0默认 1已发送 2已接收 3已匹配
|
||||
MatchId string `protobuf:"bytes,4,opt,name=matchId,proto3" json:"matchId" bson:"matchId"` //战斗ID
|
||||
Timestamp int64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp" bson:"timestamp"` //切磋发起时间戳
|
||||
}
|
||||
@ -277,6 +278,13 @@ func (x *QiecuoRecord) GetTargetId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *QiecuoRecord) GetStatus() int32 {
|
||||
if x != nil {
|
||||
return x.Status
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *QiecuoRecord) GetMatchId() string {
|
||||
if x != nil {
|
||||
return x.MatchId
|
||||
@ -326,15 +334,17 @@ var file_friend_friend_db_proto_rawDesc = []byte{
|
||||
0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x61, 0x73, 0x73, 0x69, 0x73, 0x74, 0x54, 0x69, 0x6d,
|
||||
0x65, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x73, 0x73, 0x69, 0x73, 0x74, 0x48, 0x65, 0x72, 0x6f, 0x49,
|
||||
0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x73, 0x73, 0x69, 0x73, 0x74, 0x48,
|
||||
0x65, 0x72, 0x6f, 0x49, 0x64, 0x22, 0x74, 0x0a, 0x0c, 0x51, 0x69, 0x65, 0x63, 0x75, 0x6f, 0x52,
|
||||
0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x61, 0x72, 0x67, 0x65,
|
||||
0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x61, 0x72, 0x67, 0x65,
|
||||
0x74, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x49, 0x64, 0x18, 0x04,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x49, 0x64, 0x12, 0x1c, 0x0a,
|
||||
0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03,
|
||||
0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e,
|
||||
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x65, 0x72, 0x6f, 0x49, 0x64, 0x22, 0x8c, 0x01, 0x0a, 0x0c, 0x51, 0x69, 0x65, 0x63, 0x75, 0x6f,
|
||||
0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x61, 0x72, 0x67,
|
||||
0x65, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x61, 0x72, 0x67,
|
||||
0x65, 0x74, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07,
|
||||
0x6d, 0x61, 0x74, 0x63, 0x68, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d,
|
||||
0x61, 0x74, 0x63, 0x68, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74,
|
||||
0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73,
|
||||
0x74, 0x61, 0x6d, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -175,6 +175,7 @@ func (this *DB) ServerDBConn(stage string) (conn *DBConn, err error) {
|
||||
if !ok {
|
||||
err = fmt.Errorf("DBConn:%s on init", stage)
|
||||
}
|
||||
log.Debug("servers", log.Field{Key: stage, Value: this.servers[stage]})
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user