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 Apr 11, 2023
1 parent 4bbfaac commit 3673019
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 50 deletions.
38 changes: 38 additions & 0 deletions src/taoensso/sente/server_adapters/community/jetty9.clj
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,41 @@
(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
50 changes: 0 additions & 50 deletions src/taoensso/sente/server_adapters/jetty9.clj

This file was deleted.

0 comments on commit 3673019

Please sign in to comment.