Sign in to follow this  
HexDump

Event Manager revisited.

Recommended Posts

Hi!,

First of all I want to apologize for posting about this subject, I know there are a lot of threads on the subject, and I have read some of them, but can't get my head around it (A way that satisfies me). If anyone could help I would be really greatefull.

First of all, I wanna use boost::signals for the matter. And I want my system to serve for system messages and entity messages.

The only thing I have come across is a monolitic Event Manager class, with a map < id message, vector of boost::functions >. Where objects register to listen to a certain event.

Checking boost::signals documentation it seems they could serve when objects/systems are the place where listeners are registered but not for the design I have come with. Example: can't have a map of map< id message, std::signal> and when you add a listener look for the mesage type and connect to the signal. This is why I have the map <int, boost::function>. The other problem with my sistem is that it is good for sending messages to anonymous objects, but what about if you wnat the message to be targeted to a certain instance?. I could be sending the message to all listeners and let the listener decide if it is interested in the message when targeted do X, but I think it is pretty ugly.

Well, sorry for the long text, I have spent all day on this and I'm a bit fuzzy. Could anyone help here?.

Thanks in advance,
HexDump.

Share this post


Link to post
Share on other sites
I'm going to go at this gently because I'm also a bit fuzzy today.

There are several kinds of message systems;


1) Broadcast. It's like the radio.

The transmitter sends out information. Listeners decide if they want to know it. So the shipping forecast tells you what the weather will be all round the UK's seas. You just pay attention to the bits for the area you're in. You only listen to one thing. It's usually a "one speaks to many" channel.

2) Subscription. It's like a magazine.

The information receivers ask to be sent the magazine, which are all about different subjects. So if you want to know about new stuff happening in chemistry, you subscribe to "Chemistry Month" and you know what arrives is at least relevant. You can have multiple subscriptions and start/stop them when you want. These are either "one to many" or "many to many" channels.

3) Noticeboard. It's like a noticeboard.

There are sections where people get to pin things up about those subjects. Information receivers get to go to the pinboard when they want to find out things. This one is "many to many" but also stores information.

4) Post. It's like getting letters in the mail.

So this is where the information sender sends out a letter talking about something to another object. It's a "one to one" transmission.




You use these for different things. System messages are likely to be Broadcast all over the place. Keypresses might be subscriptions. A button being clicked and activating something would be a postal operation.

So, the first thing is to decide which kind of system you're looking for -- and don't get hung up on details about boost::signals and maps until you've made that decision first.

Share this post


Link to post
Share on other sites
Hi!,

Thanks for the information, never have seen things that way.

So, do you mean, for my game I should be using a different system depending on the parts I want to communicate? Or should I implement different modes in the event manager? I mean, for example "say this to all" (broadcast), "say this to one" (Post), or "say this to this set of interested budies" (Subscription). Noticeboard seems like pooling to me.

I would need the first 3 types, broadcast (for example, level finished), post (for example tell this entity that is tracking me that I'm dead), and the subscription one.

SO, what I have been trying is to try to design a clean way to acclompish the above but all systems seems to have its drawbacks/advantages.

Thanks in advance,
HexDump.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this