Skip to content

Commit d0fd918

Browse files
committed
[new] Alias client option: :ws-kalive-ping-timeout-ms -> :ws-ping-timeout-ms
The previous name was overly verbose. And since the same option will soon also be made available server-side, now's a good opportunity to simplify the name. Note that the old name will continue to be supported for backwards compatibility.
1 parent 15cfe0a commit d0fd918

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

src/taoensso/sente.cljc

+24-15
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,7 @@
13331333
[client-id chs params headers packer url
13341334
state_ ; {:type _ :open? _ :uid _ :csrf-token _ ...}
13351335
conn-id_ retry-count_ ever-opened?_
1336-
ws-kalive-ms ws-kalive-ping-timeout-ms ws-opts
1336+
ws-kalive-ms ws-ping-timeout-ms ws-opts
13371337
backoff-ms-fn ; (fn [nattempt]) -> msecs
13381338
cbs-waiting_ ; {<cb-uuid> <fn> ...}
13391339
socket_ ; ?[<socket> <socket-id>]
@@ -1561,11 +1561,11 @@
15611561
;; if conn is broken.
15621562
(timbre/debugf "Client will send ws-ping to server: %s"
15631563
{:ms-since-last-activity (- (enc/now-udt) udt-t1)
1564-
:timeout-ms ws-kalive-ping-timeout-ms})
1564+
:timeout-ms ws-ping-timeout-ms})
15651565

15661566
(-chsk-send! chsk [:chsk/ws-ping]
15671567
{:flush? true
1568-
:timeout-ms ws-kalive-ping-timeout-ms
1568+
:timeout-ms ws-ping-timeout-ms
15691569
:cb ; Server will auto reply
15701570
(fn [reply]
15711571
(when (and (own-conn?) (not= reply "pong") #_(= reply :chsk/timeout))
@@ -1867,11 +1867,10 @@
18671867
:wrap-recv-evs? ; Should events from server be wrapped in [:chsk/recv _]?
18681868
; Default false for Sente >= v1.18, true otherwise.
18691869
1870-
:ws-kalive-ms ; Ping to keep a WebSocket conn alive if no activity
1871-
; w/in given msecs. Should be different to server's :ws-kalive-ms.
1872-
:ws-kalive-ping-timeout-ms ; When above keep-alive ping is triggered, use this
1873-
; timeout (default: 5000) before regarding the connection
1874-
; as broken.
1870+
:ws-kalive-ms ; Ping to keep a WebSocket conn alive if no activity
1871+
; w/in given msecs. Should be different to server's :ws-kalive-ms.
1872+
:ws-ping-timeout-ms ; When pinging to test WebSocket connections, msecs to
1873+
; await reply before regarding the connection as broken
18751874
18761875
:ws-constructor ; Advanced, (fn [{:keys [uri-str headers on-message on-error on-close]}]
18771876
; => connected WebSocket, see `default-client-ws-constructor` code for
@@ -1880,7 +1879,7 @@
18801879
[path ?csrf-token-or-fn &
18811880
[{:as opts
18821881
:keys [type protocol host port params headers recv-buf-or-n packer
1883-
ws-constructor ws-kalive-ms ws-kalive-ping-timeout-ms ws-opts
1882+
ws-constructor ws-kalive-ms ws-ping-timeout-ms ws-opts
18841883
client-id ajax-opts wrap-recv-evs? backoff-ms-fn]
18851884

18861885
:or {type :auto
@@ -1891,9 +1890,9 @@
18911890
wrap-recv-evs? false
18921891
backoff-ms-fn enc/exp-backoff
18931892

1894-
ws-kalive-ms 20000
1895-
ws-kalive-ping-timeout-ms 5000
1896-
ws-constructor default-client-ws-constructor}}
1893+
ws-kalive-ms 20000
1894+
ws-ping-timeout-ms 5000
1895+
ws-constructor default-client-ws-constructor}}
18971896

18981897
_deprecated-more-opts]]
18991898

@@ -1939,15 +1938,25 @@
19391938
(chan buf (map (fn [ev] [:chsk/recv ev])))
19401939
(chan buf)))}
19411940

1941+
ws-ping-timeout-ms
1942+
(cond
1943+
(contains? opts :ws-ping-timeout-ms)
1944+
(do (get opts :ws-ping-timeout-ms))
1945+
1946+
(contains? opts :ws-kalive-ping-timeout-ms) ; Back compatibility
1947+
(do (get opts :ws-kalive-ping-timeout-ms))
1948+
1949+
:else ws-ping-timeout-ms)
1950+
19421951
common-chsk-opts
19431952
{:client-id client-id
19441953
:chs private-chs
19451954
:params params
19461955
:headers headers
19471956
:packer packer
1948-
:ws-kalive-ms ws-kalive-ms
1949-
:ws-kalive-ping-timeout-ms ws-kalive-ping-timeout-ms
1950-
:ws-constructor default-client-ws-constructor}
1957+
:ws-kalive-ms ws-kalive-ms
1958+
:ws-ping-timeout-ms ws-ping-timeout-ms
1959+
:ws-constructor default-client-ws-constructor}
19511960

19521961
ws-chsk-opts
19531962
(merge common-chsk-opts

0 commit comments

Comments
 (0)