jarohen / chord

A library designed to bridge the gap between the triad of CLJ/CLJS, web-sockets and core.async.
439 stars 40 forks source link

How do I use {:format :fression} on server side? (or: no method in multimethod for fression connection) #46

Closed retrogradeorbit closed 8 years ago

retrogradeorbit commented 8 years ago

Got a system going with {:format :transit-json}, but now when I try to switch to fression with code like this:

(defn ws-handler [{:keys [ws-channel] :as req}]
  (go
    (println (<! ws-channel))
    (>! ws-channel {1 ["recieving you"]})))

...

(GET "/ws" []
       (wrap-websocket-handler ws-handler {:format :fression}))

The wrap-socket-handler fails with:

java.lang.IllegalArgumentException: No method in multimethod 'formatter*' for dispatch value: :fression

Are there any docs or examples of working fression client/server connections?

jarohen commented 8 years ago

Hi there - think this might be a typo: :fression -> :fressian?

James

retrogradeorbit commented 8 years ago

Well that's embarrassing... I was all excited this would fix it, but after changing to the correct spelling it still doesn't like it.

java.lang.IllegalArgumentException: No method in multimethod 'formatter*' for dispatch value: :fressian

For mor info, I've been testing it in this little test project:

https://github.com/retrogradeorbit/multiplayer/blob/master/src-cljs/multiplayer/core.cljs#L106

retrogradeorbit commented 8 years ago

OK. I got this working by :requiring chord.format.fressian in the ns declaration (even though I don't directly use it). This seems to register the multimethod and then the :format :fressian works.

So

 (:require [chord.format.fressian :as fressian])

...

(GET "/ws" []
       (wrap-websocket-handler ws-handler {:format :fressian}))