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