Skip to content

Commit

Permalink
fixup! [mod] [taoensso#424] reintroduce fixed jetty9-ring-adapter s…
Browse files Browse the repository at this point in the history
…upport
  • Loading branch information
TimoKramer committed Mar 22, 2023
1 parent fdc6a61 commit 14a3e0e
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions src/taoensso/sente/server_adapters/community/jetty9.clj
Original file line number Diff line number Diff line change
Expand Up @@ -48,41 +48,3 @@
(server-ch-resp (jetty9.websocket/ws-upgrade-request? req) callbacks-map))))

(defn get-sch-adapter [] (JettyServerChanAdapter.))

(comment
(require '[ring.adapter.jetty9 :refer [run-jetty stop-server]]
'[taoensso.sente :as sente]
'[compojure.core :refer :all])

(let [{:keys [ch-recv send-fn connected-uids
ajax-post-fn ajax-get-or-ws-handshake-fn]}
(sente/make-channel-socket! (get-sch-adapter) {})]
(def ring-ajax-post ajax-post-fn)
(def ring-ajax-get-or-ws-handshake ajax-get-or-ws-handshake-fn)
(def ch-chsk ch-recv) ; ChannelSocket's receive channel
(def chsk-send! send-fn) ; ChannelSocket's send API fn
(def connected-uids connected-uids)) ; Watchable, read-only atom

(defroutes my-app-routes
;; <other stuff>

;;; Add these 2 entries: --->
(GET "/chsk" req (ring-ajax-get-or-ws-handshake req))
(POST "/chsk" req (ring-ajax-post req)))

(def server (atom nil))
(reset! server (run-jetty my-app-routes {:port 50505
:join? false
:async? true}))
(stop-server @server)

(let [{:keys [chsk ch-recv send-fn state]}
(sente/make-channel-socket-client!
"/chsk" ; Note the same path as before
"foo"
{:type :ws})] ; e/o #{:auto :ajax :ws}

(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

0 comments on commit 14a3e0e

Please sign in to comment.