{"size": 1032, "ext": "js", "max_stars_repo_path": "nodejs/app.js", "max_stars_repo_name": "projet-aaa/Api-Poc", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "nodejs/app.js", "max_issues_repo_name": "projet-aaa/Api-Poc", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nodejs/app.js", "max_forks_repo_name": "projet-aaa/Api-Poc", "max_forks_repo_forks_event_min_datetime": "2017-01-18T15:40:36.000Z", "max_forks_repo_forks_event_max_datetime": "2017-01-18T15:40:36.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 17.7931034483, "max_line_length": 78, "alphanum_fraction": 0.6395348837}
var redis = require('redis').createClient(6379, 'redis')
  , http = require('http')
  , sock = require('sockjs')
  , fs = require('fs');
 
/*
* Store all connected clients
*/
 
var sockets = {};
 
/*
* Create websockets server and attach listeners
*/
 
var socketServer = sock.createServer();
 
socketServer.on('connection', function(conn) {
    sockets[conn.id] = conn;
});
 
/*
* Cache front-end file
*/
 
var front = fs.readFileSync(__dirname  + '/index.html', { encoding: 'utf8' });
 
/*
* Create http server
*/
 
var httpServer = http.createServer(function(req, res) {
    res.writeHead(200, { 'Content-Type': 'text/html' });
    res.end(front);
}).listen(8088);
 
/*
* Hook websockets in to http server
*/
 
socketServer.installHandlers(httpServer, { prefix: '/websockets' });
 
/*
* Subscribe to 'updates' channel
*/
 
redis.subscribe('updates');
 
/*
* Push incoming message to all connected clients
*/
 
redis.on('message', function(channel, data) {
    for (var id in sockets) {
        sockets[id].write(data);
    }
});
