Skip to content

Commit

Permalink
[new] [#477] [Community adapters] Support both Jetty 11 and 12
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaoussanis committed Dec 31, 2024
1 parent 39b8093 commit 2816672
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/taoensso/sente/server_adapters/community/jetty.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,32 @@
[ring.util.response :as ring-response]
[ring.websocket :as ws]
[ring.websocket.protocols :as ws.protocols]
[taoensso.encore :as enc]
[taoensso.sente.interfaces :as i]
[taoensso.timbre :as timbre])

(:import
[org.eclipse.jetty.websocket.api WebSocketListener]
[ring.websocket.protocols Socket]))
[ring.websocket.protocols Socket]))

;;;; WebSockets

(extend-type WebSocketListener
i/IServerChan
(enc/compile-if org.eclipse.jetty.websocket.common.WebSocketSession
(extend-type org.eclipse.jetty.websocket.common.WebSocketSession ; Jetty 12
i/IServerChan
(sch-open? [sch] (.isOpen sch))
(sch-close! [sch] (.close sch))
(sch-send! [sch-listener _websocket? msg]
(ws.protocols/-send sch-listener msg)
true))

(extend-type org.eclipse.jetty.websocket.api.WebSocketListener ; Jetty 11
i/IServerChan
(sch-open? [sch] (.isOpen sch))
(sch-close! [sch] (.close sch))
(sch-send! [sch-listener _websocket? msg]
(ws.protocols/-send sch-listener msg)
true)))

(extend-type Socket
i/IServerChan
(sch-open? [sch] (ws.protocols/-open? sch))
Expand Down Expand Up @@ -102,7 +111,7 @@

(defn get-sch-adapter
"Returns a Sente `ServerChan` adapter for `ring-jetty-adapter` [1].
Supports Jetty 11.
Supports Jetty 11, 12.
Options:
`:ajax-resp-timeout-ms` - Max msecs to wait for Ajax responses (default 60 secs),
Expand Down

0 comments on commit 2816672

Please sign in to comment.