This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-01
Channels
- # aleph (71)
- # aws (1)
- # bangalore-clj (4)
- # beginners (36)
- # boot (153)
- # cider (23)
- # clara (9)
- # cljs-dev (67)
- # cljsjs (2)
- # cljsrn (22)
- # clojure (348)
- # clojure-argentina (4)
- # clojure-austin (12)
- # clojure-berlin (9)
- # clojure-dusseldorf (6)
- # clojure-france (4)
- # clojure-italy (4)
- # clojure-russia (358)
- # clojure-spain (2)
- # clojure-spec (28)
- # clojure-uk (109)
- # clojurescript (130)
- # core-typed (1)
- # cursive (35)
- # datascript (6)
- # datomic (18)
- # emacs (12)
- # hoplon (4)
- # klipse (64)
- # lein-figwheel (13)
- # leiningen (3)
- # luminus (4)
- # lumo (51)
- # mount (22)
- # off-topic (83)
- # om (22)
- # om-next (8)
- # onyx (3)
- # pedestal (8)
- # perun (6)
- # portland-or (2)
- # re-frame (50)
- # ring (8)
- # ring-swagger (5)
- # untangled (10)
- # yada (9)
Alright. Thankfully someone can help me out before I pull my hair out. I have this very odd issue. I'm using aleph/manifold to connect to a websocket, and s/consume
doesn't seem to be triggering at all and I really don't know why. Evaluating each relevant line one at a time works from the repl, just not within a function. Here's the exact line that doesn't trigger: https://github.com/eslachance/dithcord/blob/master/src/dithcord/core.clj#L121
@dm3 I just have [aleph "0.4.1"]
@eslachance what does printing the stream that you consume show?
e.g.
boot.user=> (manifold.stream/stream)
<< stream: {:pending-puts 0, :drained? false, :buffer-size 0, :permanent? false, :type "manifold", :sink? true, :closed? false, :pending-takes 0, :buffer-capacity 0, :source? true} >>
after you start consuming the stream, it should have a :pending-takes 1
and :closed?
should be false
When I call that function (ws-connect) it returns the session, which has the stream as a socket
and printing out (:socket @session)
does show that stream
yes which I have as (swap! session assoc :socket ws)
let me see about drained
what happens if you just do
(let [x @(http/websocket-client "")]
(s/consume #(println "DEBUG" %) x))
?.... nothing
well sorry it returns nil
to be precise
nothing else, no message, not output.
But I am though if I do
(def conn @(http/websocket-client ""))
(s/on-closed conn (fn [] (prn "closed")))
(s/consume (fn [msg] (prn msg)) conn)
then I do get a messageI get a first packet, and then I get a closed message after a second or so because the websocket is expecting an identity packet
which, if I provide it, does work
So I'm receiving packets fine when I def the connection. But when I use let
it doesn't work
I was previously using http.async.client
, which worked fine except for the fact that it crashes the websocket on large packets (a bug in the java lib it uses)
I do. those 3 lines work
That's the packet
and you are saying that
(let [conn @(http/websocket-client ""))]
(s/on-closed conn (fn [] (prn "closed")))
(s/consume (fn [msg] (prn msg)) conn))
doesn't?wait a sec. no it does.
but...
(let [x @(http/websocket-client "")]
(s/consume #(println "DEBUG" %) x))
didn't work. IT didn't print out that packetthe heck?
I don't even know what that is >.<
but really I know this API
we're talkinga bout Discord here it always sends a packet
consistently
OH MY GOD
Thank you.
I shall take my shame and go fix the error
Obviously, this does bring to light that aleph doesn't have an "on-error" event cough
(well manifold doesn't?)
True, but when a websocket closes, it has a reason to close. Getting that reason would be... useful.
I mean we have s/on-close
why not s/on-error
. I feel that's expected, and consistent.
And also consistent with other libraries
Obviously!
Once I get this all working I'm planning a series of video tutorials on various things clojure-related in the shape of a development story for my library
But that's once I get it working ^_^
Any way to handle a zlib compressed packet? It shows up as #object["[B" 0x7282913c "[B@7282913c"]
if I just print it to console, not exactly sure how to handle that
And the java interop adventure beings....
this seems like an approach - https://github.com/amatus/GNUnet-in-Clojure/blob/master/src/main/clojure/org/gnu/clojure/gnunet/zip.clj
Wait what about byte-streams?
ooooh
I feel like I'm so close though
"x?????0\fE??k???]?????A?t\"??K??\b??e2???vG?G???\n\rz??????B/;X/?&??\n??`??\r?Z???????z ??9?m??_?L??;?S??*8.??(?c4!8%????0?1/?}Y?B?i??\\???BY????E??\r?f??)i\fº?Z??$??u??+??2<?\r?B&\"5?1LIz?!*?Iz??,?l?`???/?????Y??t?Rh??R????y??2??+????????NGa???\r??R8?u??\b+c????*\n???k????ab??q?u?G??.\\?4?}??U?f?r???l?r"
Oh btw, @dm3 that approach did work, I included it in my project, and used the following line on the incoming packet:
(String. (byte-array (z/inflate msg)))
(z/ being that zip.clj file)Took a lot of mucking around and some help from other people but it works!