Permalink
Browse files

improves way of sending message using the socket.io

Signed-off-by: Henrique Vicente <henriquevicente@gmail.com>
  • Loading branch information...
1 parent fb17a10 commit 7837c92f79a49ff7a548444f9fc9dc2ea68524e1 @henvic committed May 24, 2012
Showing with 5 additions and 3 deletions.
  1. +4 −3 app/sockets/control.js
  2. +1 −0 public/javascripts/client.js
View
@@ -14,9 +14,10 @@ var config = require('../../config/settings');
//set Arduino metainfo channel
io.of('/meta/arduino').on('connection', function (socket) {
socket.on('message', function (msg) {
- if (msg === 'blink led') {
- console.log('blink LED');
- console.log(board);
+ var data = JSON.parse(msg);
+
+ if (data.route === "/led/blink") {
+ console.log('Blink LED');
board.digitalWrite(config.ledPin, board.HIGH);
setTimeout(function () {
board.digitalWrite(config.ledPin, board.LOW);
@@ -24,6 +24,7 @@
e.preventDefault();
morseReturn.html('<i class="icon-arrow-right"></i> ' + morse.encode(message, true));
+ var data = {"route":"/led/morse", "message":[message]};
});
$('[data-spy="scroll"]').each(function () {

0 comments on commit 7837c92

Please sign in to comment.