Permalink
Browse files

loggingproxy: record timing of events for accurate replay

  • Loading branch information...
1 parent e0875b8 commit 19b48c46935db9820e47502d3f3421ff27ffdc4b @sibson committed Oct 7, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 vncdotool/loggingproxy.py
View
@@ -16,9 +16,9 @@
5: 6,
}
-
REVERSE_MAP = dict((v, n) for (n, v) in KEYMAP.iteritems())
+
class RFBServer(Protocol):
_handler = None
@@ -168,6 +168,7 @@ def connectionMade(self):
portforward.ProxyServer.connectionMade(self)
RFBServer.connectionMade(self)
self.mouse = (None, None)
+ self.last_event = time.time()
def dataReceived(self, data):
RFBServer.dataReceived(self, data)
@@ -178,17 +179,25 @@ def _handle_clientInit(self):
self.peer.startLogging()
def handle_keyEvent(self, key, down):
+ now = time.time()
+
if key in REVERSE_MAP:
key = REVERSE_MAP[key]
else:
key = chr(key)
+ self.logger('pause %f\n' % (now - self.last_event))
+ self.last_event = now
if down:
self.logger('keydown %s\n' % key)
else:
self.logger('keyup %s\n' % key)
def handle_pointerEvent(self, x, y, buttonmask):
+ now = time.time()
+
+ self.logger('pause %f\n' % (now - self.last_event))
+ self.last_event = now
if self.mouse != (x, y):
self.logger('move %d %d\n' % (x, y))
self.mouse = x, y

0 comments on commit 19b48c4

Please sign in to comment.