Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handler for user timeout #803

Closed
totaam opened this issue Feb 6, 2015 · 12 comments
Closed

Handler for user timeout #803

totaam opened this issue Feb 6, 2015 · 12 comments

Comments

@totaam
Copy link
Collaborator

totaam commented Feb 6, 2015

Issue migrated from trac ticket # 803

component: server | priority: major | resolution: worksforme

2015-02-06 22:04:38: sbennett created the issue


Looking for a way to detect that the user has not been interacting with their XPRA session for 'x' seconds. The goal would be to do something configurable when the user has not sent any keyboard or mouse click events for the specified period of time. Mouse movements may or may not be taken into consideration depending on level of effort.

@totaam
Copy link
Collaborator Author

totaam commented Feb 7, 2015

2015-02-07 06:24:12: totaam changed owner from antoine to sbennett

@totaam
Copy link
Collaborator Author

totaam commented Feb 7, 2015

2015-02-07 06:24:12: totaam commented


We already have a value which fits the bill exactly: the ServerSource's last_user_event records when the last key event or button event was received by the server, you can see it with:

xpra info | grep client.idle_time

I think we can just add a server option (call it idle-timeout? and make it default to 0 = disabled), we then just (re-)schedule a timer in user_event().

As for the exact action to take, the easiest thing would be to hardcode it to drop the connection with a "idle timeout" warning message.
Or maybe you want to exit the server instead? (in which case this would probably need to be configurable, in a similar way to the key shortcuts in the client)

@totaam
Copy link
Collaborator Author

totaam commented Feb 8, 2015

2015-02-08 03:07:46: sbennett commented


Adding a server option + timer would be excellent.

Dropping the connection with an "idle timeout" sounds like a good (and useful) default behavior and will work well for us.

Additionally, we would need to receive an event on the server somehow so that we can decide to trigger a shutdown of the server or not.

Perhaps a method that I can override that returns true for "disconnect and shutdown" or false for "just disconnect"? Or a void method in which I could invoke a shutdown if needed?

@totaam
Copy link
Collaborator Author

totaam commented Feb 8, 2015

2015-02-08 09:31:47: totaam commented


Done in r8642.

To use it:

xpra start --idle-timeout=10

Then attach and the client should get disconnected after 10 seconds of inactivity (key presses or mouse clicks).

You can also change the timeout value at runtime using xpra control:

xpra control :DISPLAY idle-timeout 120

The value zero disables the timeout.

As for overriding the code to inject your own logic, you should be able to just override (or monkey patch) idle_timeout_cb in ServerBase.

@totaam
Copy link
Collaborator Author

totaam commented Feb 13, 2015

2015-02-13 01:47:36: antoine commented


Missed bits in r8654.

@totaam
Copy link
Collaborator Author

totaam commented Feb 18, 2015

2015-02-18 02:22:15: afarr commented


Just to make it even friendlier, would it be possible to add mouse cursor events over an xpra window which has focus to the list of events that reset timeout clock?

@totaam
Copy link
Collaborator Author

totaam commented Feb 18, 2015

2015-02-18 04:17:01: antoine commented


r8679 resets the timer when:

  • the window gains focus (usually when the user clicks on it, or alt-tabs to it) - we can easily remove this if you want, I thought it made sense
  • the mouse is moved over the window whilst it has focus

To make it easier to debug, I've added a new debug category for the server: -d timeout. Shows things like:

user_event()
schedule_idle_timeout() idle_timer=1465, idle_timeout=20
user_event()
schedule_idle_timeout() idle_timer=1467, idle_timeout=20

Something else that Scott mentioned, is the ability to have another event that fires before real the timeout so that we can trigger some things (like slowing down window updates, etc). This should probably go in a separate ticket.

@totaam
Copy link
Collaborator Author

totaam commented Feb 25, 2015

2015-02-25 05:59:46: antoine commented


Minor fixes worth having (only relevant if the timeout does not cause a disconnection): r8701 + r8702.

If that works OK then I think we can close this and follow up in #816.

@totaam
Copy link
Collaborator Author

totaam commented Mar 21, 2015

2015-03-21 18:07:09: antoine changed status from new to closed

@totaam
Copy link
Collaborator Author

totaam commented Mar 21, 2015

2015-03-21 18:07:09: antoine set resolution to worksforme

@totaam
Copy link
Collaborator Author

totaam commented Mar 21, 2015

2015-03-21 18:07:09: antoine commented


Closing this, please re-open if you have problems or follow up in #816.

@totaam totaam closed this as completed Mar 21, 2015
@totaam
Copy link
Collaborator Author

totaam commented Jan 30, 2018

2018-01-30 08:02:40: antoine commented


Improved in r18200, see #1688#comment:6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant