函数中的node.js event-stream stdin不起作用

时间:2014-03-31 21:02:18

标签: javascript node.js stdout stdin event-stream

好吧继承我的事件流功能evrything其他工作正常,除了尝试发送输入

es.pipeline(
child.stdout,
es.split(),
es.map(function (line) {
    console.log(line);

    if (line === 'Input1') {
        console.log("Working1");
        console.log(line);
    }        
    if (line === 'Input2') {
        console.log("working 2");
        console.log(line);
        child.stdin.write("2345324:fdghdfgth456:45365" + '/n');
    }
})
);

编辑我的完整脚本我想让stdin.write工作,因为它不是

var app = require('express')();
var es = require('event-stream');
var server = require('http').createServer(app);
var bin = "casperjs";
var args = ['Backend.js'];
var io = require('socket.io').listen(server);
server.listen(process.env.PORT);

app.get('/', function (req, res) {
    res.sendfile(__dirname + '/client/index.html');
});

io.sockets.on('connection', function (socket) {
console.log("socket connection incoming");
});

var spawn = require('child_process').spawn,
child = spawn(bin, args);
child.stdin.setEncoding = 'utf-8';


es.pipeline(
child.stdout,
process.openStdin(), 
es.split(),
es.map(function (line) {
    console.log(line);

    if (line === 'Input1') {
        console.log("Working1");
        console.log(line);
    }        
    if (line === 'Input2') {
        console.log("working 2");
        console.log(line);
        child.stdin.write("2345324:fdghdfgth456:45365" + '/n');
    }
})
);

任何帮助都会很精彩。所以请告诉我如何解决这个问题

0 个答案:

没有答案