Skip to content
This repository was archived by the owner on May 24, 2020. It is now read-only.

Commit 223d9eb

Browse files
fix socket.io events
1 parent 815401a commit 223d9eb

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

app.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ app.post('/update', (req, res) => {
3838
data.vibrs = req.body.vibrs;
3939
data.total = req.body.total;
4040

41-
if (req.body.first_connected) {
42-
io.emit('first_connection', data);
41+
let first_connected = req.body.first_connected;
42+
43+
if (first_connected) {
44+
io.emit('first_connected', data);
4345
}
4446
else {
4547
io.emit('update', data);

static/js/index.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@ $( document ).ready(() => {
22
var socket = io();
33

44
socket.on('update', (new_data) => {
5+
$.notify("New data arrived!", {
6+
position : 'top center',
7+
className : 'info',
8+
autoHideDelay: 2000,
9+
});
10+
511
$('#p-touches').text(new_data.touches);
612
$('#p-vibrs').text(new_data.vibrs);
713
$('#p-total').text(new_data.total);
814
});
915

10-
socket.on('first_connection', (data) => {
16+
socket.on('first_connected', (data) => {
1117
$.notify("Arduino connected!", {
1218
position : 'top center',
13-
class : 'success',
19+
className : 'success',
1420
});
1521

1622
$('#p-touches').text(data.touches);

0 commit comments

Comments
 (0)