From 319916a777780df40675c7e22d2520f524612330 Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期一, 11 十一月 2019 16:44:10 +0800 Subject: [PATCH] fix picDate to minisec --- server.go | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-) diff --git a/server.go b/server.go index 2a17bfd..a3298d9 100644 --- a/server.go +++ b/server.go @@ -7,9 +7,9 @@ "strconv" "time" - "github.com/long/test/esutil" - "github.com/long/config" - log "github.com/long/test/log" + "andriodServer/esutil" + "andriodServer/extend/config" + log "andriodServer/log" ) var addr = flag.String("addr", "0.0.0.0", "The address to listen to") @@ -67,15 +67,17 @@ }(conn, ech) - tick := time.NewTicker(10 * time.Second) - + tick := time.NewTicker(3 * time.Second) + lastTime := time.Now() for { select { case <-tick.C: - if !handleMessage(conn, connArr){ + curTime := time.Now() + if !handleMessage(conn, connArr, lastTime, curTime){ conn.Close() return } + lastTime = curTime case err := <-ech: log.Log.Infoln(err, "remoteAddr ", remoteAddr, " close") conn.Close() @@ -86,8 +88,8 @@ log.Log.Infoln("Client at " + remoteAddr + " disconnected.") } -func handleMessage(conn net.Conn, connArr []net.Conn) bool { - jsonstring := esutil.PostAction(*sec, *Eurl, *Picurl, *IsHub, *Size) +func handleMessage(conn net.Conn, connArr []net.Conn,lastT time.Time, curTime time.Time) bool { + jsonstring := esutil.PostAction(*sec, *Eurl, *Picurl, *IsHub, *Size, lastT, curTime) if jsonstring == nil { log.Log.Infoln("the data is nil,remoteArr:",conn.RemoteAddr()) if _, err := conn.Write([]byte("\000"));err !=nil { -- Gitblit v1.8.0