# Dispatching messages from juce\_xxx\_Messaging.cpp

**URL:** <https://forum.juce.com/t/dispatching-messages-from-juce-xxx-messaging-cpp/2886>\
**Category:** General JUCE discussion\
**Created:** [May 28, 2008, 7:07pm UTC](https://forum.juce.com/t/dispatching-messages-from-juce-xxx-messaging-cpp/2886 "2008-05-28T19:07:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![agillesp](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/agillesp/32/434_2.png) [@agillesp](https://forum.juce.com/u/agillesp)\
**Post date:** [May 28, 2008, 7:07pm UTC](https://forum.juce.com/t/dispatching-messages-from-juce-xxx-messaging-cpp/2886/1 "2008-05-28T19:07:42Z")

</div>

I’ve patched both juce\_win\_Messaging.cpp and juce\_mac\_Messaging.cpp so that they receive events when media is inserted/ejected, but I’m not exactly clear on the best way to get these messages to my app.

I’m currently using

MessageManager::getInstance()-\>deliverBroadcastMessage(T(“CRDOM\_INSERTED”));

which works, but hardly seems ideal. I’d like to be able to send parameters with the message, like I could with Message instance, but I can’t see a way to do it. Any suggestions?

Thanks,

Art

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 29, 2008, 10:42am UTC](https://forum.juce.com/t/dispatching-messages-from-juce-xxx-messaging-cpp/2886/2 "2008-05-29T10:42:13Z")

</div>

Broadcast messages are for inter-process messages so can’t carry much data.

Why not just make an abstract listener class, let the listeners register with a singleton “disk insertion manager” class, and call them back?

---

<div class="post-metadata">

**Author:** ![agillesp](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/agillesp/32/434_2.png) [@agillesp](https://forum.juce.com/u/agillesp)\
**Post date:** [May 29, 2008, 4:36pm UTC](https://forum.juce.com/t/dispatching-messages-from-juce-xxx-messaging-cpp/2886/3 "2008-05-29T16:36:12Z")

</div>

Thanks for the suggestion, Jules. I was hoping to keep type information from my app out of the juce code to keep maintenance headaches to a minimum.

Wouldn’t a more generic way of handling this be to have JUCEApplication implement MessageListener?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 29, 2008, 5:03pm UTC](https://forum.juce.com/t/dispatching-messages-from-juce-xxx-messaging-cpp/2886/4 "2008-05-29T17:03:04Z")

</div>

> [@](#):
>
> Wouldn’t a more generic way of handling this be to have JUCEApplication implement MessageListener?

Can’t see how that’d help. And disk drive notifications have nothing to do with the application object anyway, so it doesn’t belong there. Using listener classes and a manager object that can register them for callbacks is a much neater way of doing things like this, and doesn’t spill over into any other parts of the code.
