moribvndvs / ng2-idle

Responding to idle users in Angular (not AngularJS) applications.
https://moribvndvs.github.io/ng2-idle
Apache License 2.0
315 stars 128 forks source link

Ng Idle pauses when system goes to sleep mode #112

Open srishti-sqm opened 5 years ago

srishti-sqm commented 5 years ago

I have used Ng Idle version 6.0.0-beta.3 and using angular 6, this library is working fine system is on but timer stops when system goes to sleep mode. How to achieve idle state is system goes to sleep?

earbullet commented 5 years ago

I'm experiencing a similar issue with the system going to sleep. idle occurs, laptop sleeps, laptop wakes and then onIdleEnd does not fire.

To duplicate: 1 - Set my idle timer at 5 seconds. 2 - onIdleStart does a console.log, see the output 3 - Widows / sleep 4 - wake 5 - Move mouse on browser and onIdleEnd does not fire.

after waking idle.isRunning() = false.

earbullet commented 5 years ago

Ok, so immediately after posting my issue with onIdleEnd I figured out my mistake. If I didn't post, I'd have never figured it out. There is a timeout after onIdleStart that defaults to 30 seconds.

I added this line and things are working fine now. this.idle.setTimeout(false);

I also tested a sleep for the idle to fire: 1 - set 60 second timer 2 - windows / sleep 3 - wake 4 - my console.log output for idle was there.

This particular timer is using SimpleExpiry. I've not tested this use case with IdleExpiry.

earbullet commented 5 years ago

By default when it goes idle it then starts a timeout timer. If there is no activity within that timer then it exits. Meaning, it will never pickup again and isn't watching for activity anymore. If you setTimeout(false) then that second timer starts so it never exits the process.

My purpose was to fire events always on idle / on no longer idle.


From: Andrew Lobban notifications@github.com Sent: Friday, October 5, 2018 10:25 AM To: HackedByChinese/ng2-idle Cc: Shawn; Mention Subject: Re: [HackedByChinese/ng2-idle] Ng Idle pauses when system goes to sleep mode (#112)

@earbullethttps://github.com/earbullet can you explain why setting this.idle.setTimeout(false) came about? Would this affect the app from ever going back into an idle state? Or was this only meant for the laptop snoozing?

My issue is that '6.0.0-beta.3doesn't seem to be firingonIdleEnd`. So I don't see my log statement if it is being fired.

idle.onIdleEnd.subscribe(() => { this.hasIdled = false; this.idleState = No longer idle.; this.status = { state: this.idleState, active: this.hasIdled }; console.log('Act-Mon', this.status.state); this.amService.setStatus(this.status); });

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/HackedByChinese/ng2-idle/issues/112#issuecomment-427384067, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AR0M8Bv6984rxOJRw58_ekU1D3rkZZjqks5uh2vngaJpZM4Vr9F0.

alobban commented 5 years ago

@earbullet can you indicate where you added this line of code?

earbullet commented 5 years ago

Right before I started the watch. It's a configuration for that particular idle service. When the user goes idle should you timeout or wait for them to become active again.

this._idle.setTimeout(false); this._idle.watch();


From: Andrew Lobban notifications@github.com Sent: Friday, October 5, 2018 10:51 AM To: HackedByChinese/ng2-idle Cc: Shawn; Mention Subject: Re: [HackedByChinese/ng2-idle] Ng Idle pauses when system goes to sleep mode (#112)

@earbullethttps://github.com/earbullet can you indicate where you added this line of code?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/HackedByChinese/ng2-idle/issues/112#issuecomment-427392840, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AR0M8Hc9xFrCzxsi4YxDQOA1oDqwC-4qks5uh3IPgaJpZM4Vr9F0.

rajasekarsphcl commented 3 years ago

@earbullet what is the actual solution for this issue ?

earbullet commented 3 years ago
constructor(@Inject('GlobalIdle') private _idle: Idle)

....

const documnetInterruptsOnly = DEFAULT_INTERRUPTSOURCES.slice(0, 1);
this._idle.setInterrupts(documnetInterruptsOnly);

this._idle.onIdleEnd.subscribe(() => {
....
});

this._idle.onIdleStart.subscribe(() => {
....
});

this._idle.setTimeout(false); // this is the line that I was missing
this._idle.watch();
rafay-veemed commented 3 years ago
constructor(@Inject('GlobalIdle') private _idle: Idle)

....

const documnetInterruptsOnly = DEFAULT_INTERRUPTSOURCES.slice(0, 1);
this._idle.setInterrupts(documnetInterruptsOnly);

this._idle.onIdleEnd.subscribe(() => {
....
});

this._idle.onIdleStart.subscribe(() => {
....
});

this._idle.setTimeout(false); // this is the line that I was missing
this._idle.watch();

Does not works on Mac! Any idea or fix?

mcrtricolor commented 1 year ago

This is not a solution to the problem, this only disables the timeout function.

I want to use the idle and timeout function, and that it takes into account if the user shutdown or put to sleep the computer.