Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { appendFileSync } = require('fs');
- // Debug
- // process.on('uncaughtException', (err) => {
- // appendFileSync('/Users/justin/GitHub/node-message-forwarder/log', `${err}\n\n`);
- // });
- var stdin = process.stdin;
- // Debug
- // if (stdin.isTTY) {
- // stdin.setRawMode(true);
- // }
- stdin.resume();
- // on any data into stdin
- stdin.on('data', (data) => {
- // First 4 bytes are actually the length of the message from Chrome. Since {data} is a Buffer here,
- // we can just call toString(). In C, though, we will use the first 4 bytes to get the message length
- // and allocate a string of the contents before forwarding the message as JSON to the right address.
- const err = appendFileSync('/Users/justin/GitHub/node-message-forwarder/log', `${data.toString().substr(1)}\n\n`);
- });
Add Comment
Please, Sign In to add comment