On Thu, Aug 21, 2008 at 5:45 PM, Vincent Verhoeven <[EMAIL PROTECTED]> wrote: > On Thu, Aug 21, 2008 at 11:03 PM, Victor Ivri <[EMAIL PROTECTED]> wrote: >> >> I'm afraid it doesn't work "out of the box" :( . The server accepts >> it, but the response doesn't get registered with the client; it just >> waits for it indefinitely. > > I'm not sure what the response is supposed to be, I don't get/use one > anyway in libtpclient-py.
Right, that's the key! The server simply does not return a frame after sending "finished turn". I was waiting for any type of frame, most likely OK, but the point is that the connection waited for the reply in vain. Now I tried to send it without waiting for a reply, and it worked like a charm. > > You should probably regularly poll the server to determine the end of > turn time and base yourself on that. I have the following code: > > connection.turnfinished() > waitfor = connection.time() > while waitfor > 1: > time.sleep(1) > waitfor = connection.time() > time.sleep(2) > > The problem is that the end-of-turn time can be changed while you are > waiting for it, so you have to poll the server to see if your value is > still up to date. My code seems to work pretty fine for the job. Hm, so you're waiting for 2 milliseconds after the turn has finished, to commence your own "start of turn" sequence? I did that, too, at first, but my mentor alerted me to the problem that the server may choose any length of time between end of turn, and start of new turn. If it's longer than 2ms (or 2 secs), the code will no longer work. You can do a sequence of 2 loops: one waits for connection.time() = 0, then goes to another, that waits for connection.time() > 0, which is the start of the next turn. Or else, what I did, is have the Visitor push a "turn start" flag in the client, and then set up a loop which waits for the value there to change. PS- apologize for the last email... I pushed "send" before even starting to write this! -- Victor. Truth is greater than ten goats (Nigerian proverb). _______________________________________________ tp-devel mailing list [email protected] http://www.thousandparsec.net/tp/mailman.php/listinfo/tp-devel
