Commit 4fbb3858 authored by Leo Iannacone's avatar Leo Iannacone

a little refactor for client - more deep refactor needed

parent 6ee9a051
......@@ -45,6 +45,7 @@ var broadcast = new Broadcaster(io.sockets, status)
io.sockets.on('connection', function(socket) {
client = new Client(socket)
client.start()
if (status.packages.length > 0)
client.send_status(status)
});
......
......@@ -142,36 +142,36 @@ function Client (socket) {
var _e = config.events.client
// init send distributions and status
utils.get_files_list(config.debomatic.path, true, function(distros) {
socket.emit(config.events.broadcast.distributions, distros);
})
// init events
socket.on(_e.distribution_packages.get, function (data) {
if (! utils.check_data_distribution(data))
return
distribution_path = path.join(config.debomatic.path, data.distribution.name, 'pool')
utils.generic_handler_watcher(_e.distribution_packages.set, socket, data, distribution_path, __send_distribution_packages)
})
socket.on(_e.package_files_list.get, function(data) {
if (! utils.check_data_package(data))
return
package_path = utils.get_package_path(data)
utils.generic_handler_watcher(_e.package_files_list.set, socket, data, package_path, __send_package_files_list)
})
socket.on(_e.file.get, function (data){
if (! utils.check_data_file(data))
return
__handler_get_file(socket, data)
})
this.start = function () {
// init send distributions and status
utils.get_files_list(config.debomatic.path, true, function(distros) {
socket.emit(config.events.broadcast.distributions, distros);
})
// init events
socket.on(_e.distribution_packages.get, function (data) {
if (! utils.check_data_distribution(data))
return
distribution_path = path.join(config.debomatic.path, data.distribution.name, 'pool')
utils.generic_handler_watcher(_e.distribution_packages.set, socket, data, distribution_path, __send_distribution_packages)
})
socket.on(_e.package_files_list.get, function(data) {
if (! utils.check_data_package(data))
return
package_path = utils.get_package_path(data)
utils.generic_handler_watcher(_e.package_files_list.set, socket, data, package_path, __send_package_files_list)
})
socket.on(_e.file.get, function (data){
if (! utils.check_data_file(data))
return
__handler_get_file(socket, data)
})
}
return {
send_status: function (status) {
socket.emit(_e.status, status)
}
this.send_status = function(status) {
socket.emit(_e.status, status)
}
}
......
......@@ -4,4 +4,8 @@ new Page_Generic().init(socket)
if (window.location.pathname == config.paths.distribution) {
new Page_Distrubion(socket).start()
}
\ No newline at end of file
}
socket.on(config.events.client.distribution_packages.status, function(data){
console.log(data)
})
\ No newline at end of file
......@@ -266,7 +266,7 @@ function Page_Distrubion(socket)
update.view()
}
this.start = function (mysocket) {
this.start = function () {
socket.on(events.distribution_packages.set, function(socket_data){
packages.set(socket_data)
......
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