Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
cc0d94ea6c
@ -104,9 +104,9 @@ func (c *ConnServiceImpl) ListenerPush() {
|
|||||||
DataTime: time.Now().Format(time.RFC3339),
|
DataTime: time.Now().Format(time.RFC3339),
|
||||||
Msg: msg,
|
Msg: msg,
|
||||||
}
|
}
|
||||||
logrus.WithFields(
|
// logrus.WithFields(
|
||||||
logrus.Fields{"MainType": msg.MainType, "SubType": msg.SubType},
|
// logrus.Fields{"MainType": msg.MainType, "SubType": msg.SubType},
|
||||||
).Debug(methodName)
|
// ).Debug(methodName)
|
||||||
|
|
||||||
renderRespPanel := func(p *model.PushModel) {
|
renderRespPanel := func(p *model.PushModel) {
|
||||||
c.obs.Notify(observer.EVENT_REQ_RSP, p.Msg)
|
c.obs.Notify(observer.EVENT_REQ_RSP, p.Msg)
|
||||||
|
@ -22,6 +22,8 @@ type PttService interface {
|
|||||||
GetUser() *UserInfo
|
GetUser() *UserInfo
|
||||||
SetUser(dbUser *pb.DBUser, dbUserExpand *pb.DBUserExpand)
|
SetUser(dbUser *pb.DBUser, dbUserExpand *pb.DBUserExpand)
|
||||||
SendToClient(mainType, subType string, rsp proto.Message) error
|
SendToClient(mainType, subType string, rsp proto.Message) error
|
||||||
|
|
||||||
|
Ping(sid, account string)
|
||||||
}
|
}
|
||||||
|
|
||||||
type PttServiceImpl struct {
|
type PttServiceImpl struct {
|
||||||
@ -85,6 +87,15 @@ func (p *PttServiceImpl) Login(sid, account string) (code pb.ErrorCode) {
|
|||||||
return
|
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
|
// create role
|
||||||
func (p *PttServiceImpl) CreateRole(nickName string, gender, figure int32) (code pb.ErrorCode) {
|
func (p *PttServiceImpl) CreateRole(nickName string, gender, figure int32) (code pb.ErrorCode) {
|
||||||
head := &pb.UserMessage{MainType: string(comm.ModuleUser), SubType: user.UserSubTypeCreate}
|
head := &pb.UserMessage{MainType: string(comm.ModuleUser), SubType: user.UserSubTypeCreate}
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"go_dreamfactory/modules/user"
|
"go_dreamfactory/modules/user"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/container"
|
"fyne.io/fyne/v2/container"
|
||||||
@ -312,6 +313,14 @@ func (ui *MainWindowImpl) createLoginWin(sid, sname string) {
|
|||||||
return
|
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
|
// reset main window title
|
||||||
subTitle := fmt.Sprintf("%s[%s]", sname, sid)
|
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))
|
ui.w.SetTitle(fmt.Sprintf(common.APP_WIN_TITLE, subTitle, ui.app.Metadata().Version, ui.app.Metadata().Build, common.APP_NAME))
|
||||||
|
@ -163,7 +163,7 @@ const (
|
|||||||
|
|
||||||
TableCrossSession = "crosssession"
|
TableCrossSession = "crosssession"
|
||||||
|
|
||||||
TableServerData = "serverdata" // 跨服服务器相关数据
|
TableSeasonData = "seasondata" // 跨服服务器相关数据
|
||||||
|
|
||||||
///竞技场
|
///竞技场
|
||||||
TableArena = "arena"
|
TableArena = "arena"
|
||||||
@ -590,7 +590,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
MaxRankList = 50 // 赛季塔 排行榜人数
|
MaxRankList = 50 // 赛季塔 排行榜人数
|
||||||
|
MaxMailCount = 50 // 当前邮件最大数量
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -71,7 +71,7 @@ locp:
|
|||||||
go this.Close()
|
go this.Close()
|
||||||
break locp
|
break locp
|
||||||
}
|
}
|
||||||
this.wsConn.SetReadDeadline(time.Now().Add(time.Second * 30))
|
|
||||||
if err = proto.Unmarshal(data, msg); err != nil {
|
if err = proto.Unmarshal(data, msg); err != nil {
|
||||||
this.gateway.Errorf("agent:%s uId:%s Unmarshal err:%v", this.sessionId, this.uId, err)
|
this.gateway.Errorf("agent:%s uId:%s Unmarshal err:%v", this.sessionId, this.uId, err)
|
||||||
go this.Close()
|
go this.Close()
|
||||||
@ -89,9 +89,11 @@ locp:
|
|||||||
SubType: "heartbeat",
|
SubType: "heartbeat",
|
||||||
Data: data,
|
Data: data,
|
||||||
})
|
})
|
||||||
|
//this.wsConn.SetReadDeadline(time.Now().Add(time.Second * 30))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := this.messageDistribution(msg); err != nil {
|
if err := this.messageDistribution(msg); err != nil {
|
||||||
|
this.gateway.Errorf("messageDistribution err:%v", err)
|
||||||
go this.Close()
|
go this.Close()
|
||||||
break locp
|
break locp
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ func (this *apiComp) Fusion(session comm.IUserSession, req *pb.HeroFusionReq) (c
|
|||||||
if c != pb.ErrorCode_Success || _obj.SameCount < v {
|
if c != pb.ErrorCode_Success || _obj.SameCount < v {
|
||||||
code = pb.ErrorCode_HeroNoExist
|
code = pb.ErrorCode_HeroNoExist
|
||||||
}
|
}
|
||||||
mapHero[_obj.HeroID] = v
|
mapHero[_obj.HeroID] += v
|
||||||
_costMaphero[k] = _obj
|
_costMaphero[k] = _obj
|
||||||
}
|
}
|
||||||
for _, v := range conf.Pointhero {
|
for _, v := range conf.Pointhero {
|
||||||
|
@ -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) {
|
func (this *modelMail) MailQueryUserMail(uId string) (mail []*pb.DBMailData, err error) {
|
||||||
|
var index int32
|
||||||
if _data, err := this.DB.Find(comm.TableMail, bson.M{"uid": uId}, options.Find().SetSort(bson.M{"createtime": -1})); err == nil {
|
if _data, err := this.DB.Find(comm.TableMail, bson.M{"uid": uId}); err == nil {
|
||||||
for _data.Next(context.TODO()) {
|
for _data.Next(context.TODO()) {
|
||||||
|
index++
|
||||||
temp := &pb.DBMailData{}
|
temp := &pb.DBMailData{}
|
||||||
if err = _data.Decode(temp); err == nil {
|
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)
|
mail = append(mail, temp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,6 +95,29 @@ func (this *modelMail) MailGetMailAttachmentState(objId string) (*pb.DBMailData,
|
|||||||
|
|
||||||
return nd, err
|
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 {
|
func (this *modelMail) MailUpdateMailAttachmentState(objId string) bool {
|
||||||
|
@ -187,3 +187,12 @@ func (this *Mail) SendMailByCid(session comm.IUserSession, cid string, res []*pb
|
|||||||
|
|
||||||
return true
|
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
|
||||||
|
}
|
||||||
|
@ -41,7 +41,7 @@ func (this *apiComp) Activate(session comm.IUserSession, req *pb.PagodaActivateR
|
|||||||
season.Uid = session.GetUserId()
|
season.Uid = session.GetUserId()
|
||||||
season.PagodaId = 0 // 初始数据0层
|
season.PagodaId = 0 // 初始数据0层
|
||||||
if conn, err := db.Cross(); err == nil {
|
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{}
|
server := &pb.DBServerData{}
|
||||||
rst.Decode(server)
|
rst.Decode(server)
|
||||||
season.Type = server.SeasonType
|
season.Type = server.SeasonType
|
||||||
|
@ -242,7 +242,7 @@ func (this *Pagoda) ModifySeasonPagodaFloor(session comm.IUserSession, level int
|
|||||||
list.Uid = session.GetUserId()
|
list.Uid = session.GetUserId()
|
||||||
list.PagodaId = level
|
list.PagodaId = level
|
||||||
if conn, err := db.Cross(); err == nil {
|
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{}
|
server := &pb.DBServerData{}
|
||||||
rst.Decode(server)
|
rst.Decode(server)
|
||||||
list.Type = server.SeasonType
|
list.Type = server.SeasonType
|
||||||
|
@ -279,13 +279,14 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T
|
|||||||
for _, v := range condis {
|
for _, v := range condis {
|
||||||
conf, err := this.configure.getRtaskTypeById(v.condId)
|
conf, err := this.configure.getRtaskTypeById(v.condId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.Errorln(err)
|
log.Errorf("get condId conf err:%v", err)
|
||||||
code = pb.ErrorCode_RtaskCondiNoFound
|
code = pb.ErrorCode_RtaskCondiNoFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.update != nil {
|
if v.update != nil {
|
||||||
if err := v.update(uid, conf, params...); err != nil {
|
if err := v.update(uid, conf, params...); err != nil {
|
||||||
|
log.Errorf("update task:%v", err)
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
// 公会BOSS 推荐
|
// 公会BOSS 推荐
|
||||||
func (this *apiComp) RecommendCheck(session comm.IUserSession, req *pb.SociatyRecommendReq) (code pb.ErrorCode) {
|
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
|
code = pb.ErrorCode_ReqParameterError
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -71,9 +71,9 @@ func (this *SeasonPagoda) Start() (err error) {
|
|||||||
conn, err := db.Cross()
|
conn, err := db.Cross()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
//this.DbTest()
|
//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 {
|
if err1 == nil && _len == 0 {
|
||||||
fmt.Printf("%v,%v", _len, err1)
|
fmt.Printf("%v,%v", _len, err1)
|
||||||
server := &pb.DBServerData{
|
server := &pb.DBServerData{
|
||||||
@ -89,7 +89,7 @@ func (this *SeasonPagoda) Start() (err error) {
|
|||||||
server.SeasonType = conf.DisposableLoop[0]
|
server.SeasonType = conf.DisposableLoop[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
model.DB.InsertOne(comm.TableServerData, server)
|
model.DB.InsertOne(comm.TableSeasonData, server)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -129,7 +129,7 @@ func (this *SeasonPagoda) TimerSeasonOver() {
|
|||||||
this.module.Debugf("TimerSeasonOver:%d", configure.Now().Unix())
|
this.module.Debugf("TimerSeasonOver:%d", configure.Now().Unix())
|
||||||
if db.IsCross() {
|
if db.IsCross() {
|
||||||
if conn, err := db.Cross(); err == nil {
|
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{}
|
serverData := &pb.DBServerData{}
|
||||||
rst.Decode(serverData)
|
rst.Decode(serverData)
|
||||||
conf := this.GetSeasonLoop(comm.SeasonType) // 获取赛季塔重置配置
|
conf := this.GetSeasonLoop(comm.SeasonType) // 获取赛季塔重置配置
|
||||||
@ -151,7 +151,7 @@ func (this *SeasonPagoda) TimerSeasonOver() {
|
|||||||
}
|
}
|
||||||
serverData.SeasonType = conf.FixedLoop[int(serverData.FixedLoop)-1]
|
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)
|
fmt.Printf("%v", serverData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,7 +174,7 @@ func (this *SeasonPagoda) TimerSeasonStar() {
|
|||||||
if !db.IsCross() { // 删除本服的赛季塔数据
|
if !db.IsCross() { // 删除本服的赛季塔数据
|
||||||
conn, err := db.Cross() // 获取跨服的链接对象
|
conn, err := db.Cross() // 获取跨服的链接对象
|
||||||
if err == nil {
|
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.TableSeasonPagoda, bson.M{}, options.Delete())
|
||||||
model.DB.DeleteMany(comm.TableSeasonRecord, bson.M{}, options.Delete())
|
model.DB.DeleteMany(comm.TableSeasonRecord, bson.M{}, options.Delete())
|
||||||
for pos := 0; pos < comm.MaxRankNum; pos++ {
|
for pos := 0; pos < comm.MaxRankNum; pos++ {
|
||||||
|
Loading…
Reference in New Issue
Block a user