Receiving signals from server in C

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2014-06-13 at 17:17 +0200, Greg Knoll wrote:
> I think first it would be good to know that I'm correctly registering
> with ListenForSignal.  First I use
> 
>    conn = dbus_connection_open(serverAddress, &err);
> 
> to get a connection to PulseAudio.  Then I call the message:
> 
>     msg = dbus_message_new_method_call(
> 
>             "org.PulseAudio1",             //Destination
> 
>             "/org/pulseaudio/core1",     //Object path to call on
> 
>             "org.PulseAudio.Core1",     //Interface to call on
> 
>             "ListenForSignal");             //Method
> 
> 
> 
>     //Add arguments: s, []
> 
>     dbus_message_iter_init_append(msg, &msgIter);
> 
> 
>         //string
> 
>         dbus_message_iter_append_basic(&msgIter, DBUS_TYPE_STRING,&signalName);
> 
> 
>         //empty array to listen to all
> 
>         dbus_message_iter_open_container(&msgIter,DBUS_TYPE_ARRAY,"o",&arrayIter);
> 
>         dbus_message_iter_close_container(&msgIter, &arrayIter);
> 
> 
>     //call dbus function
> 
>     debug_print("   >...Listening for signal %s...\n",signalName);
> 
>     dbus_connection_send_with_reply_and_block (conn, msg, -1, &err);
> 
> with signalName = "org.PulseAudio.Core1.NewModule"
> 
> Is this correct if I want to be notified when all new modules are loaded?

Yes, looks correct.

> If so, I then call dbus_connection_pop_message on the private
> connection in the main loop.

How do you wait for incoming messages?

Typically you shouldn't call dbus_connection_pop_message() (even the
documentation of that function says that). If you have a main loop, you
should integrate the DBusConnection with the main loop. If you don't
have a main loop in your program, you can use
dbus_connection_read_write_dispatch().

>Do I need to add a match?

As already discussed in this thread: no, you don't need to add a match.

-- 
Tanu



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux