Browse Source

Finish communication web interface.

master
flabbergast 9 years ago
parent
commit
3156531c5a
  1. 10
      modules/socket_server.js
  2. 6
      public/js/socket_client.js

10
modules/socket_server.js

@ -1,5 +1,6 @@
var sockets;
var serport = require('./serial_node');
var lhelper = require('./llap_helper');
var activeUser;
/*
@ -34,8 +35,15 @@ exports.init = function(io){
};
exports.onDataOverSerial = function(data){
console.log('onDataOverSerial', data.toString());
var msg = data.toString();
console.log('onDataOverSerial', msg);
// process data received
if (lhelper.isValid(msg)) {
// let all the clients know about the message
sockets.emit('received-llap-msg', { content: msg });
} else {
// message not valid
}
};
var onUserConnected = function(socket)

6
public/js/socket_client.js

@ -3,9 +3,7 @@ var socket_connected = false;
var autoMode;
socket.on('connected-to-server', function (data) {
// update the view based with the current server settings //
// generate a random id for this newly connected user //
var id = Math.floor(Math.random()*9999);
$('#user-id').html('Connected : <span style="color:blue">'+id+'</span>');
@ -17,3 +15,7 @@ socket.on('connected-to-server', function (data) {
socket.on('server-info-response', function (data) {
$('footer #serial-port-elt').html('<span>'+data.serialPort+'</span>');
});
socket.on('received-llap-msg', function (data) {
$('#serialtalk #serialtalk-resp').html(data.content);
});
Loading…
Cancel
Save