denoland / fastwebsockets

A fast RFC6455 WebSocket implementation
https://docs.rs/fastwebsockets/
Apache License 2.0
880 stars 66 forks source link

feat: refactor to allow for split mode of operation #47

Closed mmastrac closed 1 year ago

mmastrac commented 1 year ago

Works towards solving #40, allowing read and write halves to work independently. Maintains the old API for compatibility.

This is a pre-factoring PR that splits out a ReadHalf and WriteHalf, and ensures that you can read and write independently. A later PR will build on this to create the split API.

The main parts of this PR are:

I tried to avoid making any major logic changes to functions -- this is mainly moving things around for a later patch.

Also note that the logic around checking whether the WriteHalf is closed or not has been hoisted into the read callers. This is a little awkward given that there is a fragmented and non-fragmented read path that duplicate this logic, but we may be able to clean this up in the future.

M4urici0GM commented 1 year ago

That's awesome, actually, i need this feature as well. Hope it gets merged 🚀