I’m currently planing with WebSockets and was a bit surprised that I don’t found any method to get an Async(Throwing)Sequence with the incoming Messges. Anyways I think that is a common expectation, so are the any reasons that it’s not there yet? Like heavy battery usage or so?
And are there a strong sequence if I want to contribute this kind of method to swift, like create a proposal, let it be reviewed and create a pull request on github?
It‘s a solid solution, but unintuitive in my opinion. I want a consolidated solution for this issue. Elsewhere I would use an extension.
I would also take care about it, but I have currently only my experience about it and don’t want to invest time into a pull requests or something if there are no people with the same experience.
And then is the question where to start? Is there a guide or anything?
We generally recommend that you use the WebSocket support in Network framework [1], not URLSession, and this year Network framework got a whole bunch of Swift concurrency enhancements. See WWDC 2025 Session 250 Use structured concurrency with Network framework.
Out of curiosity. It’s easy to suggest people use NWConnection (NetworkConnection has an unrealistic deployment restriction) but does Apple actually provide a readily available WebSocket connection? I just had a quick look at the APIs, and it seemed like one would have to implement the actual standard oneself?