File tree 4 files changed +11
-2
lines changed
4 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ var path = require('path');
3
3
var http = require ( 'http' ) ;
4
4
var app = express ( ) ;
5
5
var server = http . Server ( app ) ;
6
+ var io = require ( 'socket.io' ) ( server ) ;
6
7
var port = process . env . PORT || 3000 ;
7
8
8
9
app . use ( express . static ( path . join ( __dirname , 'public' ) ) ) ;
Original file line number Diff line number Diff line change 2
2
"name" : " NodeKC-October-2014" ,
3
3
"version" : " 0.0.1" ,
4
4
"engines" : {
5
- "node" : " 0.10.x"
5
+ "node" : " 0.10.x"
6
6
},
7
7
"dependencies" : {
8
- "express" : " ~4.2.0"
8
+ "express" : " ~4.2.0" ,
9
+ "socket.io" : " ^1.1.0"
9
10
},
10
11
"author" : " Joe Longstreet" ,
11
12
"license" : " MIT"
Original file line number Diff line number Diff line change 11
11
< h1 id ='sup '> sup?</ h1 >
12
12
</ div >
13
13
< audio id ='clip ' src ='/sup.mp3 ' />
14
+ < script src ='/socket.io/socket.io.js '> </ script >
14
15
< script src ='/sup.js '> </ script >
15
16
</ body >
16
17
</ html >
Original file line number Diff line number Diff line change
1
+ var socket = io ( ) ;
1
2
var $background = document . getElementById ( 'container' ) ;
2
3
var $sup = document . getElementById ( 'sup' ) ;
3
4
var $audio = document . getElementById ( 'clip' ) ;
@@ -25,3 +26,8 @@ var highlight = function(){
25
26
var playSound = function ( ) {
26
27
$audio . play ( ) ;
27
28
} ;
29
+
30
+ socket . on ( 'sup' , function ( ) {
31
+ highlight ( ) ;
32
+ playSound ( ) ;
33
+ } ) ;
You can’t perform that action at this time.
0 commit comments