cch1 / http.async.client

Async Http Client - Clojure
http://cch1.github.com/http.async.client
267 stars 40 forks source link

open and close handlers get called twice if :byte and :text handlers are created #73

Closed ryfow closed 8 years ago

ryfow commented 8 years ago

When creating a websocket connection, if you specify :byte, :text, :open and :close handlers as the readme describes, :open gets called twice when the websocket is opened and :close gets called twice when the websocket closes.

cch1 commented 8 years ago

Ryan, THanks for the report. Unfortunately, I don't use the websockets implementation -it was a vestige from the previous maintainer.

Any patch or PR would be most welcome.

-Chris

pbostrom commented 8 years ago

I think that the API should only accept a single callback fn to align with most WebSocket clients, i.e. replace :text and :byte with :message. Then it's up to the application to manage the format of the message.

cch1 commented 8 years ago

That sounds reasonable.

cch1 commented 8 years ago

Upon further investigation, websocket seems to natively handle text and thus byte support calls for additional overhead (some kind of encoding/decoding on each end, plus expansion of messages while in transit). We need to improve this lib's optioning between the two to ensure mutual exclusivity. Thoughts?