[bedevtalk] SendReply seems actually to succeed only the first time for me
John Ashmun
jrashmun at halcyon.com
Thu Aug 27 19:52:19 EDT 2009
Hello.
After quite a long delay, I've resumed developing a little on my
development BeBox.
Here's my scenario: I have two teams, which can be considered a
server and a client, intended to be run on the same system (the server
is useful running alone, and the client provides a simple user
interface for it).
The server spawns and starts a thread which does some calculations,
while its main thread runs its message loop.
When the client is started, it sends a BMessage containing its
be_app_messenger to the server. The server's main thread caches that
BMessenger.
When a button is clicked in the client's window, the client forwards
the button's message to the server. This causes the server to begin
sending messages about its state to the client. The client displays
the state data in its window.
Here's my problem: I don't want to flood the client with messages
that cause the screen to be updated so often that the user would have
no chance to read the data, but I do want frequent automatic updates
until another button is clicked (causing the server to stop sending
messages), so my protocol also requires the server to receive a reply
from the client before it sends another message with its latest state
data. In the server, I used the flavor of SendMessage( msg, &reply )
that waits for a reply to arrive, but what I found is that although
the status returned by SendReply( ... ) in the client succeeds when it
replies to each of the first two server state messages, the reply
BMessage received by the server has a what value of B_NO_REPLY for the
second reply. Why is this?
(I've worked around this by calling the SendMessage( msg ) flavor that
doesn't expect a reply in the server and setting a flag in there to
skip sending its messages, and by sending the client's replies using
SendMessage( ) rather than SendReply( ), and in the server main
thread's MessageReceived( ) function, clearing the flag when a reply
has arrived from the client, but I'd like to know what wasn't working
when I tried waiting for a reply message via SendReply( ).)
Regards,
John
More information about the bedevtalk
mailing list