I am working on a P2P game in Flash and I'm wondering what network topology would be most robust for dealing with people randomly joining/leaving. I was thinking the first user to join could be the host, but if the host leaves the whole session would be killed. I am looking for a way to deal with this with no (or little) disruption.


1 Answer 1


If you're using a model where there's a "host", you pretty much have star topology, however you dress it up. Recovery from loss of the central node in that model requires that all the nodes be able to find each other in that event (which makes it sound like mesh topology but it isn't), and either all of them have sufficient state to be able to take over the host role or they can reconstruct that state between them. Then you elect a new host by whatever method you like (I suggest lowest average ping to the rest of the nodes).

You can potentially do that with no disruption if the host leaves "nicely"; you start the host-role transfer process when they hit Quit and let them leave when it's done. If they leave by network interruption, force-quit, power loss, etc. there will be disruption.

If you do actual mesh topology, where each node has its own full state model and communicates about changes made to that out to everybody it's connected to, then you avoid the host role and the vulnerability that comes with it. The fun part then is conflict resolution -- working out what happens when two nodes try to propagate changes that contradict each other.

  • 2
    \$\begingroup\$ If players joining and leaving is a frequent event, it would likely be better to chose as the central host not based on ping, but based on "likeliness to not disconnect". (how to determine that value, is up to you) \$\endgroup\$
    – o0'.
    Feb 20, 2011 at 11:19
  • 2
    \$\begingroup\$ Lots of P2P networks use the metric that the longer a peer has been around, the less likely they are to leave. This probably doesn't hold for games, but it would be a good starting point. \$\endgroup\$
    – Martin
    Feb 21, 2011 at 1:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .