public function singleAPI($name, $param, $mode = DoraConst::SW_MODE_WAITRESULT, $retry = 0, $ip = "", $port = "")
{
//get guid
$this->guid = $this->generateGuid();
$packet = array('guid' => $this->guid, 'api' => array("one" => array('name' => $name, 'param' => $param)));
switch ($mode) {
case DoraConst::SW_MODE_WAITRESULT:
$packet["type"] = DoraConst::SW_MODE_WAITRESULT_SINGLE;
break;
case DoraConst::SW_MODE_NORESULT:
$packet["type"] = DoraConst::SW_MODE_NORESULT_SINGLE;
break;
case DoraConst::SW_MODE_ASYNCRESULT:
$packet["type"] = DoraConst::SW_MODE_ASYNCRESULT_SINGLE;
break;
default:
throw new \Exception("unknow mode have been set", 100099);
break;
}
$sendData = Packet::packEncode($packet);
$result = $this->doRequest($sendData, $packet["type"]);
//retry when the send fail
while ((!isset($result["code"]) || $result["code"] != 0) && $retry > 0) {
$result = $this->doRequest($sendData, $packet["type"]);
$retry--;
}
if ($this->guid != $result["guid"]) {
return Packet::packFormat("guid wront please retry..", 100100, $result["data"]);
}
return $result;
}