🚧 Initial work on websocket communication.

This commit is contained in:
Andrey Antukh 2019-12-18 18:15:25 +01:00
parent 9c1c613c90
commit 9d93b0d3fb
9 changed files with 219 additions and 75 deletions

View file

@ -103,6 +103,12 @@
(st/emit! (udw/initialize file-id page-id))
#(rx/cancel! sub)))})
(mf/use-effect
{:deps #js [(str file-id)]
:fn (fn []
(st/emit! (udw/initialize-websocket file-id))
#(st/emit! (udw/finalize-websocket file-id)))})
(let [layout (mf/deref refs/workspace-layout)
file (mf/deref refs/workspace-file)
page (mf/deref refs/workspace-page)

View file

@ -128,6 +128,8 @@
;; --- Viewport
(declare remote-user-cursor)
(mf/defc canvas-and-shapes
{:wrap [mf/wrap-memo]}
[props]
@ -276,9 +278,44 @@
(when (contains? flags :ruler)
[:& ruler {:zoom zoom :ruler (:ruler local)}])
;; -- METER CURSOR MULTIUSUARIO
[:div.multiuser-cursor
[i/infocard]
[:span "USER_NAME"]]
;;[:& remote-user-cursor]
[:& selrect {:data (:selrect local)}]]])))
(mf/defc remote-user-cursor
[props]
[:g.multiuser-cursor #_{:transform "translate(100, 100) scale(2)"}
[:svg {:x "100"
:y "100"
:style {:fill "#000"}
:width "106.824"
:height "20.176"
:viewBox "0 0 28.264 5.338"}
[:path {:d "M5.292 4.027L1.524.26l-.05-.01L0 0l.258 1.524 3.769 3.768zm-.45 0l-.313.314L1.139.95l.314-.314zm-.5.5l-.315.316-3.39-3.39.315-.315 3.39 3.39zM1.192.526l-.668.667L.431.646.64.43l.552.094z"
:font-family "sans-serif"}]
[:g {:transform "translate(0 -291.708)"}
[:rect {:width "21.415"
:height "5.292"
:x "6.849"
:y "291.755"
:fill-opacity ".893"
:paint-order "stroke fill markers"
:rx ".794"
:ry ".794"}]
[:text {:x "9.811"
:y "295.216"
:fill "#fff"
:stroke-width ".265"
:font-family "Open Sans"
:font-size"2.91"
:font-weight "400"
:letter-spacing"0"
:line-height "1.25"
:word-spacing "0"
;; :style="line-height:1
}
"User 2"]]]])