Sorry if I ask silly question, I am working with the example below regarding on nodejs long polling. http://www.stoimen.com/blog/2010/12/02/diving-into-node-js-a-long-polling-example/
I understand most of them, but just one thing I am not quite able to understand although I have done thousands of searching.
fs.stat('filepath', function(err, stats) {
// if the file is changed
if (stats.mtime.getTime() > request.socket._idleStart.getTime()) {
// read it
fs.readFile('filepath', 'utf8', function(err, data) {
// return the contents
response.writeHead(200, {
'Content-Type' : 'text/plain',
'Access-Control-Allow-Origin' : '*'
});
// return response
response.write(data, 'utf8');
response.end();
// return
return false;
});
}
});
The part "request.socket._idleStart", what is the meaning of the parameter _idleStart? Actually, I try to print out the whole request object and got the following parameters.
_readableState:
{ highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: false,
ended: false,
endEmitted: false,
reading: false,
calledRead: false,
sync: true,
needReadable: false,
emittedReadable: false,
readableListening: false,
objectMode: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
domain: null,
_events: {},
_maxListeners: 10,
socket:
....
...
...
I am wondering if there is any documentations describing these parameters, thanks for all for the help!