I have this little
Packets sender code:
public function spinboxAction() {
$this->_response->setHeader('Access-Control-Allow-Origin', '*');
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$post = $this->getRequest()->getQuery();
$this->db = Application_Model_Db::db_load();
$sql = "select
u.id, u.username, u.status, callstatus, callername,
namedisplay,
theme,debug, p.username as pusername, (select kiosk
from sh_av_spform
where `status` IS NULL
and kiosk=u.username limit 1) as ftodo
from
sh_av_users u
inner join sh_av_profile p on u.profileid=p.id
where u.groups='c1'";
$result = $this->db->fetchAll($sql);
$json = '';
if (count($result) > 0) {
//$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/conf.ini', 'production');
$todo = false;
$sql = "select *from sh_av_spform where `status` IS NULL limit 1";
$todo = $this->db->fetchAll($sql);
if(count($todo)> 0 ){
$todo = true;
} else {
$todo = false;
}
$json = array(
'result' =>'ok',
'db' => $result,
'todo' => $todo
);
} else {
$json = array(
'result' => 'fail',
'db' =>$result,
'todo' => false
);
}
$this->getResponse()
->setHeader('Content-Type', 'application/json')
->setBody(Zend_Json::encode($json))
->sendResponse();
exit;
}
Packets receiver code:
function crawl() {
maincrawl_timer = setTimeout(function() {
var s1 = $.get(submit_url + '/spinbox', {
action: 'spinbox',
ousername: main_username,
status: 'offline'
}, function(msg) {
for(bee in msg.db) {
//...
}
}, 'json');
s1.always(function() {
console.log('>>> crawl started, autocall state: ', global_autocall);
crawl();
});
}, 2000 );
}
crawl();
On Packets receiver end is Google Chrome stable (Windows 8.1 Pro). Its taking a while to get the packets like you can see below 204ms sometimes its 500ms but the application is suffering a lot of issue for this. Sometimes the packet is completely lost not being sent to server as a result the application fails on production site.
How to speed this process little more faster so that it can be done within less then 204ms please?