making tests pass, but introduced a bug in the actual ui

pull/8/head
Stephen Searles 7 years ago
parent 07daa5e160
commit 99e794ac00
  1. 2
      caddyhugo.go
  2. 14
      deltas.go

@ -96,5 +96,5 @@ func (ch *CaddyHugo) TmplData(r *http.Request, docref *docref) interface{} {
ch.HugoSites.Fs.Destination = afero.NewMemMapFs() ch.HugoSites.Fs.Destination = afero.NewMemMapFs()
ch.Build() ch.Build()
} }
return tmplData{ch.Site, r, ch, doc, docref} return &tmplData{ch.Site, r, ch, doc, docref}
} }

@ -51,6 +51,8 @@ func (ch *CaddyHugo) DeltaWebsocket(w http.ResponseWriter, r *http.Request) (int
return http.StatusBadRequest, err return http.StatusBadRequest, err
} }
conn.SetReadDeadline(time.Time{})
doc, err := ch.doc(r) doc, err := ch.doc(r)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
@ -115,7 +117,7 @@ func (ch *CaddyHugo) handleConn(conn DeltaConn, doc *docref) (int, error) {
err := conn.ReadJSON(&message) err := conn.ReadJSON(&message)
if err != nil { if err != nil {
errCh <- err errCh <- fmt.Errorf("error reading message from client conn: %v", err)
return return
} }
ch.ObserveLTime(message.LTime) ch.ObserveLTime(message.LTime)
@ -127,7 +129,7 @@ func (ch *CaddyHugo) handleConn(conn DeltaConn, doc *docref) (int, error) {
err = client.PushDeltas(message.Deltas...) err = client.PushDeltas(message.Deltas...)
if err != nil { if err != nil {
errCh <- err errCh <- fmt.Errorf("error pushing deltas into document: %v", err)
return return
} }
@ -141,9 +143,17 @@ func (ch *CaddyHugo) handleConn(conn DeltaConn, doc *docref) (int, error) {
}() }()
for { for {
select {
case err := <-errCh:
fmt.Println(err)
return 500, err
default:
}
select { select {
case <-timer.C: case <-timer.C:
conn.WriteJSON(ch.Message()) conn.WriteJSON(ch.Message())
resetTimer(idlePing)
case <-readMessagesCh: case <-readMessagesCh:
resetTimer(idlePingShort) resetTimer(idlePingShort)
case <-wroteMessagesCh: case <-wroteMessagesCh:

Loading…
Cancel
Save