I can sympathize with your current problem. I'm working on a 4 player, tcp-networked game and have spent the last 4 days trying to solve a similar problem. If the "listening loop' isn't setup just right, things quickly get "out of synchronization" and I end up with a situation where clients have to hit enter a few times, to be brougt back into "sync".

All I can say is setup a test network, and hack,hack,hack :-) Sooner or later you will find the right place to put the update code. In my situation, I've resorted to "tagging" the data being sent from the server, with "to_all", or to "$player_only", and have the client's listening loop filter it accordingly.

I have found this quite difficult to get a handle on, because of the complexity of remembering that the callbacks in the server are "client specific", and it's real easy to think the data is being broadcast, when in actuality it's only going to 1 client. And the inverse problem, when you want to broadcast to everyone, but the last-client to send, gets the data twice, because you happen to be in it's client specific callback. The worst problem being your brain gets "numbed" by trying to absorb it all, and you can easily "get on a wrong track".

So setup a local IRC server, and a few test clients, and start trying different code. Evertime you reach a point, where things seem to be working, save a backup of the code, so you can revert to it, if your attempt at the next step, proves a dead-end.


I'm not really a human, but I play one on earth. flash japh

In reply to Re: Design decision, call backs and network data by zentara
in thread Design decision, call backs and network data by BUU

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.