Commit 0154eeef authored by Leo Iannacone's avatar Leo Iannacone

client emit only one event: get-view

parent 3e408d77
...@@ -39,11 +39,13 @@ app.get('/', routes.index); ...@@ -39,11 +39,13 @@ app.get('/', routes.index);
io.sockets.on('connection', function(socket) { io.sockets.on('connection', function(socket) {
send.distributions(socket); send.distributions(socket);
socket.on('get-packages-list', function(distro) { socket.on('get-view', function(data) {
send.packages_list(socket, distro); if (! data.package) {
}); send.packages_list(socket, data);
socket.on('get-package', function(package_info) { }
send.package(socket, package_info); else {
send.package(socket, data);
}
}); });
}); });
......
...@@ -36,11 +36,11 @@ debomatic_sender = { ...@@ -36,11 +36,11 @@ debomatic_sender = {
}); });
}, },
packages_list: function(socket, distro) { packages_list: function(socket, data) {
distro_path = path.join(BASE_DIR, distro, 'pool'); distro_path = path.join(BASE_DIR, data.distribution, 'pool');
get_files_list(distro_path, true, function (packages) { get_files_list(distro_path, true, function (packages) {
result = {} result = {}
result.distribution = distro; result.distribution = data.distribution;
result.packages = [] result.packages = []
packages.forEach( function (p) { packages.forEach( function (p) {
pack = {} pack = {}
......
...@@ -8,16 +8,15 @@ ...@@ -8,16 +8,15 @@
<script> <script>
function get_path(path) { function get_path(path) {
info = path.split('/'); info = path.split('/');
data = {}
if (info.length >= 1) { if (info.length >= 1) {
socket.emit("get-packages-list", info[0]); data.distribution = info[0];
} }
if (info.length >= 3){ if (info.length >= 3){
data = {}
data.distribution = info[0];
data.package = info[1]; data.package = info[1];
data.version = info[2]; data.version = info[2];
socket.emit("get-package", data);
} }
socket.emit('get-view', data);
} }
var socket = io.connect('//localhost:3000'); var socket = io.connect('//localhost:3000');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment