Skip to content

Conversation

@nnabeyang
Copy link
Contributor

This pull request changes the type of the closeWithCode:reason: method's code parameter from NSInteger to SRStatusCode.

Changes

  • Replaced NSInteger with SRStatusCode for close codes in the SRWebSocketDelegate protocol's webSocket:didCloseWithCode:reason:wasClean: method.
  • Replaced NSInteger with SRStatusCode for the closeWithCode:reason: method in the SRWebSocket class.
  • Updated the _closeCode internal property from int to SRStatusCode for type safety.
  • Replaced the magic number 1000 with SRStatusCodeNormal for better readability.
  • Updated the README.md to reflect the new method signature.

Motivation

This change improves type safety and clarity by using the specific SRStatusCode enum for WebSocket close codes, instead of a generic NSInteger. This helps developers avoid passing invalid values and makes the code's intent more explicit. The use of SRStatusCodeNormal instead of 1000 also improves code readability.

Breaking Change

This is a breaking change as it alters the public API of SRWebSocket and SRWebSocketDelegate. Users who have implemented the delegate method or called the closeWithCode:reason: method will need to update their code to use SRStatusCode.

@meta-cla meta-cla bot added the CLA Signed label Sep 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant