Prototype code for packet handler decorators#40
Prototype code for packet handler decorators#40snarlynarwhal wants to merge 1 commit intomarkiodev:masterfrom
Conversation
|
|
||
| namespace Networker.Common | ||
| { | ||
| public abstract class PacketHandlerDecorator<T> : PacketHandlerBase<T> where T: class |
There was a problem hiding this comment.
This particular way of doing it would work well as an extension project, but I would like to avoid the dependency on PacketHandlerBase as you are able to use just an IPacketHandler now.
Would this also mean you'd need a new PacketHandlerDecorator for each packet type?
There was a problem hiding this comment.
Yeah implementing IPacketHandler makes more sense. The decorator has helper methods to get the target handler method info based on the packet type. This assumes the handler methods accept a base packet type though. I definitely need to think more about this.
Where should I wire up the decorators? Once I get it to a testable state, I can play around with ideas to make sure a single decorator can handle multiple packet types.
There was a problem hiding this comment.
I've got a new way of registering packets + handlers coming in soon which might be the best place to wire up the decorator, I'll let you know when it's ready.
There was a problem hiding this comment.
Alright sounds good! Also, it might be preferable to assign decorators using the builder instead of attributes. That approach would require a fluent interface instead of method chaining, which I can add later on if you think it's a good idea.
I wanted to get feedback before continuing with the last step of wiring up the decorators.
I added 3 classes to Networker:
Decorate[typeof(AuthorizationHandlerDecorator)][Authorize]The attributes can get added to handlers and modules.
I put together
Demo.Decoratorsto demonstrate how the features gets used. It does not function yet.The last part I need to do is wire up the decorators on startup. Should do this in
BuilderBase.SetupSharedDependencies?