io.sockets.on('connection', function (socket) { dbs.session.findOne({slug: 'default'}, function (err, session) { playlist.get(function (err, pl) { socket.emit('playlist.init', {playlist: pl.items, session: session}); }); }); socket.on('playlist.add', function (media) { ytDL.findLinks(media, function(err, mediaFiles) { playlist.add(mediaFiles, function (err, pl) { console.log('err = ' + err); console.log('AFTER ALL ACTIONS: playlist = ', pl); io.sockets.emit('playlist.add', mediaFiles); }); }); }); socket.on('playlist.del', function (mediaId) { console.log('playlist.del called with id: ' + mediaId); io.sockets.emit('playlist.del', media); playlist.del(mediaId); }); });
app.configure( function() { this.set( 'views', path.join( process.cwd(), config.templates.folder )); this.set( 'view engine', config.templates[ 'template engine' ] ); this.use( express.bodyParser() ); this.use( express.cookieParser() ); if ( 'session' in config ) { // Load the supported stores supported var supported = require( path.join( __dirname, '..', 'supported.json' ) ); // Test if the config's is supported if ( !~supported.session.indexOf( config.session.store ) ) { throw new Error( 'The session store driver ' + config.session.store + ' is not supported by tartempion.' ); } // And load the appropriate session store this.use( express.session( { store: require( path.join( __dirname, 'sessions', config.session.store + '.js' ) )( config ), secret: config.session.secret, cookie: { maxAge: config.session.maxAge } })); } });