This commit is contained in:
meixiongfeng 2023-01-30 17:27:19 +08:00
commit ec3610dc6e
3 changed files with 23 additions and 3 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))