Skip to content

Commit 06b7d3a

Browse files
committed
stuffs
1 parent 5ce4502 commit 06b7d3a

File tree

3 files changed

+15
-30
lines changed

3 files changed

+15
-30
lines changed

app.js

+14-16
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,6 @@ app.configure('production', function(){
3333
app.use(express.errorHandler());
3434
});
3535

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-
4636
var server = http.createServer(app).listen(app.get('port'), function(){
4737
console.log("Express server listening on port "+ app.get('port') +" in "+ app.get('env') +" mode.");
4838
});
@@ -58,11 +48,19 @@ io.configure(function() {
5848
io.set('log level', 1);
5949
});
6050

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');
6660
});
61+
app.get('/prova', function(req, res) {
6762

68-
/******************************************************************/
63+
console.log('rendering frontend client...');
64+
65+
res.render('index.twig');
66+
});

views/index.twig

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
<script src='//code.jquery.com/jquery-1.7.2.min.js'></script>
44
<script src="/socket.io/socket.io.js"></script>
55
<script>
6-
var socket = io.connect('http://localhost');
6+
var socket = io.connect('http://192.168.1.5');
77
socket.on('evento', function (data) {
8-
//console.log('arrivato!');
98
$('#messages').append("<li>test</li>");
109
});
1110
</script>

views/okEvent.twig

-12
This file was deleted.

0 commit comments

Comments
 (0)