radu-matei / websocket-manager

Real-Time library for ASP .NET Core
https://radu-matei.com/blog/real-time-aspnet-core/
MIT License
451 stars 182 forks source link

Client Connection: Made Invoke virtual for custom behavior. #64

Closed Henry00IS closed 6 years ago

Henry00IS commented 6 years ago

Similar to #63.

This allows me to use the original library without having to hack logic into the source to for example prefix method calls and find the method in different classes compared to having thousands of awkward .On(...) actions with object arrays.

Additionally:

Henry00IS commented 6 years ago

Here is an example of why I need this to be virtual (assuming you saw the other PR, this is nearly identical).

image

Now I can call my fancy methods in different classes depending on the prefix:

image

And I don't have to register anything with .On(), just like the server. It feels much nicer.

RobSchoenaker commented 6 years ago

You may want to abstract this away in a MethodInvocationStrategy. In this case it would be a ControllerMethodInvocationStrategy with a subclass to DecoratedControllerMethodInvocationStrategy. Then, add a regsitration (possibly with a priority) and a lookup mechanism. This way you do not need to care about all the 'if's.

Henry00IS commented 6 years ago

Yeah I was hoping this would inspire someone here to make some generic implementation that does the same thing. Sorry about posting the code as images. I doubt everyone wants to start using crazy ᐅ characters in their code like me. ;) I just didn't want to break anything and now I am only using master branch code, it's a weight off my chest because I started to feel really guilty about fixing so much and not sharing it haha.