davidstump / SwiftPhoenixClient

Connect your Phoenix and iOS applications through WebSockets!
MIT License
506 stars 146 forks source link

Add code and reason to socket close callbacks #237

Closed ejensen closed 1 year ago

ejensen commented 1 year ago

This PR adds code and reason parameters to the Socket.onClose callback. This allows clients to know why a socket was closed.

The two parameters were added in a non-breaking manner by keeping the existing methods that don't supply the two additional parameters in the callback closures.

The only potentially breaking change is when implementing a custom PheonixTransport or PhoenixTransportDelegate, the onClose method now has an additional reason: String? parameter. This is unlikely to impact typical usages of SwiftPhoenixClient since URLSessionTransport and Socket are the natural implementors of PheonixTransport and PhoenixTransportDelegate, respectively.