* Add & use WebSocketError type
Previously, there were separate errors thrown for Starscream and native
web sockets. Now, they both throw `WebSocketError`s.
Also, if there’s a "Retry-After" header, we’ll include it on errors.
* Use coarser lock in SSKWebSocketNative
This isn’t strictly required, but it makes the class easier to reason
about, and it fixes a bug where writing to a web socket while that
socket is being closed normally could allow the write error to be
reported instead of the close error.
* Fix web socket close/final message race condition
There’s a comment in the code that describes the fix.
In addition, this updates the native web socket to only post the first
error that occurs. Both of the existing web socket implementations
(OWSWebSocket & ProvisioningSocket) are written in such a way that these
subsequent errors would be ignored, and it makes future code simpler if
there’s at most one error that gets reported.
* Make error required in web socket close delegate
Before this change, the error was never nil when using the native
socket, which is the implementation we use on iOS 13+. This change
ensures it’s never nil on iOS 12, which improves consistency.
In addition, this updates the iOS 12 implementation to skip reporting
error if the user has explicitly requested the connection be closed,
which also mimics the behavior on iOS 13+.