This commit is contained in:
liwei1dao 2023-01-30 17:59:23 +08:00
commit cc0d94ea6c
13 changed files with 80 additions and 19 deletions

View File

@ -104,9 +104,9 @@ func (c *ConnServiceImpl) ListenerPush() {
DataTime: time.Now().Format(time.RFC3339),
Msg: msg,
}
logrus.WithFields(
logrus.Fields{"MainType": msg.MainType, "SubType": msg.SubType},
).Debug(methodName)
// logrus.WithFields(
// logrus.Fields{"MainType": msg.MainType, "SubType": msg.SubType},
// ).Debug(methodName)
renderRespPanel := func(p *model.PushModel) {
c.obs.Notify(observer.EVENT_REQ_RSP, p.Msg)

View File

@ -22,6 +22,8 @@ type PttService interface {
GetUser() *UserInfo
SetUser(dbUser *pb.DBUser, dbUserExpand *pb.DBUserExpand)
SendToClient(mainType, subType string, rsp proto.Message) error
Ping(sid, account string)
}
type PttServiceImpl struct {
@ -85,6 +87,15 @@ func (p *PttServiceImpl) Login(sid, account string) (code pb.ErrorCode) {
return
}
func (p *PttServiceImpl) Ping(sid, account string) {
head := &pb.UserMessage{MainType: string(comm.ModuleGate), SubType: "heartbeat"}
head.Sec = common.BuildSecStr(sid, account)
if err := p.connService.SendMsg(head, &pb.GatewayHeartbeatReq{}); err != nil {
return
}
return
}
// create role
func (p *PttServiceImpl) CreateRole(nickName string, gender, figure int32) (code pb.ErrorCode) {
head := &pb.UserMessage{MainType: string(comm.ModuleUser), SubType: user.UserSubTypeCreate}

View File

@ -10,6 +10,7 @@ import (
"go_dreamfactory/modules/user"
"go_dreamfactory/pb"
"strings"
"time"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
@ -312,6 +313,14 @@ func (ui *MainWindowImpl) createLoginWin(sid, sname string) {
return
}
go func() {
timer := time.NewTimer(10 * time.Second)
for {
timer.Reset(10 * time.Second)
<-timer.C
ui.pttService.Ping(sid, account.Text)
}
}()
// reset main window title
subTitle := fmt.Sprintf("%s[%s]", sname, sid)
ui.w.SetTitle(fmt.Sprintf(common.APP_WIN_TITLE, subTitle, ui.app.Metadata().Version, ui.app.Metadata().Build, common.APP_NAME))

View File

@ -163,7 +163,7 @@ const (
TableCrossSession = "crosssession"
TableServerData = "serverdata" // 跨服服务器相关数据
TableSeasonData = "seasondata" // 跨服服务器相关数据
///竞技场
TableArena = "arena"
@ -591,6 +591,7 @@ const (
const (
MaxRankList = 50 // 赛季塔 排行榜人数
MaxMailCount = 50 // 当前邮件最大数量
)
const (

View File

@ -71,7 +71,7 @@ locp:
go this.Close()
break locp
}
this.wsConn.SetReadDeadline(time.Now().Add(time.Second * 30))
if err = proto.Unmarshal(data, msg); err != nil {
this.gateway.Errorf("agent:%s uId:%s Unmarshal err:%v", this.sessionId, this.uId, err)
go this.Close()
@ -89,9 +89,11 @@ locp:
SubType: "heartbeat",
Data: data,
})
//this.wsConn.SetReadDeadline(time.Now().Add(time.Second * 30))
continue
}
if err := this.messageDistribution(msg); err != nil {
this.gateway.Errorf("messageDistribution err:%v", err)
go this.Close()
break locp
}

View File

@ -48,7 +48,7 @@ func (this *apiComp) Fusion(session comm.IUserSession, req *pb.HeroFusionReq) (c
if c != pb.ErrorCode_Success || _obj.SameCount < v {
code = pb.ErrorCode_HeroNoExist
}
mapHero[_obj.HeroID] = v
mapHero[_obj.HeroID] += v
_costMaphero[k] = _obj
}
for _, v := range conf.Pointhero {

View File

@ -31,11 +31,16 @@ func (this *modelMail) Init(service core.IService, module core.IModule, comp cor
}
func (this *modelMail) MailQueryUserMail(uId string) (mail []*pb.DBMailData, err error) {
if _data, err := this.DB.Find(comm.TableMail, bson.M{"uid": uId}, options.Find().SetSort(bson.M{"createtime": -1})); err == nil {
var index int32
if _data, err := this.DB.Find(comm.TableMail, bson.M{"uid": uId}); err == nil {
for _data.Next(context.TODO()) {
index++
temp := &pb.DBMailData{}
if err = _data.Decode(temp); err == nil {
if index > comm.MaxMailCount { // 删除超标的邮件
this.DB.DeleteOne(comm.TableMail, bson.M{"_id": temp.ObjId}, options.Delete())
continue
}
mail = append(mail, temp)
}
}
@ -90,6 +95,29 @@ func (this *modelMail) MailGetMailAttachmentState(objId string) (*pb.DBMailData,
return nd, err
}
func (this *modelMail) GetMailCountByUid(uid string) (int32, error) {
var count int64
count, err := this.DB.CountDocuments(comm.TableMail, bson.M{"uid": uid})
return int32(count), err
}
// 删除超过最大邮件数量的邮件
func (this *modelMail) DelOtherMail(uid string) {
if _data, err := this.DB.Find(comm.TableMail, bson.M{"uid": uid}); err == nil {
var index int32
for _data.Next(context.TODO()) {
index++
temp := &pb.DBMailData{}
if err = _data.Decode(temp); err == nil {
if index >= comm.MaxMailCount { // 删除超标的邮件
this.DB.DeleteOne(comm.TableMail, bson.M{"_id": temp.ObjId}, options.Delete())
continue
}
}
}
}
}
// 更新领取附件状态
func (this *modelMail) MailUpdateMailAttachmentState(objId string) bool {

View File

@ -187,3 +187,12 @@ func (this *Mail) SendMailByCid(session comm.IUserSession, cid string, res []*pb
return true
}
// 创建邮件之前检测邮件是否达到上限
func (this *Mail) CheckMaxMail(session comm.IUserSession) bool {
count, err := this.modelMail.GetMailCountByUid(session.GetUserId())
if err == nil && count >= comm.MaxMailCount {
this.modelMail.DelOtherMail(session.GetUserId())
}
return true
}

View File

@ -41,7 +41,7 @@ func (this *apiComp) Activate(session comm.IUserSession, req *pb.PagodaActivateR
season.Uid = session.GetUserId()
season.PagodaId = 0 // 初始数据0层
if conn, err := db.Cross(); err == nil {
rst := conn.Mgo.FindOne(comm.TableServerData, bson.M{})
rst := conn.Mgo.FindOne(comm.TableSeasonData, bson.M{})
server := &pb.DBServerData{}
rst.Decode(server)
season.Type = server.SeasonType

View File

@ -242,7 +242,7 @@ func (this *Pagoda) ModifySeasonPagodaFloor(session comm.IUserSession, level int
list.Uid = session.GetUserId()
list.PagodaId = level
if conn, err := db.Cross(); err == nil {
rst := conn.Mgo.FindOne(comm.TableServerData, bson.M{})
rst := conn.Mgo.FindOne(comm.TableSeasonData, bson.M{})
server := &pb.DBServerData{}
rst.Decode(server)
list.Type = server.SeasonType

View File

@ -279,13 +279,14 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T
for _, v := range condis {
conf, err := this.configure.getRtaskTypeById(v.condId)
if err != nil {
this.Errorln(err)
log.Errorf("get condId conf err:%v", err)
code = pb.ErrorCode_RtaskCondiNoFound
return
}
if v.update != nil {
if err := v.update(uid, conf, params...); err != nil {
log.Errorf("update task:%v", err)
code = pb.ErrorCode_DBError
}
}

View File

@ -9,7 +9,7 @@ import (
// 公会BOSS 推荐
func (this *apiComp) RecommendCheck(session comm.IUserSession, req *pb.SociatyRecommendReq) (code pb.ErrorCode) {
if req.Cate != 1 || req.Cate != 2 {
if req.Cate != 1 && req.Cate != 2 {
code = pb.ErrorCode_ReqParameterError
}
return

View File

@ -71,9 +71,9 @@ func (this *SeasonPagoda) Start() (err error) {
conn, err := db.Cross()
if err == nil {
//this.DbTest()
model := db.NewDBModel(comm.TableServerData, 0, conn)
model := db.NewDBModel(comm.TableSeasonData, 0, conn)
_len, err1 := model.DB.CountDocuments(comm.TableServerData, bson.M{})
_len, err1 := model.DB.CountDocuments(comm.TableSeasonData, bson.M{})
if err1 == nil && _len == 0 {
fmt.Printf("%v,%v", _len, err1)
server := &pb.DBServerData{
@ -89,7 +89,7 @@ func (this *SeasonPagoda) Start() (err error) {
server.SeasonType = conf.DisposableLoop[0]
}
model.DB.InsertOne(comm.TableServerData, server)
model.DB.InsertOne(comm.TableSeasonData, server)
}
}
return
@ -129,7 +129,7 @@ func (this *SeasonPagoda) TimerSeasonOver() {
this.module.Debugf("TimerSeasonOver:%d", configure.Now().Unix())
if db.IsCross() {
if conn, err := db.Cross(); err == nil {
if rst := conn.Mgo.FindOne(comm.TableServerData, bson.M{}); rst != nil {
if rst := conn.Mgo.FindOne(comm.TableSeasonData, bson.M{}); rst != nil {
serverData := &pb.DBServerData{}
rst.Decode(serverData)
conf := this.GetSeasonLoop(comm.SeasonType) // 获取赛季塔重置配置
@ -151,7 +151,7 @@ func (this *SeasonPagoda) TimerSeasonOver() {
}
serverData.SeasonType = conf.FixedLoop[int(serverData.FixedLoop)-1]
}
this.DB.UpdateOne(comm.TableServerData, bson.M{}, serverData)
this.DB.UpdateOne(comm.TableSeasonData, bson.M{}, serverData)
fmt.Printf("%v", serverData)
}
}
@ -174,7 +174,7 @@ func (this *SeasonPagoda) TimerSeasonStar() {
if !db.IsCross() { // 删除本服的赛季塔数据
conn, err := db.Cross() // 获取跨服的链接对象
if err == nil {
model := db.NewDBModel(comm.TableServerData, 0, conn)
model := db.NewDBModel(comm.TableSeasonData, 0, conn)
model.DB.DeleteMany(comm.TableSeasonPagoda, bson.M{}, options.Delete())
model.DB.DeleteMany(comm.TableSeasonRecord, bson.M{}, options.Delete())
for pos := 0; pos < comm.MaxRankNum; pos++ {