/** * 结果处理 * @param $response * @return ByteBuffer|string */ function getResult($response) { if ($response) { $result = Tool::parse($response); } else { $result = ""; } $data = ByteBuffer::wrap($result); return $data; }
public function onServerReceive($server, $fd, $from_id, $data) { $this->startApp(); $requestData = Tool::getParseInfo($data); $resData = $this->prepareRequest($requestData); $content = ""; if ($resData) { $res = $this->handleRequest($resData); $content = $res->content(); } $this->send($server, $fd, $content, $requestData); $this->stopApp(); }
public function send($server, $fd, $data, $requestData) { $data = Tool::binFormat($data, $requestData['bufferRouteMatch'], $requestData['bufferCompressType']); $server->send($fd, $data); // $server->stop(); }