Skip to content

Commit a0fb858

Browse files
committed
fix for missing websocket
1 parent c750e7a commit a0fb858

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

controllers/editor.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var fs_helper = require('../helpers/fs_helper'),
1212
db = require('../models/webideModel'),
1313
sanitize = require('validator');
1414

15-
var REPOSITORY_PATH = path.resolve(__dirname, "../repositories")
15+
var REPOSITORY_PATH = path.resolve(__dirname, "../repositories");
1616

1717
//Loads the editor
1818
exports.index = function(req, res) {
@@ -28,6 +28,7 @@ exports.index = function(req, res) {
2828
};
2929

3030
exports.editor = function(ws, req) {
31+
config.editor_ws = ws;
3132
winston.debug('socket io connection completed');
3233

3334
function send_message(type, data) {

helpers/git_helper.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,11 @@ function push_queue_interval() {
3939
function push(repository_path, remote, branch, username) {
4040
var repo = git(repository_path);
4141
repo.push(remote, branch, function(err) {
42-
require('../server').get_socket(function(ws) {
43-
if (err) {
44-
winston.error(err);
45-
ws_helper.send_message(ws, 'git-push-error', {err: "Error: Failure pushing code to remote repository"});
46-
}
47-
//winston.debug(obj);
48-
});
42+
if (err) {
43+
winston.error(err);
44+
ws_helper.send_message(null, 'git-push-error', {err: "Error: Failure pushing code to remote repository"});
45+
}
46+
//winston.debug(obj);
4947
});
5048
}
5149

helpers/websocket_helper.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
var config = require('../config/config');
2+
13
exports.send_message = function send_message(ws, type, data) {
4+
if (!ws) {
5+
ws = config.editor_ws;
6+
}
27
ws.send(JSON.stringify({type: type, data: data}));
38
}

0 commit comments

Comments
 (0)