Skip to content

Commit

Permalink
Refactored and fixed error when linkin to worker.
Browse files Browse the repository at this point in the history
  • Loading branch information
raksooo committed May 18, 2015
1 parent eed79d8 commit fc84508
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ app.post('/receive', function(req, res) {
sse.send({'type': 'start'});
dockerx.server.receive(name, port).then((imageHash) => {
let servePort = 7021;
dockerx.run(imageHash, servePort);
console.log(timestamp() + " FINISHED, running at port: " + servePort + "\n");
sse.send({'type': 'finished', 'port': servePort})
dockerx.run(imageHash, servePort);
});

// response to post request:
Expand Down
2 changes: 1 addition & 1 deletion src/components/ClientPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ let ClientAgreement = React.createClass({
}
let address = workerInfo[1] + ":" + port;
if (port) {
address = (<a href="http://{address}">{address}</a>);
address = (<a href={"http://" + address}>{address}</a>);
}
return (
<span>
Expand Down
21 changes: 12 additions & 9 deletions src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import "bootstrap";
let DefaultRoute = Router.DefaultRoute;
let RouteHandler = Router.RouteHandler;
let Route = Router.Route;
let es;

let App = React.createClass({
checkForAgreement(worker, agreement, callback) {
Expand Down Expand Up @@ -52,15 +53,17 @@ let App = React.createClass({
}
},
workerEnableXfer(agreement) {
let es = new EventSource('/stream');
es.onmessage = function(event) {
console.log(event);
let data = JSON.parse(event.data);
if (data.type === 'finished') {
console.log("Docker port to contract: ", data.port);
EthClient.contract.setWorkerPort(data.port);
}
};
if (!es) {
es = new EventSource('/stream');
es.onmessage = function(event) {
console.log(event);
let data = JSON.parse(event.data);
if (data.type === 'finished') {
console.log("Docker port to contract: ", data.port);
EthClient.contract.setWorkerPort(data.port);
}
};
}
$.post("/receive", {
port: DockerConfig.port
}, (data) => {
Expand Down

0 comments on commit fc84508

Please sign in to comment.