Skip to content

Commit 897f03e

Browse files
committed
添加链接维持
1 parent f46a481 commit 897f03e

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

service/msap/msap.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,29 @@ func sync(c *gin.Context) {
216216
return
217217
}
218218

219+
go func() {
220+
for {
221+
time.Sleep(30 * time.Second)
222+
select {
223+
case <-c.Request.Context().Done():
224+
return
225+
default:
226+
jsonData, err := json.Marshal(gin.H{
227+
"result": gin.H{
228+
"code": errorcode.Success,
229+
"msg": "",
230+
},
231+
"msg": []gin.H{},
232+
})
233+
fmt.Fprintf(w, "data: %s\n\n", jsonData)
234+
flusher.Flush()
235+
if err != nil {
236+
return
237+
}
238+
}
239+
}
240+
}()
241+
219242
// 循环从gRPC流中接收消息并发送到SSE客户端
220243
for {
221244
select {

0 commit comments

Comments
 (0)