Use SRStatusCode instead of NSInteger for close codes #707
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request changes the type of the
closeWithCode:reason:method'scodeparameter fromNSIntegertoSRStatusCode.Changes
NSIntegerwithSRStatusCodefor close codes in theSRWebSocketDelegateprotocol'swebSocket:didCloseWithCode:reason:wasClean:method.NSIntegerwithSRStatusCodefor thecloseWithCode:reason:method in theSRWebSocketclass._closeCodeinternal property frominttoSRStatusCodefor type safety.1000withSRStatusCodeNormalfor better readability.README.mdto reflect the new method signature.Motivation
This change improves type safety and clarity by using the specific
SRStatusCodeenum for WebSocket close codes, instead of a genericNSInteger. This helps developers avoid passing invalid values and makes the code's intent more explicit. The use ofSRStatusCodeNormalinstead of1000also improves code readability.Breaking Change
This is a breaking change as it alters the public API of
SRWebSocketandSRWebSocketDelegate. Users who have implemented the delegate method or called thecloseWithCode:reason:method will need to update their code to useSRStatusCode.