Reply half-received ?

yrc yohann at varyoh.com
Tue Oct 25 19:58:54 PDT 2005


Hello!

I'm trying to continue my player :-)

So, all signals works fine, but now, I'm trying to get a result of a
method.
So I have, on the server side:


static void
handle_get_current_song (DBusMessage *message)
{
	printf("Hey... Here is a job for me! ");
	DBusMessage *reply;

	reply = dbus_message_new_method_return(message);
	
	dbus_message_append_args (reply,
			DBUS_TYPE_STRING, "Hello World",
			DBUS_TYPE_INVALID);

	dbus_connection_send (bus_conn, reply, NULL);
	dbus_message_unref (reply);
	dbus_connection_flush (bus_conn);
	printf("reply sent.\n");
}
/*-------------------------------------------------------*/

And, on the client side:

int
send_get_current_song ()
{
	DBusMessage *message;
	DBusError error;
	char* path = 0;
	
	dbus_error_init (&error);

	message = dbus_message_new_method_call (
			VNAP_DBUS_SERVICE,
			VNAP_PLAYER_PATH,
			VNAP_PLAYER_INTERFACE,
			VNAP_PLAYER_GET_CURRENT_SONG);

	dbus_message_append_args (message,
			DBUS_TYPE_INVALID,
			DBUS_TYPE_STRING, &path,
			DBUS_TYPE_INVALID);

	dbus_connection_send_with_reply_and_block (bus_conn, message, 2000,
&error);
	dbus_message_unref (message);
	dbus_connection_flush (bus_conn);

	if (dbus_error_is_set (&error)) {
		printf ("Failed to get current song: %s", error.message);
		dbus_error_free (&error);
		free(path);
		return 0;
	}
	
	printf(">>> %s\n", path);
	free(path);
	return 1;
}

/*-------------------------------------------------------*/


Here is the server execution:
unknown message received
unknown message received
get_current_song
Hey... Here is a job for me! reply sent.


And for the client:
>>> (null)


So, two questions:
As you can see, the server receive the method call, because wee can see
"Hey...". and it seems to answer to it since the client receive an
answer (no timeout or another error...), but the "Hello World" is not
set to path (that's why i said half-received ;-) )! what i'm doing
wrong?

This was the first question; and the second one:
Why do my server receive two messages when I run it, even without any
client.... Maybe you will need more code for this.... or does it
happends each time?

Thank'

Yohann.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 481 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/dbus/attachments/20051025/a0b74958/attachment.pgp


More information about the dbus mailing list