I’m designing a game in C#, I’m sure you get it a lot – but my question is a bit different in that I want to design something around an observer pattern to my understanding – and I can’t find much information it.
All of my packets implement a basic interface, called IPacket… and I was hoping to fire off an event when a packet of a certain type was recieved; without using a massive switch.
I was perhaps hoping for something like:
networkEvents.PacketRecieved += […]
Could anyone point me in the direction to do this?
What about something like this:
Each type of package you create registers a handler specific to that type of packet. Using a ConcurrentDictionary makes locking superfluous.