fix write when heartbeat #14
This commit is contained in:
@@ -3,6 +3,7 @@ package api
|
|||||||
import (
|
import (
|
||||||
requstform "Gwen/http/request/api"
|
requstform "Gwen/http/request/api"
|
||||||
"Gwen/http/response"
|
"Gwen/http/response"
|
||||||
|
"Gwen/model"
|
||||||
"Gwen/service"
|
"Gwen/service"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -53,7 +54,11 @@ func (i *Index) Heartbeat(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, gin.H{})
|
c.JSON(http.StatusOK, gin.H{})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
peer.LastOnlineTime = time.Now().Unix()
|
//如果在一分钟以内则不更新
|
||||||
service.AllService.PeerService.Update(peer)
|
if time.Now().Unix()-peer.LastOnlineTime > 60 {
|
||||||
|
peer.LastOnlineTime = time.Now().Unix()
|
||||||
|
upp := &model.Peer{RowId: peer.RowId, LastOnlineTime: peer.LastOnlineTime}
|
||||||
|
service.AllService.PeerService.Update(upp)
|
||||||
|
}
|
||||||
c.JSON(http.StatusOK, gin.H{})
|
c.JSON(http.StatusOK, gin.H{})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user