Display the output of a process in browsers.
This programme was originally used by me to display Minecraft log text when queueing in 2b2t, so I could see my position in queue when away from computer, such as when going out for dinner.
The CLI program is piping the output of a local port to a websocket so that can be viewed in browsers. The local port could be created by jmcl, which is what I usually do.
const createServer = require('webmc');
const server = createServer({
addr: 'localhost:8080', // server address, used in websocket handshake, port number must be consistent with `port'
port: 8080, // server port
decodeMC: true // whether to decode Minecraft color code
});
const childProcess = /* Create a child process, could be Minecraft */;
prc.stdout.on('data', data => server.write(data));