Comments (2)
Hello, I don't think this would stay within the scope of the class since it was made non-generic in order to be usable with different kind of IMessageReader<T>
at once.
The solution that you mentionned would require to introduce a new public strongly-typed generic type that may not be necessary since an extension method could be sufficient (user defined or made generic with a static generic protocol store within the bedrock framework, or even a generic interface with static abstract singleton member if we want to use new language features):
namespace MyProtocolNamespace;
public static class MyProtocolExtensions
{
// suppose we implemented a singleton pattern in our IMessageReader<MyResult> implementation
public static ValueTask<ProtocolReadResult<MyResult>> ReadAsync(this ProtocolReader reader, CancellationToken token)
=> reader.ReadAsync(MyMessageReader.Instance, token);
}
In the user-defined case, you could even wrap the ProtocolReadResult<T>
on your own readonly struct to reduce verbosity (given that you make the required changes to the extension method):
public readonly struct MyReceiveResult
{
public required ProtocolReadResult<MyResult> ReadResult { get; init; }
public MyResult => ReadResult.Message;
public bool IsCompleted => ReadResult.IsCompleted;
public bool IsCanceled => ReadResult.IsCanceled;
}
from bedrockframework.
Hi, you're completely right, I missed this point. The idea of creating an extension class sounds much better. Thanks!
from bedrockframework.
Related Issues (20)
- Can a single connection support writing in concurrent scenarios? HOT 1
- How to initiate disconnection? HOT 6
- Blazor WASM support HOT 1
- Framing - Variable size length fielded protocol
- Out-of-Box BinarySerializer HOT 6
- How can use WebSocket (help wanted) HOT 1
- Connection closed when sending more than 126 bytes in a given message via WebSocket HOT 3
- How to make the server to disconnect all (or a specified) connected clients while keep running?
- Server Start-Stop "restart" exception HOT 1
- Disposable issues
- How to receive data correctly and how to close normally HOT 7
- Easily seeding user/roles for testing
- Question: SSL routines:tls_post_process_client_hello:no shared cipher
- Is Bedrock production ready? HOT 1
- MIDI Protocol - How to handle realtime, interleaved, messages
- DuplexPipeStream and Adapter Access
- Upgrade to .NET 7 HOT 6
- How do I use HubProtocol? I don't have invocationBinder.
- Question about using some code piece in `Server.cs` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bedrockframework.