Permalink
Browse files

thumb event polling now working properly

  • Loading branch information...
1 parent d792335 commit 8f018108cca3000038e4cc8785a7fd709da959b3 @substack committed Sep 29, 2010
Showing with 17 additions and 17 deletions.
  1. +17 −16 lib/models/process.js
  2. +0 −1 static/js/site.js
View
@@ -1,4 +1,5 @@
var fs = require('fs');
+var sys = require('sys');
var path = require('path');
var RemoteEmitter = require('dnode/events');
@@ -46,33 +47,33 @@ function Process (params) {
FB(self.address, self.engine, function (err, fb) {
if (err) throw err;
- fb.encoder.on('end', function () {
- self.emit('exit');
- });
- framebuffer = fb;
- self.emit('ready');
-
- var elapsed = 0;
- var lastUpdate = 0;
- function update () {
- if (self.connections == 0) return;
- if ((Date.now() - lastUpdate) / 1000 > 10) {
+ var hasUpdates = false;
+ var iv = setInterval((function f () {
+ if (hasUpdates && self.connections > 0) {
fb.encoder.requestRedraw();
+ hasUpdates = false;
}
- lastUpdate = Date.now();
- }
+ return f;
+ })(), 3000);
- fb.encoder.on('raw', update);
- fb.encoder.on('copyRect', update);
+ fb.encoder.on('end', function () {
+ clearInterval(iv);
+ self.emit('exit');
+ });
fb.encoder.on('screenUpdate', function (rect) {
if (rect.fullScreen && self.connections > 0) {
var file = thumbDir + '/' + self.address + '.png';
saveRect(file, rect);
-console.log('emit!');
self.emit('thumb', rect.width, rect.height);
}
+ else {
+ hasUpdates = true;
+ }
});
+
+ framebuffer = fb;
+ self.emit('ready');
});
}, 500);
View
@@ -31,7 +31,6 @@ function registerDisk (disk, filename) {
});
sub.on('thumb', function () {
-console.log('caught thumb');
procElem.find('img').remove();
procElem.append(makeImg());
});

0 comments on commit 8f01810

Please sign in to comment.