-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Improve and simplify output writer thread handling
Expose a straight PipeWriter over the websocket by directly adapting it to Stream so we can use the biult-in PipeWriter.Create over a websocket. Note that we depend on knowledge of how the default pipe writer does its writing, which is by just invoking `WriteAsync` and `FlushAsync` on it. So we leave all other `Stream` members unimplemented. The `StreamPipeWriter` invokes `FlushAsync` automatically whenever there are bytes written, so it's impossible to distinguish writing partial messages from full messages. This seems like an acceptable trade-off anyway, so we just assume the same (`WriteAsync` == full EndOfMessage for WebSocket message). Now the `RunAsync` task deals exclusively with the incoming side of the websocket, and it's much easier to reason about it (including whether it's worth creating another thread to keep it running or not). Fixes #5
- Loading branch information
Showing
5 changed files
with
47 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters