Hi Micheil,
My code is simple:
at setInterval I emmitted 'url_request' event (every 5 seconds), and in the listener:
emitter.addListener('url_request', function(){
var idc_client = http.createClient(options.idc_port, options.idc_ip);
var idc_req = idc_client.request('GET', options.idc_command + param, {
'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3',
'Accept': 'text/html,text/xml,application/xhtml+xml,application/xml,text/csv',
'Host': options.idc_host,
'Keep-Alive' : options.idc_keepalive,
'Connection' : 'keep-alive',
'Accept-Language' : 'en,en-us',
'Accept-Charset' : 'utf-8'
});
idc_req.addListener('response', function (response){
options.allQuery++; //query counter
var data = '';
response.addListener('data', function (chunk){ data = data + chunk; });
response.addListener('end', function(){
// processing responce data
sys.puts('Request end');
idc_req.socket.destroy();
idc_req.removeAllListeners('data');
idc_req.removeAllListeners('end');
idc_req.removeAllListeners('response');
idc_req.destroy();
idc_client.destroy();
});
});
idc_req.end();
});
Where is my error?