RTC Forums
May 20, 2024, 01:47:00 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: SessionOpen/close events on the server  (Read 4193 times)
DPerkins
RTC License
***
Posts: 37


« on: January 17, 2014, 11:40:51 AM »

I note that both TRtcHttpServer and TRtcServerModule both have SessionOpen/Close events.  Is there any difference between the two and which one is preferred, if any?
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: January 17, 2014, 12:12:02 PM »

Sessions are not linked to requests and are handled by the TRtcHttpServer component, so the event on the TRtcHttpServer component is primary. But all OnSessionOpen/Close events are forwarded to all connected components with the same events registered, so you can implement the event handlers on any or all of them.

Best Regards,
Danijel Tkalcec
Logged
DPerkins
RTC License
***
Posts: 37


« Reply #2 on: January 17, 2014, 04:37:57 PM »

I've noticed that (auto)sessions on the server are only checked whenever a request is received.  If I close my (only) client, then the server sessions persist and my server code still thinks there are clients connected/alive.  Is there anything I can periodically call on the server to get it to recheck all open sessions and thus fire the SessionClose events?
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: January 17, 2014, 04:45:52 PM »

No. Session handling is automatic. The Server will clean up old Sessions when you try to access Sessions. This is true for AutoSessions as well as manual Sessions.

Best Regards,
Danijel Tkalcec
Logged
DPerkins
RTC License
***
Posts: 37


« Reply #4 on: January 17, 2014, 04:51:34 PM »

But my code doesn't get to know (via SessionClosed) that client sessions have closed because there has not been any requests for the past 30 minutes to trigger session expiry checking.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #5 on: January 17, 2014, 05:42:37 PM »

This is only true if nobody is accessing the Server. The purpose of Sessions is to keep user info stored on the Server. And the purpose of Session cleaning is to clean up memory from old Sessions. It is not a way to know how much time has passed since the last time a user was active. If you need to know how much time has passed since the last time user was active, you can stored the time info in the session and check it when the user comes back.

Best Regards,
Danijel Tkalcec
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.025 seconds with 17 queries.