If an application has a lot of packets and the developer must create a handler for each packet, it might get tedious, especially if a group of packet handlers have the same dependencies.
Ideally, related packets that require similar dependencies would get processed by the same handler. For example, in a game, all combat packets could get handled by CombatHandler. Of course if this class grows unwieldy, a developer could always break it all the way down to the traditional 1:1 relationship, if desired.
If the packet processor handled deserialization and the handler just processed the packet, then PacketHandlerBase<T> could get replaced by IPacketHandler<T> which would just require the Process method. This way, a concrete implementation could implement any number of IPacketHandler<T> interfaces.
If an application has a lot of packets and the developer must create a handler for each packet, it might get tedious, especially if a group of packet handlers have the same dependencies.
Ideally, related packets that require similar dependencies would get processed by the same handler. For example, in a game, all combat packets could get handled by
CombatHandler
. Of course if this class grows unwieldy, a developer could always break it all the way down to the traditional 1:1 relationship, if desired.If the packet processor handled deserialization and the handler just processed the packet, then
PacketHandlerBase<T>
could get replaced byIPacketHandler<T>
which would just require theProcess
method. This way, a concrete implementation could implement any number ofIPacketHandler<T>
interfaces.What do you think?