Usecase of ofMessage?

Hello,
I am using openFrameworks for a few years now, but I have never used or seen code where ofMessage is used.
How would one use ofMessage?

1 Like

this is something we included in OF 0.7 cause some thought it could be useful to have a very generic event that could be notified from anywhere and listened to from anywhere too.

you can send a message with:

ofSendMessage("some message");

and listen to them with:

ofAddListener(ofEvents().messageEvent, this, &MyClass::messageReceived);

you could create your own message format and have different parts of your application react to them in whatever way you want.

i’ve personally never used it and don’t really think is a very good pattern. it would be the equivalent to a global variable for events which, it might be useful to hack something quick but in the long term it won’t be very clean code since every class ends up receiving events from everyone else.

1 Like

here are some examples that might help including some addons / etc:

1 Like

Thanks for explaining and thanks for github search. I see this only useful for fast prototyping and debugging.