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,13 +125,14 @@ func (w *wsConnectItem) heartbeat() {
case <-w.closeChan:
return
default:
//发送心跳信息
b, _ := json.Marshal(rsp)
if err := w.conn.WriteMessage(websocket.TextMessage, b); err != nil {
logx.Error("发送心跳信息异常,关闭连接:", w.flag, err)
w.close()
return
}
}
//发送心跳信息
b, _ := json.Marshal(rsp)
if err := w.conn.WriteMessage(websocket.TextMessage, b); err != nil {
logx.Error("发送心跳信息异常,关闭连接:", w.flag, err)
w.close()
return
}
}
}
@ -170,16 +171,17 @@ func (w *wsConnectItem) readLoop() {
case <-w.closeChan: //如果关闭了
return
default:
_, data, err := w.conn.ReadMessage()
if err != nil {
logx.Error("接受信息错误:", err)
//关闭连接
w.close()
return
}
//消息传入缓冲通道
w.inChan <- data
}
_, data, err := w.conn.ReadMessage()
if err != nil {
logx.Error("接受信息错误:", err)
//关闭连接
w.close()
return
}
//消息传入缓冲通道
w.inChan <- data
}
}

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",