From 8806e725402d224e5296ebf9b5b54fb07c222ae4 Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Tue, 20 Sep 2022 15:26:04 +0200 Subject: [PATCH] [new] [Undertow adapter] [#409] Allow Ajax read timeout (@kajism) --- .../sente/server_adapters/undertow.clj | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/taoensso/sente/server_adapters/undertow.clj b/src/taoensso/sente/server_adapters/undertow.clj index 8ca7703..81ea377 100644 --- a/src/taoensso/sente/server_adapters/undertow.clj +++ b/src/taoensso/sente/server_adapters/undertow.clj @@ -2,7 +2,6 @@ "Sente server adapter for ring-undertow-adapter." {:author "Nik Peric"} (:require - [clojure.core.async :as async] [ring.adapter.undertow.websocket :as websocket] [ring.adapter.undertow.response :as response] [taoensso.sente.interfaces :as i]) @@ -40,24 +39,30 @@ (defprotocol ISenteUndertowAjaxChannel (ajax-read! [sch])) -(deftype SenteUndertowAjaxChannel [resp-ch open?_ on-close _adapter-opts] +(deftype SenteUndertowAjaxChannel [resp-promise_ open?_ on-close adapter-opts] i/IServerChan - (sch-send! [sch websocket? msg] (async/put! resp-ch msg (fn [_] (i/sch-close! sch)))) + (sch-send! [sch websocket? msg] (deliver resp-promise_ msg) (i/sch-close! sch)) (sch-open? [sch] @open?_) (sch-close! [sch] (when (compare-and-set! open?_ true false) + (deliver resp-promise_ nil) (when on-close (on-close sch false nil)) - (async/close! resp-ch) true)) ISenteUndertowAjaxChannel - (ajax-read! [sch] (async/