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 切磋超时
|
if now-qr.Timestamp > 10 { //大于10s 切磋超时
|
||||||
code = pb.ErrorCode_FriendQiecuoTimeout
|
code = pb.ErrorCode_FriendQiecuoTimeout
|
||||||
//清除切磋记录
|
//清除切磋记录
|
||||||
this.moduleFriend.ModelFriendQiecuo.Del(req.Uid)
|
// this.moduleFriend.ModelFriendQiecuo.Del(req.Uid)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -30,12 +30,6 @@ func (this *apiComp) Qiecuo(session comm.IUserSession, req *pb.FriendQiecuoReq)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//已发送切磋
|
|
||||||
// if qr.Timestamp != 0 {
|
|
||||||
// code = pb.ErrorCode_FriendQiecuoRequested
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
//判断是否切磋中
|
//判断是否切磋中
|
||||||
if qr.MatchId != "" {
|
if qr.MatchId != "" {
|
||||||
code = pb.ErrorCode_FriendQiecuoing
|
code = pb.ErrorCode_FriendQiecuoing
|
||||||
|
@ -44,18 +44,25 @@ func (this *ModelFriendQiecuo) createQiecuoRecord(uid, targetUid string) (*pb.Qi
|
|||||||
Uid: uid,
|
Uid: uid,
|
||||||
TargetId: targetUid,
|
TargetId: targetUid,
|
||||||
Timestamp: configure.Now().Unix(),
|
Timestamp: configure.Now().Unix(),
|
||||||
|
Status: 1, //已发起
|
||||||
}
|
}
|
||||||
if err := this.Add(uid, qr); err != nil {
|
if err := this.Add(uid, qr); err != nil {
|
||||||
this.moduleFriend.Errorln(err)
|
this.moduleFriend.Errorln(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
update := map[string]interface{}{
|
//如果目标未接受且在超时时间内,不允许再次发送
|
||||||
"targetId": targetUid,
|
now := configure.Now().Unix()
|
||||||
"timestamp": configure.Now().Unix(),
|
if qr.Status == 1 && now-qr.Timestamp < 10 {
|
||||||
}
|
return qr, comm.NewCustomError(pb.ErrorCode_FriendQiecuoRequested)
|
||||||
if err := this.Change(uid, update); err != nil {
|
} else {
|
||||||
return nil, err
|
update := map[string]interface{}{
|
||||||
|
"targetId": targetUid,
|
||||||
|
"timestamp": configure.Now().Unix(),
|
||||||
|
}
|
||||||
|
if err := this.Change(uid, update); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +75,7 @@ func (this *ModelFriendQiecuo) updateQiecuoRecord(uid, targetUid, matchId string
|
|||||||
if qr != nil {
|
if qr != nil {
|
||||||
update := map[string]interface{}{
|
update := map[string]interface{}{
|
||||||
"matchId": matchId,
|
"matchId": matchId,
|
||||||
|
"status": 2, //已接受
|
||||||
}
|
}
|
||||||
if err := this.Change(uid, update); err != nil {
|
if err := this.Change(uid, update); err != nil {
|
||||||
this.moduleFriend.Errorln(err)
|
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) {
|
func (this *User) getRemoteUser(uid string) (*pb.DBUser, error) {
|
||||||
reply := &pb.DBUser{}
|
reply := &pb.DBUser{}
|
||||||
if err := this.getUserFromRemoteDb(uid, reply); err != nil {
|
if err := this.getUserFromRemoteDb(uid, reply); err != nil {
|
||||||
|
this.Errorln("getRemoteUser", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
this.Debug("远程用户", log.Field{Key: "uid", Value: uid}, log.Field{Key: "user", Value: reply})
|
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)
|
this.Errorln("Get User:", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
this.Debug("Get", log.Field{Key: "rsp",Value: rsp})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,6 +227,7 @@ type QiecuoRecord struct {
|
|||||||
|
|
||||||
Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid" bson:"uid"` //切磋发起人
|
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"` //切磋接受人
|
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
|
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"` //切磋发起时间戳
|
Timestamp int64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp" bson:"timestamp"` //切磋发起时间戳
|
||||||
}
|
}
|
||||||
@ -277,6 +278,13 @@ func (x *QiecuoRecord) GetTargetId() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *QiecuoRecord) GetStatus() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Status
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
func (x *QiecuoRecord) GetMatchId() string {
|
func (x *QiecuoRecord) GetMatchId() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.MatchId
|
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,
|
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,
|
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,
|
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, 0x72, 0x6f, 0x49, 0x64, 0x22, 0x8c, 0x01, 0x0a, 0x0c, 0x51, 0x69, 0x65, 0x63, 0x75, 0x6f,
|
||||||
0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
|
0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20,
|
||||||
0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x61, 0x72, 0x67, 0x65,
|
0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x61, 0x72, 0x67,
|
||||||
0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x61, 0x72, 0x67, 0x65,
|
0x65, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x61, 0x72, 0x67,
|
||||||
0x74, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x49, 0x64, 0x18, 0x04,
|
0x65, 0x74, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x49, 0x64, 0x12, 0x1c, 0x0a,
|
0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07,
|
||||||
0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03,
|
0x6d, 0x61, 0x74, 0x63, 0x68, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d,
|
||||||
0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e,
|
0x61, 0x74, 0x63, 0x68, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74,
|
||||||
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
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 (
|
var (
|
||||||
|
@ -47,7 +47,7 @@ func (this *DB) init() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//读取游戏配置文件
|
// 读取游戏配置文件
|
||||||
func (this *DB) readercrossconf(path string) (err error) {
|
func (this *DB) readercrossconf(path string) (err error) {
|
||||||
config := make(comm.CrossConfigs, 0)
|
config := make(comm.CrossConfigs, 0)
|
||||||
var (
|
var (
|
||||||
@ -93,7 +93,7 @@ func (this *DB) readercrossconf(path string) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//同步服务列表
|
// 同步服务列表
|
||||||
func (this *DB) SyncServiceList() (err error) {
|
func (this *DB) SyncServiceList() (err error) {
|
||||||
if this.options.IsCross {
|
if this.options.IsCross {
|
||||||
err = this.ConnectServiceList()
|
err = this.ConnectServiceList()
|
||||||
@ -175,6 +175,7 @@ func (this *DB) ServerDBConn(stage string) (conn *DBConn, err error) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
err = fmt.Errorf("DBConn:%s on init", stage)
|
err = fmt.Errorf("DBConn:%s on init", stage)
|
||||||
}
|
}
|
||||||
|
log.Debug("servers", log.Field{Key: stage, Value: this.servers[stage]})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user