public function async_result_handler($params) { $this->begin(__FUNCTION__); $result = new base_rpc_result($_POST, $params['app_id']); $obj_rpc_poll = app::get('base')->model('rpcpoll'); $arr_rpc_id = explode('-', $params['id']); $rpc_id = $arr_rpc_id[0]; $rpc_calltime = $arr_rpc_id[1]; $row = $obj_rpc_poll->getlist('fail_times,callback,callback_params', array('id' => $rpc_id, 'calltime' => $rpc_calltime, 'type' => 'request'), 0, 1); $fail_time = $row[0]['fail_times'] - 1 ? $row[0]['fail_times'] - 1 : 0; $obj_rpc_poll->update(array('fail_times' => $row[0]['fail_times'] - 1), array('id' => $rpc_id, 'calltime' => $rpc_calltime, 'type' => 'request')); if ($row) { list($class, $method) = explode(':', $row[0]['callback']); if ($class && $method) { $result->set_callback_params(unserialize($row[0]['callback_params'])); $return = kernel::single($class)->{$method}($result); if ($return) { $notify = array('callback' => $row[0]['callback'], 'rsp' => $return['rsp'], 'msg' => $return['res'], 'notifytime' => time()); app::get('base')->model('rpcnotify')->insert($notify); } } } //$obj_rpc_poll->delete(array('id'=>$rpc_id,'calltime'=>$rpc_calltime,'type'=>'request','fail_times'=>'1')); if ($row[0]['fail_times'] - 1 <= 0 && $return['rsp'] == 'succ') { $obj_rpc_poll->delete(array('id' => $rpc_id, 'calltime' => $rpc_calltime, 'type' => 'request')); } if (!$return) { $return = array("rsp" => "fail", "res" => "", "msg_id" => ""); } $this->end(); header('Content-type: text/plain'); echo json_encode($return); }
public function async_result_handler($params) { $this->begin(__FUNCTION__); $apilog_mdl = app::get('apiactionlog')->model('apilog'); $api_log = kernel::single('apiactionlog_router_logging'); $result = new base_rpc_result($_POST, $params['app_id']); $arr_rpc_id = explode('-', $params['id']); $rpc_id = $arr_rpc_id[0]; $rpc_calltime = $arr_rpc_id[1]; $status = $result->get_status(); $msg_id = $result->get_pid(); $data = $result->get_data(); if ($result->get_result()) { $msg = $result->get_result() . "," . $_POST['err_msg']; } switch ($status) { case 'succ': $log_status = 'success'; break; case 'fail': $log_status = 'fail'; break; } $log_data = array('status' => $log_status, 'msg' => $msg, 'msg_id' => $msg_id); $return = $api_log->update($log_data, $rpc_id, $rpc_calltime); if (!$return) { $return = array("rsp" => "fail", "res" => "", "msg_id" => ""); } else { $return = array('rsp' => $status, 'res' => $msg, 'data' => $data); } $this->end(); header('Content-type: text/plain'); echo json_encode($return); }
public function async_result_handler($params) { base_logger::begin(__FUNCTION__); $result = new base_rpc_result($_POST); $row = app::get('base')->model('rpcpoll')->getlist('callback,callback_params', array('id' => $params['id'], 'type' => 'request'), 0, 1); if ($row) { list($class, $method) = explode(':', $row[0]['callback']); if ($class && $method) { $result->set_callback_params(unserialize($row[0]['callback_params'])); kernel::single($class)->{$method}($result); } } $return = array('rst' => 'ok', 'id' => $params['id'], 'error' => null); app::get('base')->model('rpcpoll')->delete(array('id' => $params['id'], 'type' => 'request')); if (!$return) { $return = array('id' => $request->id, 'error' => 'bad request-id:' . $request->id); } base_logger::end(); header('Content-type: text/plain'); echo json_encode($return); }
public function async_result_handler($params) { $this->begin(__FUNCTION__); $result = new base_rpc_result($_POST); $row = app::get('base')->model('rpcpoll')->getlist('callback,callback_params', array('id' => $params['id'], 'type' => 'request'), 0, 1); if ($row) { list($class, $method) = explode(':', $row[0]['callback']); if ($class && $method) { $result->set_callback_params(unserialize($row[0]['callback_params'])); $msg = kernel::single($class)->{$method}($result); if ($msg) { $notify = array('callback' => $row[0]['callback'], 'rsp' => $result->get_status(), 'msg' => $msg, 'notifytime' => time()); app::get('base')->model('rpcnotify')->insert($notify); } } } $return = array('rst' => 'succ', 'id' => $params['id'], 'error' => null); app::get('base')->model('rpcpoll')->delete(array('id' => $params['id'], 'type' => 'request')); if (!$return) { $return = array('id' => $request->id, 'error' => 'bad request-id:' . $request->id); } $this->end(); header('Content-type: text/plain'); echo json_encode($return); }