Commit 5d8de71b authored by Leo Iannacone's avatar Leo Iannacone

create objects only after listing event

parent 442a0e3c
...@@ -7,19 +7,9 @@ var express = require('express') ...@@ -7,19 +7,9 @@ var express = require('express')
, routes = require('./routes') , routes = require('./routes')
, config = require('./lib/config.js') , config = require('./lib/config.js')
, utils = require('./lib/utils.js') , utils = require('./lib/utils.js')
, Client = require('./lib/client.js')
, Broadcaster = require('./lib/broadcaster.js')
var app = module.exports = express.createServer(); var app = module.exports = express.createServer();
// no log
//var io = require('socket.io').listen(app, { log: false });
var io = require('socket.io').listen(app);
// statuses
var status = {}
status.packages = []
// Configuration // Configuration
app.configure(function(){ app.configure(function(){
app.set('views', __dirname + '/views'); app.set('views', __dirname + '/views');
...@@ -46,19 +36,32 @@ app.get(config.routes.distribution, routes.distribution) ...@@ -46,19 +36,32 @@ app.get(config.routes.distribution, routes.distribution)
if (config.routes.preferences) if (config.routes.preferences)
app.get(config.routes.preferences, routes.preferences) app.get(config.routes.preferences, routes.preferences)
var broadcast = new Broadcaster(io.sockets, status) // Listening
var server = app.listen(config.port, config.host, null, function(){
var Client = require('./lib/client.js')
var Broadcaster = require('./lib/broadcaster.js')
// no log
//var io = require('socket.io').listen(app, { log: false });
var io = require('socket.io').listen(app);
io.sockets.on('connection', function(socket) { // statuses
client = new Client(socket) var status = {}
status.packages = []
var broadcast = new Broadcaster(io.sockets, status)
io.sockets.on('connection', function(socket) {
var client = new Client(socket)
client.start() client.start()
if (status.packages.length > 0) if (status.packages.length > 0)
client.send_status(status) client.send_status(status)
}); });
io.sockets.on('disconnect', function(socket){ io.sockets.on('disconnect', function(socket){
}); });
var server = app.listen(config.port, config.host, null, function(){
console.log("Debomatic-webui listening on %s:%d in %s mode", app.address().address, app.address().port, app.settings.env); console.log("Debomatic-webui listening on %s:%d in %s mode", app.address().address, app.address().port, app.settings.env);
}); });
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