sente icon indicating copy to clipboard operation
sente copied to clipboard

Allow channel setup without connecting

Open michihuber opened this issue 7 years ago • 1 comments

Hi,

Thank you very much for sente, it really does save a lot of work!

I have two somewhat related issues:

  1. It would be useful if I could set up the channel without connecting immediately.
  2. When reconnecting, it would be useful to be able to pass new params.

The usecase for 1) would be to set up the channel as part of the system (and get hold of :ch-recv and :send-fn) but not connect just yet if the user needs to authenticate first (e.g., fetch an authentication token through ajax). This would avoid errors being logged while authentication fails in the websocket requests.

Then, when reconnecting (or in this case, connecting), it would be great to be able to pass new params (e.g. in this case, the fetched authentication token).

Right now, I work around this by connecting immediately (which logs errors), and when the token was acquired doing:

(sente/chsk-reconnect!
  (-> chsk
      (assoc-in [:ws-chsk-opts :params :auth-token] token)
      (assoc-in [:ajax-chsk-opts :params :auth-token] token)))

Would you accept a patch for this functionality?

michihuber avatar Nov 19 '17 15:11 michihuber

Hi Michi,

Would be happy to look at a PR (maybe 2 separate PRs for the 2 items mentioned above?)- thanks! :+1:

Edit to add: Otherwise please 👍 if someone else is reading this and interested in the feature.

ptaoussanis avatar Dec 10 '17 19:12 ptaoussanis