mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-07-05 03:26:26 +00:00
Merge pull request #2174 from bradrydzewski/master
send SSE comments to keep connection alive
This commit is contained in:
commit
f43e1e6c33
@ -224,6 +224,10 @@ func EventStreamSSE(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ping the client
|
||||||
|
io.WriteString(rw, ": ping\n\n")
|
||||||
|
flusher.Flush()
|
||||||
|
|
||||||
logrus.Debugf("user feed: connection opened")
|
logrus.Debugf("user feed: connection opened")
|
||||||
|
|
||||||
user := session.User(c)
|
user := session.User(c)
|
||||||
@ -269,6 +273,9 @@ func EventStreamSSE(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
|
case <-time.After(time.Second * 30):
|
||||||
|
io.WriteString(rw, ": ping\n\n")
|
||||||
|
flusher.Flush()
|
||||||
case buf, ok := <-eventc:
|
case buf, ok := <-eventc:
|
||||||
if ok {
|
if ok {
|
||||||
io.WriteString(rw, "data: ")
|
io.WriteString(rw, "data: ")
|
||||||
@ -294,6 +301,9 @@ func LogStreamSSE(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
io.WriteString(rw, ": ping\n\n")
|
||||||
|
flusher.Flush()
|
||||||
|
|
||||||
// repo := session.Repo(c)
|
// repo := session.Repo(c)
|
||||||
//
|
//
|
||||||
// // parse the build number and job sequence number from
|
// // parse the build number and job sequence number from
|
||||||
@ -388,6 +398,9 @@ func LogStreamSSE(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
|
case <-time.After(time.Second * 30):
|
||||||
|
io.WriteString(rw, ": ping\n\n")
|
||||||
|
flusher.Flush()
|
||||||
case buf, ok := <-logc:
|
case buf, ok := <-logc:
|
||||||
if ok {
|
if ok {
|
||||||
if id > last {
|
if id > last {
|
||||||
|
Loading…
Reference in New Issue
Block a user