I have a system that works with websocket in Delphi with mORMot, when I reboot the PC or when I disconnect it it executes OnClose and OnDestroy and through that I can remove the callback of the user that was logged in, but when I send hibernate or suspend I need to do the same so the user does not record as logged in.
It would also be good to warn the user that the system will be closed before it restarts / hangs up or suspend / hibernate and if possible I identify that the computer is returning from sleep / hibernation in order to register it again.
I found this example but could not understand its operation and how it is called:
Statement:
private
procedure Hiber(var pMsg: TWMPower); message WM_POWERBROADCAST;
Implementation:
procedure Tform.Hiber(var pMsg: TWMPower);
begin
if (pMsg.PowerEvt = PBT_APMQUERYSUSPEND) then
begin
// Hibernando
end
else if (pMsg.PowerEvt = PBT_APMRESUMESUSPEND) then
begin
// Retornando
end;
pMsg.result := 1;
end;