forked from inversesquarelaw/popcorn-app-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (27 loc) · 779 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* Module dependencies
*/
var express = require('express');
var sio = require('socket.io');
var http = require('http');
var app = express();
app.use(express.static('rc/static'));
var server = http.createServer(app).listen(8889);
var io = sio.listen(server);
io.set('log level', 0);
io.sockets.on('connection', function(socket){
var movies = App.getTorrentsCollection({
searchTerm: null,
genre: null
});
movies.fetch();
movies.on('add', function(movie){
socket.emit('movie', movie);
})
socket.on('play', function(data){
var movie = movies.find(function(model) { return model.get('torrent') === data.torrent; });
console.log(movie.get('torrent'));
App.sidebar.model = movie;
App.sidebar.play($.Event('click'));
});
});