我试图在readstream.write之间设置超时但我一直收到错误:写完后。如何在res.write之间设置超时。谢谢。这是我的代码。
TRANSFORM CLNG(NZ(Count(sType),0)) AS CountOfType
SELECT UserID
,Gender
,COUNT(sType) AS TotalCount
FROM UserInfo LEFT JOIN OrderInfo ON UserInfo.UserID = OrderInfo.UserID_FK
GROUP BY UserID, Gender
PIVOT sType
我试图在客户端显示视频,问题是mjpeg很快被读取,因此无法创建视频。任何帮助将不胜感激。
答案 0 :(得分:0)
我快速写了一些我理解你需要的代码。
StackOverflow不是我最喜欢的IDE所以不要太难了^^
我真的不知道readStream,但data
事件被称为多次写入?
队列正在等待先前的块并且其超时正确完成。
这是你需要的吗?
var kue = require('kue'),
jobs = kue.createQueue();
app.get('/video', function (req, res) {
var readStream = fs.createReadStream('video.mjpeg');
res.writeHead(200, {'Content-Type': 'multipart/x-mixed- replace;boundary=ThisString'});
jobs.process('write chunck', function (job, done) {
setTimeout(function() {
res.write(job.chunck, 'binary');
done && done();
}, 200);
});
jobs.process('write end', function(job, done) {
readStream.destroy();
res.end();
console.log("End of data");
done & done();
});
readStream.on("data", (chunk) => {
jobs.create('write chunck', {
chunk: chunk
});
});
readStream.on("end", () => {
jobs.create('write end', {});
});
});