Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

clicking job# now restores the results to terminals, chromium nightly…

… socket.io proto isn't right yet
  • Loading branch information...
commit 01465c7f4c79ebb77cf026b380d03961be4a9037 1 parent 762aad8
@andrewxhill authored
Showing with 25 additions and 6 deletions.
  1. +16 −3 app.js
  2. +9 −3 static/js/main.js
View
19 app.js
@@ -27,9 +27,16 @@
var Thoonk = require("thoonk").Thoonk,
thoonk = new Thoonk('localhost', 6379, 'thoonk')
- var pio = require('socket.io');
- var io = pio.listen(app);
-
+ var io = require('socket.io').listen(app);
+ io.enable('browser client minification'); // send minified client
+ io.set('log level', 1); // reduce logging
+ io.set('transports', [ // enable all transports (optional if you want flashsocket)
+ 'websocket'
+ , 'flashsocket'
+ , 'htmlfile'
+ , 'xhr-polling'
+ , 'jsonp-polling'
+ ]);
var clients = {};
//the feed for our R job queue
@@ -131,6 +138,12 @@
});
});
+ socket.on('lookup-job', function (msg) {
+ clients[msg.username] = socket.id;
+ workerClient.get(msg.jobid+":result", function(err, res){
+ socket.emit("terminal-message",{message: JSON.parse(res).result.data});
+ });
+ });
/*
* socket for sending a new job for queuing
View
12 static/js/main.js
@@ -29,6 +29,10 @@ var Terminal = new Class({
self = this;
//node.js socket.io connection
this.socket = io.connect('http://localhost:3000');
+ this.socket.on('disconnect', function(){
+ console.log('whoops');
+ self.socket = io.connect('http://localhost:3000');
+ });
this.terminal = container;
this.socket.on('terminal-message',function(data) {
console.log(data);
@@ -41,6 +45,10 @@ var Terminal = new Class({
var j = new Element('a').addClass('job-link');
var s = new Element('div').addClass('job-status');
j.set('html', data.jobs[i].id);
+ j.addEvent('click',function(i, ev){
+ console.log(data.jobs[i].id);
+ self.socket.emit('lookup-job', {jobid: data.jobs[i].id});
+ }.bind(data, i));
s.set('html', data.jobs[i].status);
w.grab(j)
w.grab(s)
@@ -51,9 +59,7 @@ var Terminal = new Class({
$('queue').addEvent('click',function(){
self.queue($('script-value').value);
- });
-
-
+ });
},
// Outputs a line of text
out: function(text) {
Please sign in to comment.
Something went wrong with that request. Please try again.