Idle timeouts

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Queller
Posts: 9
Joined: 12 Oct 2011, 15:36

Idle timeouts

Postby Queller » 07 Jan 2013, 08:48

Hey all... what is the officially recommended way to make the SFS receive a client request but *not* reset the idle timeout clock? I want to be able to send a client request but have the SFS ignore the request from the idle timeout perspective and just keep the clock counting down. I see several different options in the User class and ISession but do not know which is appropriate for this purpose.
User avatar
Lapo
Site Admin
Posts: 21090
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Idle timeouts

Postby Lapo » 07 Jan 2013, 09:46

There isn't a way to do this. Every command sent to the server will reset the timeout clock.
Can you explain what would be the use case?
Lapo
--
gotoAndPlay()
...addicted to flash games
Queller
Posts: 9
Joined: 12 Oct 2011, 15:36

Re: Idle timeouts

Postby Queller » 07 Jan 2013, 15:50

Hi Lapo. Sure... the use case is an implementation of a basic network time protocol as seen here http://en.wikipedia.org/wiki/Network_Time_Protocol#Clock_synchronization_algorithm. The sync request is made by the client every few minutes, in effect destroying idle timeouts and for this reason I wanted to have the SFS selectively ignore/circumvent any sync request timeout resets. I pondered that perhaps doing something like user.setLastRequestTime(user.getLastRequestTime()) would suffice but I also considered it might be an unexposed mechanism and came here to find out. The problem is the client must be the initiator so it can keep track of request/response packet's time-of-flight and correct for network latency... is there some way of implementing a network time sync protocol and still keep idle timeouts working?
User avatar
Lapo
Site Admin
Posts: 21090
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Idle timeouts

Postby Lapo » 07 Jan 2013, 16:40

Code: Select all

user.setLastRequestTime(user.getLastRequestTime())

This will not work because the User timer is updated by the server. Whether it does it before or after your Extension handler (I should check) your code will not override it.

There are a couple of simple alternatives:

1) Implementing the idle-disconnection on the client side
2) Setting the User idle timer to a value shorter than the clock request so that when the player becomes inactive it will be properly detected.

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
levancho
Posts: 71
Joined: 27 Jun 2011, 16:03

Re: Idle timeouts

Postby levancho » 10 Jan 2013, 22:20

Theoretically you could use a servlet container that is bundled with sfs to synch the clocks and make sync request to plain old servlet instead of smatfox. this would keen idle timeout intact.

We do not use jetty that ships with smarfox but a seperate instance of tomcat but idea should be the same.
User avatar
Lapo
Site Admin
Posts: 21090
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Idle timeouts

Postby Lapo » 11 Jan 2013, 09:07

That is actually a good idea too.
Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
Queller
Posts: 9
Joined: 12 Oct 2011, 15:36

Re: Idle timeouts

Postby Queller » 14 Jan 2013, 21:49

Levancho - At your suggestion I just learned how to make a servlet (didn't know anything about them before) and have the SFS Jetty serving up a time sync, circumventing the SFS timeout reset and giving me exactly what I need. Thank you very much!

For anyone else who is a new to this: If you want to make a servlet to run on the included web server get started here: http://www.seas.upenn.edu/~cis330/jetty.html. The directory of interest with SFS is SmartFoxServer2X/SFS2X/www/ instead of "webapps" as the tutorial uses.

You will also need the the Jetty servlet api for the version that SFS runs (currently 6.1.26... correct me if this is incorrect). Get it from here: http://dist.codehaus.org/jetty/jetty-6.1.26/jetty-6.1.26.zip
User avatar
Lapo
Site Admin
Posts: 21090
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Idle timeouts

Postby Lapo » 15 Jan 2013, 10:24

The servlet API is already provided with SFS2X under the lib/jetty/ folder.
Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Google [Bot] and 11 guests