(02-08-2019, 09:51 AM)Jose Nilton Pace Wrote: Hi Ioan. Every Form has a property KeepAlive, just set it to true.
IW can do this for you in the same way as you said to put iwtimer in all forms.
Remove the iwtimer and set KeepAlive := True;
Hi Jose,
Is there a event handler for the KeepAlive messages? In my implementation I count how many times the HeartbeatTimer timer fires and for some parts of the web application I allow it to time out, something like this:
Code:
procedure TformUserMenu.HeartbeatTimerAsyncTimer(Sender: TObject; EventParams: TStringList);
begin
StopHeartbeatTimer(HeartbeatTimer);
end;
procedure StopHeartbeatTimer(AHeartbeatTimer: TIWTimer; ACount: integer);
var
iHeartbeats: integer;
begin
if ACount > 0 then
iHeartbeats := ACount
else
// a hearthbeat is every 20 seconds, so the timeout its (iHeartbeats * 20) seconds.
if UserSession.LevelString = 'USER' then
iHeartbeats := 30
else if (UserSession.LevelString = 'AGENT') or (UserSession.LevelString = 'COMPANY') then
iHeartbeats := 45
else
Exit; // do not timeout
if AHeartbeatTimer.Tag > iHeartbeats then
AHeartbeatTimer.Enabled := false;
AHeartbeatTimer.Tag := AHeartbeatTimer.Tag + 1;
end;
