Jump to content
  • Advertisement
Sign in to follow this  
tstrimp

Implementing Messaging Systems

This topic is 4061 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've got a messaging system in place but I'm wondering how well it's going to scale. Currently each message type has it's own class that inherits the Message class. I've got a MessageDispatcher that is responsible to tracking subscribers and sending messages out to them. Lastly I've got a MessageBroker which let's me easily translate from one message type to another. Here is an example of how the MessageBroker works.
_messageBroker.Bind(new KeyboardMessage(KeyboardButton.KEY_W, KeyAction.Pressed),
                    new CameraMessage(CameraAction.PanUp, CameraActionState.Start));

_messageBroker.Bind(new KeyboardMessage(KeyboardButton.KEY_W, KeyAction.Released),
                    new CameraMessage(CameraAction.PanUp, CameraActionState.Stop));

The MessageBroker subscribes to all Messages and checks a Map to see if anything is bound to to the message being passed in. The problem I think I'm going to be running into is an explosion of Message classes and enumerations and that could be a problem to manage. I've played around with the concept of using delegates but I need the ability to serialize the object for Message matching within the MessageBroker:
new KeyboardMessage(KeyboardButton.KEY_W, KeyAction.Released)
must always equal
new KeyboardMessage(KeyboardButton.KEY_W, KeyAction.Released)
I was wondering if anyone else has implemented a similar system or a system that accomplishes the same thing and could offer some advice on the subject. Let me know if you need any more implementation details.

Share this post


Link to post
Share on other sites
Advertisement
I think there have been 3 or 4 threads about this sort of thing in the last couple of weeks. Typical keywords you might see are 'events', 'delegates', 'signals', 'slots'...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!