What does ofApp::gotMessage() do?

What does ofApp::gotMessage(ofMessage msg) do?

It seems like it’s some kind of a listener function.

If so, what does it exactly listen to?

better late than never, I suppose :roll_eyes: you can send messages with ofSendMessage(arg) where arg can be a string or a fully featured ofMessage, see docs here

https://openframeworks.cc/documentation/events/ofEvents/#show_ofSendMessage

and then catch it in gotMessage(ofMessage msg). If you sent a string it can be read in msg.message

I have no idea if this messaging mechanism is safe to use for communication between threads or not, can someone more knowledgeable tell if this is the case?

ciao
Davide

yes any ofEvent is thread safe, ofFastEvent is faster and not thread safe

That’s cool! Is there a way to receive the messages in some other class (or different place in code) or they can only be seen in ofApp::gotMessage()?

thanks!

you can listen to ofEvents().messageEvent from anywhere

1 Like