public function run($data, $fd = null) { $server = Protocol\Factory::getInstance(Core\Config::getField('socket', 'protocol', 'Http')); $server->setFd($fd); $server->parse($data); return Core\Route::route($server); }
/** * 请求发起 */ public function onRequest($request, $response) { Utils::$response = $response; $this->protocol->parse($_REQUEST); $result = Core\Route::route($this->protocol); return $response->end($result); }
public function run() { $server = Protocol\Factory::getInstance('Cli'); Protocol\Request::setServer($server); Protocol\Request::parse($_SERVER['argv']); return Core\Route::route(); }
public function onRequest($request, $response) { $filename = ZPHP::getRootPath() . DS . 'webroot' . $request->server['path_info']; if (is_file($filename)) { //解析静态文件 $response->header("Content-Type", $this->getMime($filename) . '; charset=utf-8'); $response->end(file_get_contents($filename)); return; } $param = []; if (!empty($request->get)) { $param = $request->get; } if (!empty($request->post)) { $param += $request->post; } $_SERVER['HTTP_USER_AGENT'] = $request->header['user-agent']; Request::parse($param); Request::setViewMode('Php'); Request::setHttpServer(1); Response::setResponse($response); try { $result = ZRoute::route(); } catch (\Exception $e) { $model = Formater::exception($e); $model['_view_mode'] = 'Json'; $result = Response::display($model); } $response->end($result); Request::setViewMode(ZConfig::getField('project', 'view_mode', 'Json')); Request::setHttpServer(0); }
public function api($params) { if (!$this->protocol) { $this->protocol = Protocol\Factory::getInstance('Rpc'); } $this->protocol->parse($params); return Core\Route::route($this->protocol); }
public function run() { if (!$this->protocol) { $this->protocol = Protocol\Factory::getInstance('Cli'); } $this->protocol->parse($_SERVER['argv']); return Core\Route::route($this->protocol); }
public function run() { if (!$this->protocol) { $this->protocol = Protocol\Factory::getInstance('Http'); } $this->protocol->parse($_REQUEST); return Core\Route::route($this->protocol); }
private function route($server) { try { Core\Route::route($server); } catch (\Exception $e) { $server->display($e->getMessage()); } return $server; }
public function run($data) { $server = Protocol\Factory::getInstance('Http'); $server->parse($data); \ob_start(); Core\Route::route($server); $result = \ob_get_contents(); \ob_end_clean(); return $result; }
public function onReceive() { list($serv, $fd, $fromId, $data) = func_get_args(); if (empty($data)) { return; } Request::parse($data); $result = ZRoute::route(); $serv->send($fd, $result); }
public function onTask($server, $taskId, $fromId, $data) { Request::parse($data); Request::addParams('taskId', $taskId . '_' . $fromId); try { ZRoute::route(); } catch (\Exception $e) { $model = Formater::exception($e); ZLog::info('exception', $model); } }
public function run($data, $fd) { $server = Protocol\Factory::getInstance('ZRpack'); $server->setFd($fd); $result = array(); if (false === $server->parse($data)) { return $result; } $result[] = Core\Route::route($server); while ($server->parse("")) { $result[] = Core\Route::route($server); } return $result; }
public function onRequest($request, $response) { $param = []; if (!empty($request->get)) { $param = $request->get; } if (!empty($request->post)) { $param += $request->post; } Request::parse($param); try { $result = ZRoute::route(); } catch (\Exception $e) { $model = Formater::exception($e); $model['_view_mode'] = 'Json'; $result = Response::display($model); } $response->end($result); }
public function onMessage($server, $frame) { if (empty($frame->finish)) { //数据未完 if (empty($this->buff[$frame->fd])) { $this->buff[$frame->fd] = $frame->data; } else { $this->buff[$frame->fd] .= $frame->data; } } else { if (!empty($this->buff[$frame->fd])) { $frame->data = $this->buff[$frame->fd] . $frame->data; unset($this->buff[$frame->fd]); } } Request::parse($frame->data); $result = ZRoute::route(); $server->push($frame->fd, $result); }
public function onRequest($request, $reponse) { $content = ""; do { $path_info = explode("/", $request->server['path_info']); $ctrl = $path_info[1]; $method = $path_info[2]; if (isset($request->post)) { Protocol\Request::parse($request->post); } else { Protocol\Request::parse($request->rawContent()); } Protocol\Request::setCtrl($ctrl); Protocol\Request::setMethod($method); Protocol\Request::setViewMode('Json'); Protocol\Request::setSocket($this->serv); //\ob_start(); $content = Core\Route::route(); //$content = \ob_get_contents(); //\ob_end_clean(); } while (0); $reponse->end($content); }
public function onMessage($serv, $frame) { if (empty($frame->finish)) { if (empty($this->buffer[$frame->fd])) { $this->buffer[$frame->fd] = $frame->data; } else { $this->buffer[$frame->fd] .= $frame->data; } return; } if (!empty($this->buffer[$frame->fd])) { $frame->data = $this->buffer[$frame->fd] . $frame->data; unset($this->buffer[$frame->fd]); } if (empty($frame->data)) { return; } $this->protocol->parse($frame->data); $result = Core\Route::route($this->protocol); if (is_null($result)) { return; } return $frame->push($result); }
public function onClose() { Request::setFd(func_get_arg(1)); Request::parse(['a' => 'chat', 'm' => 'offline']); ZRoute::route(); }
public function api($params) { Protocol\Request::setServer(Protocol\Factory::getInstance('Rpc')); Protocol\Request::parse($params); return Core\Route::route(); }
public function run() { $server = Protocol\Factory::getInstance('Http'); $server->parse($_REQUEST); Core\Route::route($server); }
public function run() { $server = Protocol\Factory::getInstance('Protocol\\WebSocket'); $server->parse($_REQUEST); return Core\Route::route($server); }
private function _route($data) { try { $server = Protocol\Factory::getInstance(ZConfig::getField('socket', 'protocol', 'Rpc')); $server->parse($data); $result = Core\Route::route($server); return $result; } catch (\Exception $e) { $result = Formater::exception($e); ZPHP\Common\Log::info('zchat', [var_export($result, true)]); return null; } }
public function run() { Protocol\Request::setServer(Protocol\Factory::getInstance('Http')); Protocol\Request::parse($_REQUEST); return Core\Route::route(); }
public function run() { $server = Protocol\Factory::getInstance('Cli'); $server->parse($_SERVER['argv']); Core\Route::route($server); }
public function api($params) { $server = Protocol\Factory::getInstance('Rpc'); $server->parse($params); return Core\Route::route($server); }