|
|
@@ -25,10 +25,13 @@ io.on('connection', function(socket){ |
|
|
|
if (get_hostname(socket.request.headers.host) != get_hostname(socket.request.headers.origin)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// console.log("connection!"); |
|
|
|
var sid = cookie.parse(socket.request.headers.cookie).sid |
|
|
|
if(!sid) { |
|
|
|
return; |
|
|
|
} |
|
|
|
// console.log("firing get_user_info"); |
|
|
|
request.post(get_url(socket, '/api/method/frappe.async.get_user_info')) |
|
|
|
.type('form') |
|
|
|
.send({ |
|
|
@@ -45,16 +48,19 @@ io.on('connection', function(socket){ |
|
|
|
socket.join(room); |
|
|
|
socket.join(get_site_room(socket)); |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
socket.on('task_subscribe', function(task_id) { |
|
|
|
var room = 'task:' + task_id; |
|
|
|
socket.join(room); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
socket.on('progress_subscribe', function(task_id) { |
|
|
|
var room = 'task_progress:' + task_id; |
|
|
|
socket.join(room); |
|
|
|
send_existing_lines(task_id, socket); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
socket.on('doc_subscribe', function(doctype, docname) { |
|
|
|
// console.log('trying to subscribe', doctype, docname) |
|
|
|
request.post(get_url(socket, '/api/method/frappe.async.can_subscribe_doc')) |
|
|
@@ -73,10 +79,15 @@ io.on('connection', function(socket){ |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
socket.on('doc_unsubscribe', function(doctype, docname) { |
|
|
|
var room = get_doc_room(socket, doctype, docname); |
|
|
|
socket.leave(room); |
|
|
|
}); |
|
|
|
|
|
|
|
// socket.on('disconnect', function (arguments) { |
|
|
|
// console.log("user disconnected", arguments); |
|
|
|
// }); |
|
|
|
}); |
|
|
|
|
|
|
|
function send_existing_lines(task_id, socket) { |
|
|
|