Skip to content

Commit

Permalink
[#214] Experimental: add [:chsk/ws-error _] ev-msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaoussanis committed Apr 12, 2016
1 parent ff9a029 commit f0785fd
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/taoensso/sente.cljx
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@
* Callback wrapping: [<clj> <?cb-uuid>] for [1],[2]
* Callback replies: :chsk/closed, :chsk/timeout, :chsk/error
* Client-side events:
[:chsk/handshake [<?uid> <?csrf-token> <?handshake-data>]],
[:chsk/state <new-state>],
[:chsk/handshake [<?uid> <?csrf-token> <?handshake-data>]]
[:chsk/state <new-state>]
[:chsk/recv <[buffered-evs]>] ; server>user push
[:chsk/ws-error <error>] ; Experimental, subject to change
* Server-side events:
[:chsk/ws-ping],
[:chsk/bad-package <packed-str>],
[:chsk/bad-event <chsk-event>],
[:chsk/uidport-open],
[:chsk/uidport-close].
[:chsk/ws-ping]
[:chsk/bad-package <packed-str>]
[:chsk/bad-event <chsk-event>]
[:chsk/uidport-open]
[:chsk/uidport-close]
Notable implementation details:
* core.async is used liberally where brute-force core.async allows for
Expand Down Expand Up @@ -820,7 +821,11 @@
(reset! socket_
(doto ?socket
(aset "onerror"
(fn [ws-ev] (errorf "WebSocket error: %s" ws-ev)))
(fn [ws-ev]
(errorf "WebSocket error: %s" ws-ev)
;; Experimental, for #214;
(put! (:internal chs) [:chsk/ws-error ws-ev])

This comment has been minimized.

Copy link
@danielcompton

danielcompton May 21, 2016

Collaborator

Should this return false for cb-success??

This comment has been minimized.

Copy link
@ptaoussanis

ptaoussanis May 21, 2016

Author Member

Hey Daniel, could you possibly clarify a little what you're asking?

This isn't a callback value; it's an event. Is something calling cb-success? against this?

This comment has been minimized.

Copy link
@danielcompton

danielcompton May 21, 2016

Collaborator

Sorry, that was a bit oblique. There's a bunch of events that constitute failures in Sente, :chsk/timeout, :chsk-error, :chsk/closed. I was asking if :chsk/ws-error should be added to the set in the cb-success? function.

As I read it, this message would be treated as a successful one? I don't have a way to reproduce it, so I might be badly misunderstanding how and when this is returned.

This comment has been minimized.

Copy link
@ptaoussanis

ptaoussanis May 21, 2016

Author Member

Ahh, gotcha- thanks for clarifying. (And a good question). This doesn't need adding since it's not actually a callback value.

The only place cb-success? can be used is in the body of a send! callback function and you'll never see this [:chsk/ws-error _] in a callback fn.

:chsk/timeout and co. are all singular, callback values.

This [:chsk/ws-error _] isn't a callback value, but an event (like [:chsk/state _], etc.). It'll be handled by your Sente router.

Does that make sense?

nil))

(aset "onmessage" ; Nb receives both push & cb evs!
(fn [ws-ev]
Expand Down

0 comments on commit f0785fd

Please sign in to comment.