Send empty diffs as ACKs on both client/server
On receiving ACK, update "current server state".
This commit is contained in:
parent
76074e5b5c
commit
8850552838
1 changed files with 5 additions and 5 deletions
|
@ -22,8 +22,10 @@
|
||||||
(let [new-states (sync/apply-diff states* (:diff msg))
|
(let [new-states (sync/apply-diff states* (:diff msg))
|
||||||
new-shadow (diff/patch-state shadow (:diff msg))
|
new-shadow (diff/patch-state shadow (:diff msg))
|
||||||
{:keys [diff hash]} (sync/diff-states (sync/get-current-state new-states) new-shadow)]
|
{:keys [diff hash]} (sync/diff-states (sync/get-current-state new-states) new-shadow)]
|
||||||
(reset! states new-states)
|
(when-not (= states* new-states)
|
||||||
(when-not client? (>! out (message/diff-msg diff hash))) ;; HERE
|
(reset! states new-states))
|
||||||
|
(when-not (sync/empty-diff? diff)
|
||||||
|
(>! out (message/diff-msg diff hash)))
|
||||||
(recur new-shadow))
|
(recur new-shadow))
|
||||||
(if client?
|
(if client?
|
||||||
(do (>! out message/full-sync-request)
|
(do (>! out message/full-sync-request)
|
||||||
|
@ -47,9 +49,7 @@
|
||||||
(let [{:keys [diff hash]} (sync/diff-states (:state msg) shadow)]
|
(let [{:keys [diff hash]} (sync/diff-states (:state msg) shadow)]
|
||||||
#+cljs (logs "new state")
|
#+cljs (logs "new state")
|
||||||
#+clj (println "new state")
|
#+clj (println "new state")
|
||||||
(if client?
|
(when-not (sync/empty-diff? diff)
|
||||||
(when-not (sync/empty-diff? diff)
|
|
||||||
(>! out (message/diff-msg diff hash)))
|
|
||||||
(>! out (message/diff-msg diff hash)))
|
(>! out (message/diff-msg diff hash)))
|
||||||
(recur shadow))
|
(recur shadow))
|
||||||
(recur shadow)))))))
|
(recur shadow)))))))
|
||||||
|
|
Loading…
Reference in a new issue