• Sorry for such a late response, my laptop broke and I had to reset up everything from scratch on a new machine.

    So one of my goals here was to get the REPL to be accessible over websockets. I tried the following as suggested, and it resulted in the program emitting the following error messages over websockets to my webIDE.

    ws.on('message', function(msg) { LoopbackB.write(msg); });
    LoopbackB.on('data',function(msg) { ws.send(msg); });
    

    complete code

    var host = "192.168.1.***";
    var WebSocket = require("ws");
    var ws = new WebSocket(host, {
      path: '/',
      port: 8080, // default is 80
      protocol: "echo-protocol", // websocket protocol name (default is none)
      protocolVersion: 13, // websocket protocol version, default is 13
      origin: 'Espruino',
      keepAlive: 60,
      headers: {
        some: 'header',
        'ultimate-question': 42
      } // websocket headers to be used e.g. for auth (default is none)
    });
    
    ws.on('open', function() {
      console.log("Connected to server");
      ws.send("esp:Connected");
    });
    
    ws.on('message', function(msg) {
      LoopbackB.write(msg.toString()); 
    });
    
    LoopbackB.on('data',function(msg) {
      ws.send(msg); 
    });
    
    setTimeout(function() {
      LoopbackA.setConsole();
    },100);
    

    Error transmitted over websockets continually until program is forced to stop

    <- Telnet
     UncauUncaught SyntaxError: Got ':' expected EOF
     at Uncaught SyntaxError: Got ':' expected EOF
     at =19
     =un>=un>=un>=un>=un>=un>=un>=un>=un>=un>­=un>=unUncaught Syn>> at Uncaught Erro> at line 1 c> at line 1 cUncaught SyntaxError: Got '^' exUncaught Syn>>=und=und=und=undUncaught SyntaxError: Got ':' expected E=und=undUncaught SyntaxError: Got ':' expected E=und=undUncaught SyntaxError: Got ':' expected E=und=undUncaught SyntaxError: Got ':' expected E=und=und=und=undUnca=und=undUncaught Synt
    

    The exact error msg is the following

    =un>=un>=un>=un>=un>=un>=un>=un>=un>=un>­=un>=un>=un>=un>=un>=un>=un>=un>=un>=un>­=un>=un>=un>=un>=un>=un>=un>=un>=un>=un>­=un>=un>=un>=un>=un>=un>=un>=un>=un>=un>­=un>=un>=un>=un>=un>=un>=un>=un>=un>=un>­=un>=un>=un>=un>=un>=un>=un>=un>=un>=un>­=un>=un>=un>=un>=un>=un>=un>=un>=un>=un>­=un>=un>=un>=un>=un>=un>=un>=un>=un>=un>­=un>=un>=un>=un>=un>=un>=un>=un>=un>=un>­=un>=un>=un>=un>=un>=un>=un>=un
    received: <- Telnet
    UncauUncaught SyntaxError: Got ':' expected EOF
     at Uncaught SyntaxError: Got ':' expected EOF
     at =19
    
    

    I'm not sure what I'm doing wrong. Any insight? line 19 is just closing braces.

About

Avatar for Esper @Esper started