Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose onerror-fn #216

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/taoensso/sente.cljx
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@
state_ ; {:type _ :open? _ :uid _ :csrf-token _}
cbs-waiting_ ; {<cb-uuid> <fn> ...}
socket_ kalive-ms kalive-timer_ kalive-due?_
onerror-fn
backoff-ms-fn ; (fn [nattempt]) -> msecs
active-retry-id_ retry-count_]

Expand Down Expand Up @@ -816,8 +817,7 @@

(reset! socket_
(doto ?socket
(aset "onerror"
(fn [ws-ev] (errorf "WebSocket error: %s" ws-ev)))
(aset "onerror" onerror-fn)

(aset "onmessage" ; Nb receives both push & cb evs!
(fn [ws-ev]
Expand Down Expand Up @@ -1038,6 +1038,7 @@
ws-kalive-ms 25000 ; < Heroku 30s conn timeout
lp-timeout-ms 25000 ; ''
packer :edn
onerror-fn (fn [ws-ev] (errorf "WebSocket error: %s" ws-ev)) ; Only applies for type :ws
client-id (or (:client-uuid opts) ; Backwards compatibility
(enc/uuid-str))

Expand Down Expand Up @@ -1113,6 +1114,7 @@
:kalive-ms ws-kalive-ms
:kalive-timer_ (atom nil)
:kalive-due?_ (atom true)
:onerror-fn onerror-fn
:backoff-ms-fn backoff-ms-fn
:active-retry-id_ (atom "pending")
:retry-count_ (atom 0)})))
Expand Down