工具心跳处理
This commit is contained in:
parent
795e534105
commit
3a6de14d83
@ -4,5 +4,5 @@ Website = "http://legu.cc"
|
||||
Icon = "app.png"
|
||||
Name = "RobotGUI"
|
||||
ID = "cc.legu.app"
|
||||
Version = "1.2.13"
|
||||
Build = 43
|
||||
Version = "1.2.15"
|
||||
Build = 49
|
||||
|
@ -11,14 +11,15 @@ import (
|
||||
)
|
||||
|
||||
func BuildSecStr(sid, account string) string {
|
||||
now := time.Now().Unix()
|
||||
jsonByte, _ := jsoniter.Marshal(&model.LoginParam{
|
||||
Account: account,
|
||||
ServerId: sid,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
TimeStamp: now,
|
||||
})
|
||||
jsonBase64 := utils.Base64Encode(jsonByte)
|
||||
// log.Printf("client base64:%s", jsonBase64)
|
||||
clientMd5key := util.Md5(jsonBase64)
|
||||
// log.Printf("client md5:%s", clientMd5key)
|
||||
// logrus.Debugf("client md5:%s", clientMd5key)
|
||||
return fmt.Sprintf("CE:%s%s", clientMd5key, jsonBase64)
|
||||
}
|
||||
|
@ -54,18 +54,6 @@ func (c *ConnServiceImpl) WsConnect(wsUrl string) error {
|
||||
return err
|
||||
}
|
||||
c.ws = ws
|
||||
|
||||
go func() {
|
||||
timer := time.NewTimer(2 * time.Second)
|
||||
for {
|
||||
timer.Reset(2 * time.Second)
|
||||
<-timer.C
|
||||
if err := c.ws.WriteMessage(websocket.PingMessage, []byte{}); err != nil {
|
||||
c.obs.Notify(observer.EVENT_PING, err)
|
||||
break
|
||||
}
|
||||
}
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -80,6 +68,11 @@ func (c *ConnServiceImpl) HttpConnect(url string) ([]byte, error) {
|
||||
|
||||
// listener push
|
||||
func (c *ConnServiceImpl) ListenerPush() {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
logrus.Errorf("listenerPush err: %v", err)
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
for {
|
||||
// time.Sleep(time.Millisecond * 200)
|
||||
|
@ -62,7 +62,7 @@ func (p *PttServiceImpl) SendToClient(mainType, subType string, rsp proto.Messag
|
||||
msg.Sec = common.BuildSecStr(p.user.DbUser.Sid, p.user.DbUser.Binduid)
|
||||
now := time.Now()
|
||||
if err = p.connService.SendMsg(msg, rsp); err != nil {
|
||||
logrus.WithField("err", err).Error(err)
|
||||
logrus.WithField("发送错误:", err).Error(err)
|
||||
return err
|
||||
}
|
||||
p.obs.Notify(observer.EVENT_RST, now)
|
||||
@ -88,11 +88,18 @@ func (p *PttServiceImpl) Login(sid, account string) (code pb.ErrorCode) {
|
||||
}
|
||||
|
||||
func (p *PttServiceImpl) Ping(sid, account string) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
logrus.Errorf("Ping sid:%v account:%v err:%v", sid, account, err)
|
||||
}
|
||||
}()
|
||||
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 {
|
||||
p.obs.Notify(observer.EVENT_PING, err)
|
||||
return
|
||||
}
|
||||
// logrus.Debug("Ping")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -89,12 +89,6 @@ func (app *appMonitor) monitorlistener() {
|
||||
OnNotify: func(d interface{}, args ...interface{}) {
|
||||
app.id++
|
||||
data := d.(*model.PushModel)
|
||||
|
||||
//大于50条时清除一次
|
||||
// if len(app.monitorList.CachedList.Items) >= 50 {
|
||||
// app.monitorList.Reset()
|
||||
// }
|
||||
|
||||
protocol := fmt.Sprintf("【%s.%s】", data.Msg.MainType, data.Msg.SubType)
|
||||
app.monitorList.AddItem(common.Item{
|
||||
Text: fmt.Sprintf("%d - %-50v %-50v %-50v",
|
||||
@ -103,7 +97,6 @@ func (app *appMonitor) monitorlistener() {
|
||||
})
|
||||
|
||||
app.monitorList.ItemList.ScrollToBottom()
|
||||
// common.ShowCanvasTip("收到新的数据推送,请打开[推送]页面")//非常多调式时会导致系统崩溃
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -313,6 +313,7 @@ func (ui *MainWindowImpl) createLoginWin(sid, sname string) {
|
||||
return
|
||||
}
|
||||
|
||||
//ping
|
||||
go func() {
|
||||
timer := time.NewTimer(10 * time.Second)
|
||||
for {
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
@ -32,6 +33,7 @@ type HeroZhaomuView struct {
|
||||
exportFolder *widget.Entry
|
||||
resultCountLbl *widget.Label
|
||||
resultCount int
|
||||
f *os.File
|
||||
}
|
||||
|
||||
// 打开目录
|
||||
@ -136,9 +138,18 @@ func (this *HeroZhaomuView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
||||
common.ShowTip("请设置导出目录")
|
||||
return
|
||||
}
|
||||
filePath := filepath.Join(this.exportFolder.Text, "result.txt")
|
||||
var err error
|
||||
this.f, err = os.OpenFile(filePath, os.O_CREATE|os.O_APPEND|os.O_RDWR, os.ModeAppend|os.ModePerm)
|
||||
if err != nil {
|
||||
logrus.Error(err.Error())
|
||||
return
|
||||
}
|
||||
defer this.f.Close()
|
||||
|
||||
for i := 0; i < cast.ToInt(loopCount.Text); i++ {
|
||||
choukaBtnFunc()
|
||||
time.Sleep(time.Millisecond * 100)
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,15 +200,8 @@ func (this *HeroZhaomuView) resListener() {
|
||||
logrus.Error("unmarshal err")
|
||||
return
|
||||
}
|
||||
filePath := filepath.Join(this.exportFolder.Text, "result.txt")
|
||||
f, err := os.OpenFile(filePath, os.O_CREATE|os.O_APPEND|os.O_RDWR, os.ModeAppend|os.ModePerm)
|
||||
if err != nil {
|
||||
logrus.Error(err.Error())
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
write := bufio.NewWriter(f)
|
||||
write := bufio.NewWriter(this.f)
|
||||
for _, v := range rsp.Data {
|
||||
for _, o := range v.Atno {
|
||||
if o.A == "hero" && o.O != "" && o.T != "" {
|
||||
|
Loading…
Reference in New Issue
Block a user