NFIBrokerage / slipstream

A slick WebSocket client for Phoenix Channels
https://hex.pm/packages/slipstream
Apache License 2.0
160 stars 18 forks source link

token refresh example #49

Closed cadebward closed 2 years ago

cadebward commented 2 years ago

Hey there! I took out the minimum amount of code from our token refresh implementation and tried to come up with a straight-forward example. Maybe after a bit of back and forth, when you're happy with the code in client.ex, I can proceed to write up the tutorial and tests to go with it.

Let me know what you think!

the-mikedavis commented 2 years ago

Oh sweet, thanks for following up on this!

cadebward commented 2 years ago

I've added a pretty basic test. Any ideas of how to test it further? 🤷

the-mikedavis commented 2 years ago

I was fiddling with adding an assert_connect helper to Slipstream.SocketTest (https://github.com/NFIBrokerage/slipstream/commit/9e0c360b3a79f3308ee9a926f2cf5024b31b13ca) for testing reconnect behavior. I think that would help out here but I'm not sure yet how it should interact with the similar Slipstream.SocketTest.accept_connect/1 (maybe they should be consolidated into one helper?). I'll swing back around to this example if that ends up making its way into the API.

the-mikedavis commented 2 years ago

Thanks for working on this @cadebward!