@@ -33,16 +33,6 @@ app.configure('production', function(){
33
33
app . use ( express . errorHandler ( ) ) ;
34
34
} ) ;
35
35
36
- /*****************************************************************/
37
-
38
- // Routes
39
- app . get ( '/arduino' , function ( req , res ) {
40
- res . render ( 'okEvent.twig' ) ;
41
- } ) ;
42
- app . get ( '/prova' , function ( req , res ) {
43
- res . render ( 'index.twig' ) ;
44
- } ) ;
45
-
46
36
var server = http . createServer ( app ) . listen ( app . get ( 'port' ) , function ( ) {
47
37
console . log ( "Express server listening on port " + app . get ( 'port' ) + " in " + app . get ( 'env' ) + " mode." ) ;
48
38
} ) ;
@@ -58,11 +48,19 @@ io.configure(function() {
58
48
io . set ( 'log level' , 1 ) ;
59
49
} ) ;
60
50
61
- // main listener: Here we will put all the events we want to catch
62
- io . sockets . on ( 'connection' , function ( socket ) {
63
- socket . on ( 'arduino_response' , function ( ) {
64
- io . sockets . emit ( 'evento' ) ;
65
- } ) ;
51
+ /******************************************************************/
52
+
53
+ // Routes
54
+ app . get ( '/arduino' , function ( req , res ) {
55
+
56
+ console . log ( 'sending data to frontend client...' ) ;
57
+
58
+ io . sockets . in ( req . sessionID ) . emit ( 'evento' ) ;
59
+ res . render ( 'okEvent.twig' ) ;
66
60
} ) ;
61
+ app . get ( '/prova' , function ( req , res ) {
67
62
68
- /******************************************************************/
63
+ console . log ( 'rendering frontend client...' ) ;
64
+
65
+ res . render ( 'index.twig' ) ;
66
+ } ) ;
0 commit comments