Skip to content

Instantly share code, notes, and snippets.

@bradleyg
Created November 3, 2014 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradleyg/5cd556675ec7977f69ea to your computer and use it in GitHub Desktop.
Save bradleyg/5cd556675ec7977f69ea to your computer and use it in GitHub Desktop.
func LongPoll(w http.ResponseWriter, quit chan struct{}) {
ticker := time.NewTicker(25 * time.Second)
for {
select {
case <-ticker.C:
log.Println("writing")
w.Write([]byte(" "))
w.(http.Flusher).Flush()
case <-quit:
log.Println("stopped")
ticker.Stop()
return
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment