Trying to change the GameConnection onDrop time
by Sam Redfern · in Torque Game Engine · 03/10/2006 (9:05 am) · 5 replies
I'm trying to find out how to change the delay after a client connection is dropped, before the GameConnection::onDrop script callback happens. The reason I need this is that my game has timeouts in it, and I want a timeout to be called automatically if a client connection drops: I don't want the server to wait for 60 seconds before the GameConnection::onClientLeaveGame(%client) script function happens.
I have traced it back as far as the GameConnection::onRemove() function in the engine but I'm not sure where it comes from before that.
I know I've seen it before somewhere, but can't find it.....
can anyone help?
thanks!
Sam.
I have traced it back as far as the GameConnection::onRemove() function in the engine but I'm not sure where it comes from before that.
I know I've seen it before somewhere, but can't find it.....
can anyone help?
thanks!
Sam.
About the author
#2
At the top of netConnection.cc is this:
enum NetConnectionConstants {
PingTimeout = 4500, ///< milliseconds
DefaultPingRetryCount = 15,
};
I expect that reducing these numbers should give the result I need. I'll probably do something less drastic like pre-emptively make the player issue a "please wait for me" timeout rather than killing their connection straight away.
03/10/2006 (12:29 pm)
Thanks David, you pointed me in the right direction I think.At the top of netConnection.cc is this:
enum NetConnectionConstants {
PingTimeout = 4500, ///< milliseconds
DefaultPingRetryCount = 15,
};
I expect that reducing these numbers should give the result I need. I'll probably do something less drastic like pre-emptively make the player issue a "please wait for me" timeout rather than killing their connection straight away.
#3
03/11/2006 (7:07 am)
Keep in mind that Torque already does the "wait for me" part under the covers--by the time you get to the disconnection point, it has waited quite a bit to re-establish the connection, and the 4500 milliseconds at this point is basically just "proof" that the server (or at least the connection to the server) simply isn't available.
#4
The last 4.5 secs before the connection drops in Torque is of course following 14 failed pings already, so it's a little over 60 secs by default, which is a little too much for my game..
It's a turn-based game with a timelimit on setting your orders for each move. A number of timeouts are available to each player..
03/11/2006 (1:07 pm)
Stephen: I realise the confusing use of the word 'timeout' here. What I'm donig is have the whole game wait for the player, which is definitely not done in Torque already! :-)The last 4.5 secs before the connection drops in Torque is of course following 14 failed pings already, so it's a little over 60 secs by default, which is a little too much for my game..
It's a turn-based game with a timelimit on setting your orders for each move. A number of timeouts are available to each player..
#5
03/11/2006 (1:18 pm)
Gotcha! Yes, that is a bit non-standard in requirements :)
Associate David Wyand
Gnometech Inc.
I believe that what you're after starts in DemoGame::processTimeEvent(). Within that method is a call of GNet->checkTimeouts();, which is a global static call into NetInterface::checkTimeouts().
At the bottom of NetInterface::checkTimeouts() is where each existing NetConnection is checked with the call of walk->checkTimeout(time). If this method returns true, then the NetConnection is deleted, forcing the onRemove() call.
So it looks like you'll want to change how the NetConnection::checkTimeout() method operates. I believe that if you changed this method to be virtual you could then pass this functionality up to GameConnection and beyond so you don't have to twiddle with NetConnection itself.
- LightWave Dave
[edit] Oops, changed a reference to 'false' to actually read 'true' [/edit]