Fork me on GitHub
#pathom
<
2020-08-17
>
yenda08:08:45

pathom-viz ws seems to be working:

yenda@desktop:~$ wscat --connect 
Connected (press CTRL+C to quit)
there is an expected error in the server since I just connect with no params:
WARN [com.wsscode.node-ws-server:60] - Unhandled request: %s /.websocket
ERROR [taoensso.sente:628] - Client's Ring request doesn't have a client id. Does your server have the necessary keyword Ring middleware (`wrap-params` & `wrap-keyword-params`)?: {:websocket? true, :websocket #object[WebSocket [object Object]], :response nil, :body #object[IncomingMessage [object Object]], :query-params {}, :form-params {}, :params {}}

yenda08:08:32

I tried the simplest possible connection on cljs side with:

(let [{:keys [chsk ch-recv send-fn state] :as res}
      (sente/make-channel-socket-client!
       "/chsk" ; Note the same path as before
       "not needed"
       {:host "localhost" :port 8240 :type :auto ; e/o #{:auto :ajax :ws}
       })]
(println :res res)
  (def chsk       chsk)
  (def ch-chsk    ch-recv) ; ChannelSocket's receive channel
  (def chsk-send! send-fn) ; ChannelSocket's send API fn
  (def chsk-state state)   ; Watchable, read-only atom
  )

yenda08:08:58

no reaction on server side and the ws stays in closed state

yenda09:08:29

I noticed in res that the url has no host

yenda09:08:36

(let [;; Not available with React Native, etc.:
                 win-loc  (enc/get-win-loc)
                 path     (or path (:pathname win-loc))]

             (if-let [f (:chsk-url-fn opts)] ; Deprecated
               [(f path win-loc :ws)
                (f path win-loc :ajax)]

               (let [protocol (or protocol (:protocol win-loc) :http)
                     host     (if port
                                (str (:hostname win-loc) ":" port)
                                (do  (:host     win-loc)))]
                 [(get-chsk-url protocol host path :ws)
                  (get-chsk-url protocol host path :ajax)])))

yenda09:08:13

unless I'm misunderstanding it looks like sente ignores the host and uses win-loc instead?

yenda09:08:30

Looks like there is a bug in sente that is fixed in the next version, so I tried the newer version but it still doesn't connect

yenda09:08:55

I am running this in nodejs

yenda09:08:21

ok looks like I had to yarn add websocket to my project

👍 6
wilkerlucio23:08:26

done, also fixed the example to use cond->>, thanks for pointing those out

souenzzo20:08:32

@ballpark // @lgessler fulcro now has a function fm/with-server-side-mutation that can be used to "rename" the mutation before send it to remote

fulcro 6
lgessler20:08:08

very useful, thanks!