Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 8 down vote accepted

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.

share|improve this answer
2  
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) –  Lohoris Feb 20 '11 at 11:19
2  
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. –  Martin Feb 21 '11 at 1:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.