vapor / websocket-kit

WebSocket client library built on SwiftNIO
https://docs.vapor.codes/4.0/advanced/websockets/
MIT License
272 stars 79 forks source link

Allow `send(_ binary:)` to accept `some DataProtocol` #146

Closed fizker closed 5 months ago

fizker commented 8 months ago

These changes are now available in 2.15.0

This allows for passing in Data or ByteBufferView to send(_:), as well as the currently-supported [UInt8] type.

codecov-commenter commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 82.85%. Comparing base (a935b63) to head (8d2d799). Report is 2 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #146 +/- ## ======================================= Coverage 82.85% 82.85% ======================================= Files 6 6 Lines 659 659 ======================================= Hits 546 546 Misses 113 113 ``` | [Files](https://app.codecov.io/gh/vapor/websocket-kit/pull/146?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor) | Coverage Δ | | |---|---|---| | [Sources/WebSocketKit/WebSocket.swift](https://app.codecov.io/gh/vapor/websocket-kit/pull/146?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9XZWJTb2NrZXRLaXQvV2ViU29ja2V0LnN3aWZ0) | `89.04% <100.00%> (ø)` | |
github-advanced-security[bot] commented 8 months ago

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

fizker commented 8 months ago

Regarding the failing test, it reacts to the change of type. But since [UInt8] conforms to DataProtocol (which for the record is protocol DataProtocol : RandomAccessCollection where Self.Element == UInt8, Self.SubSequence : DataProtocol), I am not sure it actually is a breaking change?

gregcotten commented 5 months ago

Why wasn't this changed in the Concurrency shims as well?

https://github.com/vapor/websocket-kit/blob/4232d34efa49f633ba61afde365d3896fc7f8740/Sources/WebSocketKit/Concurrency/WebSocket%2BConcurrency.swift#L15

0xTim commented 5 months ago

Probably just an oversight tbh

fizker commented 5 months ago

Why wasn't this changed in the Concurrency shims as well?

https://github.com/vapor/websocket-kit/blob/4232d34efa49f633ba61afde365d3896fc7f8740/Sources/WebSocketKit/Concurrency/WebSocket%2BConcurrency.swift#L15

I didn't know that overload existed until you told me about it. I stumbled on the one I changed and didn't look further as it did what I wanted 🤷.