You are reading a single comment by @seanclark and its replies. Click here to read the full conversation.
  • I use socket.io to enable browser to browser communication in a number of projects.

    For example, a client running in Chrome might include:

    	var socket = io();
    	socket.on('matrix', function(packet) {
    		// Process packet
    	});
        socket.emit('register',{'artworkid': artworkid, 'artworktype': artworktype});
    
    

    And on the node.js server. This would "bounce" the messages between clients:

    io.on('connection', function(socket) {
      console.log('Connected');
      socket.on('disconnect', function() {
        console.log('Disconnected');
    	console.log("Clients: "+Object.keys(io.sockets.clients));
      });
    
      socket.on('register', function(msg) {
      	socket.artworkid = msg.artworkid;
      	socket.artworktype = msg.artworktype;
      	console.log("Registered: "+msg.artworkid+" "+msg.artworktype);
      });
    
      socket.on('matrix', function(msg) {
      	socket.broadcast.emit("matrix", msg);
        //console.log("matrix: "+msg);
      });
    });
    

    How do I get a client running on the Espruino to join in? I don't think there is a socket.io library for Espruino so do I need to use ordinary sockets to do the same job? Would I need to take messages received in socket.io and resend them to the Esprunio and visa versa? Are there some good examples of Espruino to node.js communication via sockets that I should be looking at?

    Thanks,

    Sean

About

Avatar for seanclark @seanclark started