Skip to content

Commit

Permalink
use Request.Context().Done() instead (gin-gonic#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
Glonee authored Apr 22, 2022
1 parent 6c5e6ca commit be3d1f7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion realtime-chat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"math/rand"
"net/http"

"github.com/gin-gonic/gin"
)

Expand All @@ -28,7 +29,7 @@ func stream(c *gin.Context) {
listener := roomManager.OpenListener(roomid)
defer roomManager.CloseListener(roomid, listener)

clientGone := c.Writer.CloseNotify()
clientGone := c.Request.Context().Done()
c.Stream(func(w io.Writer) bool {
select {
case <-clientGone:
Expand Down

0 comments on commit be3d1f7

Please sign in to comment.