|
1333 | 1333 | [client-id chs params headers packer url
|
1334 | 1334 | state_ ; {:type _ :open? _ :uid _ :csrf-token _ ...}
|
1335 | 1335 | 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 |
1337 | 1337 | backoff-ms-fn ; (fn [nattempt]) -> msecs
|
1338 | 1338 | cbs-waiting_ ; {<cb-uuid> <fn> ...}
|
1339 | 1339 | socket_ ; ?[<socket> <socket-id>]
|
|
1561 | 1561 | ;; if conn is broken.
|
1562 | 1562 | (timbre/debugf "Client will send ws-ping to server: %s"
|
1563 | 1563 | {:ms-since-last-activity (- (enc/now-udt) udt-t1)
|
1564 |
| - :timeout-ms ws-kalive-ping-timeout-ms}) |
| 1564 | + :timeout-ms ws-ping-timeout-ms}) |
1565 | 1565 |
|
1566 | 1566 | (-chsk-send! chsk [:chsk/ws-ping]
|
1567 | 1567 | {:flush? true
|
1568 |
| - :timeout-ms ws-kalive-ping-timeout-ms |
| 1568 | + :timeout-ms ws-ping-timeout-ms |
1569 | 1569 | :cb ; Server will auto reply
|
1570 | 1570 | (fn [reply]
|
1571 | 1571 | (when (and (own-conn?) (not= reply "pong") #_(= reply :chsk/timeout))
|
|
1867 | 1867 | :wrap-recv-evs? ; Should events from server be wrapped in [:chsk/recv _]?
|
1868 | 1868 | ; Default false for Sente >= v1.18, true otherwise.
|
1869 | 1869 |
|
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 |
1875 | 1874 |
|
1876 | 1875 | :ws-constructor ; Advanced, (fn [{:keys [uri-str headers on-message on-error on-close]}]
|
1877 | 1876 | ; => connected WebSocket, see `default-client-ws-constructor` code for
|
|
1880 | 1879 | [path ?csrf-token-or-fn &
|
1881 | 1880 | [{:as opts
|
1882 | 1881 | :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 |
1884 | 1883 | client-id ajax-opts wrap-recv-evs? backoff-ms-fn]
|
1885 | 1884 |
|
1886 | 1885 | :or {type :auto
|
|
1891 | 1890 | wrap-recv-evs? false
|
1892 | 1891 | backoff-ms-fn enc/exp-backoff
|
1893 | 1892 |
|
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}} |
1897 | 1896 |
|
1898 | 1897 | _deprecated-more-opts]]
|
1899 | 1898 |
|
|
1939 | 1938 | (chan buf (map (fn [ev] [:chsk/recv ev])))
|
1940 | 1939 | (chan buf)))}
|
1941 | 1940 |
|
| 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 | + |
1942 | 1951 | common-chsk-opts
|
1943 | 1952 | {:client-id client-id
|
1944 | 1953 | :chs private-chs
|
1945 | 1954 | :params params
|
1946 | 1955 | :headers headers
|
1947 | 1956 | :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} |
1951 | 1960 |
|
1952 | 1961 | ws-chsk-opts
|
1953 | 1962 | (merge common-chsk-opts
|
|
0 commit comments