Permalink
Browse files

Merge pull request #31 from dunglas/flush-missed

Flush as soon as a missed event is retrieved
  • Loading branch information...
dunglas committed Nov 22, 2018
2 parents 49d7edf + a470da2 commit 6037c33944b60f74b0ffa7305a741c53528391a7
Showing with 2 additions and 1 deletion.
  1. +2 −1 hub/subscribe.go
@@ -46,7 +46,6 @@ func (h *Hub) SubscribeHandler(w http.ResponseWriter, r *http.Request) {
if subscriber.LastEventID != "" {
h.sendMissedEvents(w, r, subscriber)
f.Flush()
}
// Create a new channel, over which the hub can send can send updates to this subscriber.
@@ -111,8 +110,10 @@ func retrieveLastEventID(r *http.Request) string {
}
func (h *Hub) sendMissedEvents(w http.ResponseWriter, r *http.Request, s *Subscriber) {
f := w.(http.Flusher)
if err := h.history.FindFor(s, func(u *Update) bool {
fmt.Fprint(w, u.String())
f.Flush()
log.WithFields(log.Fields{
"event_id": u.ID,
"last_event_id": s.LastEventID,

0 comments on commit 6037c33

Please sign in to comment.