-
-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic message type <T> #18
Comments
Hello. Thanks for the offer, I'm not against it, it should have been done a long time ago. The only thing I'll forgive - divide the implementation into separate PRs as much as possible to simplify verification. So that there is no situation where there is no code comparison, but there are simply deleted and added files. |
Sounds good! Glad you're onboard. :) I'll start with the generic/non-generic PipeXXX modification + tests and send a PR when it's finished. |
This feature looks cool and would help me a lot to achieve polymorphic pipe messages. Apparently, the PR did not make it through though. And since it has been more than a year now the work/review has been put on hold probably. For now, I will have to stick to sending content serialized as JSON for example and handle the JSON deserialization at the receiving side. |
I still love this suggestion. Unfortunately, the PR was quite voluminous, I was not able to quickly understand it and therefore it is still not accepted |
I have noticed that all the read/write APIs can only read and write the generic type defined by the user when instantiating the client and server, eg.
PipeServer<MyMessage>
,PipeClient<MyMessage>
.Would you agree to a PR with the following changes:
PipeClient
,PipeServer
,SingleConnectionPipeServer
,SingleConnectionPipeClient
would have a generic and non-generic variantvoid WriteAsync<T>(T value, [...])
void WriteAsync(byte[] value, [...])
event EventHandler<ConnectionMessageEventArgs<byte[]>>? MessageReceived;
PipeXXX
SingleConnectionPipeXXX
andPipeXXX
appear to share a lot of code. They could inherit an abstract class for all the code they have in commonSingleConnectionPipeXXX
andPipeXXX
by adding abool isSingleConnection
argument to the constructorIn essence we would have something like that:
Avoiding code duplication between SingleConnectionPipeXXX and PipeXXX
Option 1: Base class
Option 2: Merge them
We delete the SingleConnectionPipeXXX classes and add an argument in the constructor:
Non-generic PipeXXX classes
Repeat for SingleConnectionPipeXXX.
Generic PipeXXX classes
Repeat for SingleConnectionPipeXXX.
Optional: Sealed classes
Optionally, it might be nice to make the
PipeServer<T>
andPipeClient<T>
non-sealed for people who want to extend their functionalities without requiring a fork or a PR.Optional: Sharing code between PipeServer and PipeClient
PipeServer
andPipeClient
also appear to share a lot of code. I could make a base class for them to avoid code duplication.Final words
I'll be writing this for my own needs, but I would enjoy contributing to the project if possible with a PR. Let me know what you think! :)
The text was updated successfully, but these errors were encountered: