Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

strahan

Server management of players any connection transfers

This topic is 5221 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have two Networking questions: 1) For each player in the game does the server track their "heartbeat" by a seperate thread or by a async callback function? What''s the average time for a heartbeat of a player? 1 second? 2) For massive online games obviously one server is not enough. Is there any documentation out there that shows how players are transfered from one box to another? I would imagine each map/zone is on a different server and when a player moves from one zone to another his connection is somehow transfered. How, is this usually done? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
I think we use five second heartbeats. However, whenever you actually DO anything, we send data at 10 packets per second, so the heartbeats are unlikely to be needed most of the time. We use a single message queue that everything runs off of, single-threaded, using select(), and it scales pretty well. We're memory bound on the servers anyway, so multi-threading on multiple CPUs wouldn't help us; it would actually hurt us.

When you're "zoning" like in EQ or CoH, then it's very simple; the client disconnects from the previous server, and connects to the new server; meanwhile, the character login server tells the new server where you will be arriving. This could be similar to logging out, changing your position record, and then logging back in again -- there really isn't that much of a difference.

When you use a zone-less world, it's harder, as you typically need to talk to two servers during the interim, and run two copies ("ghosts") of your character in tandem while transferring ownership.


Edit: clarified heartbeat.

[edited by - hplus0603 on June 6, 2004 6:34:19 PM]

Share this post


Link to post
Share on other sites
Hello and thanks for the response. When I say "heartbeat" I mean the heartbeat of each player on the server, not that rate of sending info to the player. For example:

LPMud living.c source:


heartbeat()
{
if(true == poisoned) hit_points--;

if(hp == 0) dead = true;

etc...
}


At the end of heartbeat should I do a Sleep(1000) (1 second) then do a async callback to it again or have a master loop in a seperate thread that goes through all players heartbeats everytime a second goes by?

Thanks again!

[edited by - strahan on June 7, 2004 1:10:01 AM]

Share this post


Link to post
Share on other sites
General rule of thumb is to avoid adding extra threads when you don''t have to. Also, it''s a very bad idea to call Sleep() in a game loop, as that will cause the entire thread to block for the specified amount of time. This means your entire application will become non-responsive.

Rather, you want to use a variable that keeps track of the last time you checked the heartbeat. For example:

heartbeat()
{
if(TimeNow - lastChecked > 1)
{
// Do heartbeat processing
lastChecked = TimeNow;
}
}

The processing code will only execute once one second has elapsed from the last time you checked, and it''s updated each time as well. This is a common technique used to time events that happen every X seconds, or frames.

Share this post


Link to post
Share on other sites
You want a heart-beat on the wire, to avoid timing out idle players on their firewalls and whatnot.

I recommend structuring your server as an event queue, implemented as a priority queue on time. Your objects would add themselves to this queue to get regular callbacks. Your main loop looks like:


forever() {
now = currentTime
item = queue.firstItem();
while( item->time < now ) {
queue.remove( item );
item->callback();
item = queue.firstItem();
}
timeout = queue.firstItem()->time - now;
select( ...., timeout );
processNetworkData( .... );
}


I e, you''ll alternate processing events, and processing I/O, where the select() serves to sleep during periods of low activity. You may want to make the rule that objects can only ever enqueue events at a time that is larger than "now" to avoid live-lock.

Another way of getting a heart beat for objects is to register all objects with a world manager, and the world manager will poll all objects for how they affect the world at a regular pace. For a MMOFPS or VR system, you''ll probably want this to be 30 times a second. For a MMORPG, it might go as slow as once a second (depending on your combat system, among other things).

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!