Q:

Session Timeout in Fiori: Does SAP UI5 or the Gateway layer provide an event which gets called when the user's session times out

I'm working on resource locking in SAP Fiori.  To be more elaborate I am trying to lock a resource once a user logs in and opens my application and unlock the resource once he logs out or gets logged out.  
I am aware of the onExit() event handler which is located in the main.controller.js and is called if the user performs an action which logs him out.  This handles all scenarios except one: when the user's session is timed out.  
Is anyone aware of a method(UI5 / Gateway layer) that is called once the session time's out?  
As far as I think how this is handled is if a user's session is timed out then nothing happens until the user refreshes the screen.  
At this point an Odata call is made to fetch data.  Once this hits the Gateway it checks and finds out that the session has timed out and triggers a relogin action.  
Correct me if I'm wrong.  If right does anyone know what is the event handler which does that? 
Also I have read up quite a bit about this.  This falls under optimistic and pessimistic concurrency.  I would like to try a pessimistic apprach and not a optimistic
approach using etags. 
Thanks in advance for your time. 
Also I cant officially post any code as it would be against policy, but if you have any queries please feel free to ask and I will do my best :).  Plus this is more a fact finding mission. 

A:

There is no way you can trust a request to be executed from a browser to signal time out.  You will end up with locked resources that shouldn't be locked due to lost connectivity, app crashing, battery drain to name a few.  A classic problem for web applications! 
Instead, you can construct a lock refresh mechanism.  Refresh the lock every 30 seconds or so in the background.  Just make sure to fetch the latest version of the resource if the lock was ever released!