pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
yenda 2020-08-17T08:42:45.048900Z

pathom-viz ws seems to be working:

yenda@desktop:~$ wscat --connect <ws://localhost:8240/chsk>
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` &amp; `wrap-keyword-params`)?: {:websocket? true, :websocket #object[WebSocket [object Object]], :response nil, :body #object[IncomingMessage [object Object]], :query-params {}, :form-params {}, :params {}}

yenda 2020-08-17T08:43:32.049300Z

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
  )

yenda 2020-08-17T08:43:58.049900Z

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

yenda 2020-08-17T09:07:29.050300Z

I noticed in res that the url has no host

yenda 2020-08-17T09:07:36.050600Z

(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)])))

yenda 2020-08-17T09:08:13.051400Z

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

yenda 2020-08-17T09:27:30.051900Z

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

yenda 2020-08-17T09:27:55.052300Z

I am running this in nodejs

yenda 2020-08-17T09:35:21.052700Z

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

👍 2
souenzzo 2020-08-17T20:25:32.054300Z

@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

2
lgessler 2020-08-17T20:50:08.054500Z

very useful, thanks!

wilkerlucio 2020-08-17T23:56:26.054700Z

done, also fixed the example to use cond-&gt;&gt;, thanks for pointing those out