From fa8f14d56d438ef4798706f3d331fd1ca445af42 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Sun, 26 Jun 2011 14:17:42 -0500 Subject: [PATCH] Fix playback of recorded VNC. - Update test mode calls to work with separate websock module. - Pull in include/websock.js update 7f487fdbd from websockify. --- include/rfb.js | 6 ++---- include/websock.js | 24 ++++++++++++++++++++---- tests/vnc_playback.html | 6 ++++-- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/include/rfb.js b/include/rfb.js index a743c1aa..8b9eb252 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -1512,12 +1512,10 @@ that.clipboardPasteFrom = function(text) { //Util.Debug("<< clipboardPasteFrom"); }; +// Override internal functions for testing that.testMode = function(override_send) { - // Overridable internal functions for testing test_mode = true; - // TODO figure out what to do here - ws.send = override_send; - that.recv_message = ws.recv_message; // Expose it + that.recv_message = ws.testMode(override_send); checkEvents = function () { /* Stub Out */ }; that.connect = function(host, port, password) { diff --git a/include/websock.js b/include/websock.js index 992e1900..df4827af 100644 --- a/include/websock.js +++ b/include/websock.js @@ -59,7 +59,9 @@ var api = {}, // Public API 'open' : function() {}, 'close' : function() {}, 'error' : function() {} - }; + }, + + test_mode = false; // @@ -253,9 +255,13 @@ function init() { function open(uri) { init(); - websocket = new WebSocket(uri, 'base64'); - // TODO: future native binary support - //websocket = new WebSocket(uri, ['binary', 'base64']); + if (test_mode) { + websocket = {}; + } else { + websocket = new WebSocket(uri, 'base64'); + // TODO: future native binary support + //websocket = new WebSocket(uri, ['binary', 'base64']); + } websocket.onmessage = recv_message; websocket.onopen = function() { @@ -289,6 +295,15 @@ function close() { } } +// Override internal functions for testing +// Takes a send function, returns reference to recv function +function testMode(override_send) { + test_mode = true; + api.send = override_send; + api.close = function () {}; + return recv_message; +} + function constructor() { // Configuration settings api.maxBufferedAmount = 200; @@ -319,6 +334,7 @@ function constructor() { api.init = init; api.open = open; api.close = close; + api.testMode = testMode; return api; } diff --git a/tests/vnc_playback.html b/tests/vnc_playback.html index 9f122115..a258a476 100644 --- a/tests/vnc_playback.html +++ b/tests/vnc_playback.html @@ -95,6 +95,7 @@ mode = 'realtime'; } + recv_message = rfb.testMode(send_array); next_iteration(); } @@ -106,7 +107,9 @@ iter_time = parseInt(total_time / iterations, 10); message(iterations + " iterations took " + total_time + "ms, " + iter_time + "ms per iteration"); - rfb.get_canvas().stop(); // Shut-off event interception + // Shut-off event interception + rfb.get_mouse().ungrab(); + rfb.get_keyboard().ungrab(); $D('startButton').disabled = false; $D('startButton').value = "Start"; @@ -125,7 +128,6 @@ message("VNC_frame_data.length: " + VNC_frame_data.length); rfb = new RFB({'target': $D('VNC_canvas'), 'updateState': updateState}); - rfb.testMode(send_array); } }