我有这个小小的
数据包发件人代码:
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;
}
数据包接收器代码:
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接收器端是Google Chrome稳定版(Windows 8.1 Pro)。它需要一段时间来获取像你可以看到204ms以下的数据包,有时它的500ms,但应用程序正在遭受很多问题。有时,数据包完全丢失而不会被发送到服务器,因此应用程序在生产站点上失败。
如何更快地加快这个过程,以便在不到204ms的时间内完成?