dictation-toolbox/aenea — pull request #66 by calmofthestorm (2014-09-19 19:28:07+00:00)
Title: Better batching of keystrokes in dictation capture client

This addresses the issues raised in #61 related to batching together multiple requests into fewer RPC calls (and xdotool invocations) where possible.

The client's timeout has been raised from 0.1 to 2 seconds when attempting to connect to the server so as to allow the (now much larger) RPC calls to finish before the timeout. In order to maintain responsiveness when the server is down, we add a CONNECT_TIMEOUT of 0.1 seconds. The old behavior was to simply connect to the server with a low timeout. Now, when connecting to a server for the first time or the most recent attempt timed out, we will do a test connect with a low timeout first, and only proceed if that succeeds. It's a bit of a hack, but it provides good balance between allowing longer commands to execute and not lagging like crazy when the server's down.

aenea_client's buffering mostly rewritten to support the new design. Previously, the server constructed one ProxyKey per keystroke (assuming the keystroke could not be rolled into a ProxyText, which did combine intelligently). Now, the client will keep a key buffer as well, combining multiple adjacent keys into a single ProxyKey. If the server supports execute_batch, there shouldn't be a huge difference, but it should substantially improve performance with it disabled since it reduces the number of xdotool invocations.