redguardtoo / js-comint

js-comint will send the code from Emacs into node.js or rhino
GNU General Public License v3.0
69 stars 22 forks source link

connect to a socket REPL #12

Open velkyel opened 7 years ago

velkyel commented 7 years ago

is it possible to add connect to a socket REPL feature like in inf-clojure, please? There is possible to define inf-clojure-program like cons pair ("localhost" . 5555).

redguardtoo commented 7 years ago

what's socket REPL?

velkyel commented 7 years ago

do you know emacs commint file?

redguardtoo commented 7 years ago

No. Do you mean comint? What's the advantage to start a socket REPL?

velkyel commented 7 years ago

comint, sorry. "socket REPL" is now known name?

velkyel commented 7 years ago

Advantage? Running game with embedded js vm. Toying, scripting, debugging.

redguardtoo commented 7 years ago

How can I do that in NodeJS? Can you show me some prototype?

velkyel commented 7 years ago

like this:

var net = require('net');

var server = net.createServer(function(socket) {
    socket.setEncoding('utf8');
    socket.on('data', function(data) {
        var res = eval(data);
        socket.end(res.toString());
    });
});

server.listen(8000);

and run-js localhost:8000 in emacs.

I don't know nodejs too much -- actually I'd like to use js-comint mode to connect to my running app with embedded duktape (duktape.org) vm. This app listen and eval incoming data like example server.