This commit is contained in:
laodaming 2023-07-25 18:34:56 +08:00
parent 932ee1a578
commit 222b9ec155
2 changed files with 19 additions and 17 deletions

View File

@ -125,6 +125,8 @@ func (w *wsConnectItem) heartbeat() {
case <-w.closeChan:
return
default:
}
//发送心跳信息
b, _ := json.Marshal(rsp)
if err := w.conn.WriteMessage(websocket.TextMessage, b); err != nil {
@ -134,7 +136,6 @@ func (w *wsConnectItem) heartbeat() {
}
}
}
}
// 关闭连接
func (w *wsConnectItem) close() {
@ -170,6 +171,8 @@ func (w *wsConnectItem) readLoop() {
case <-w.closeChan: //如果关闭了
return
default:
}
_, data, err := w.conn.ReadMessage()
if err != nil {
logx.Error("接受信息错误:", err)
@ -181,7 +184,6 @@ func (w *wsConnectItem) readLoop() {
w.inChan <- data
}
}
}
// 把收到的消息发往不同的地方处理
func (w *wsConnectItem) sendLoop() {

View File

@ -36,7 +36,7 @@ func RenderNotifyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
})
return
}
if time.Now().Unix()-120 > req.Time || req.Time > time.Now().Unix() {
if time.Now().Unix()-120 > req.Time /*|| req.Time > time.Now().Unix() */ {
httpx.OkJsonCtx(r.Context(), w, basic.Response{
Code: basic.CodeRequestParamsErr.Code,
Message: "invalid param,time is expired",