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

Loading…
Cancel
Save