예제 #1
0
파일: ZPHP.php 프로젝트: heesey/zphp
 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);
 }
예제 #2
0
 /**
  *  请求发起
  */
 public function onRequest($request, $response)
 {
     Utils::$response = $response;
     $this->protocol->parse($_REQUEST);
     $result = Core\Route::route($this->protocol);
     return $response->end($result);
 }
예제 #3
0
파일: Cli.php 프로젝트: heesey/zphp
 public function run()
 {
     $server = Protocol\Factory::getInstance('Cli');
     Protocol\Request::setServer($server);
     Protocol\Request::parse($_SERVER['argv']);
     return Core\Route::route();
 }
예제 #4
0
 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);
 }
예제 #5
0
파일: Rpc.php 프로젝트: 446244451/zphp
 public function api($params)
 {
     if (!$this->protocol) {
         $this->protocol = Protocol\Factory::getInstance('Rpc');
     }
     $this->protocol->parse($params);
     return Core\Route::route($this->protocol);
 }
예제 #6
0
파일: Cli.php 프로젝트: 446244451/zphp
 public function run()
 {
     if (!$this->protocol) {
         $this->protocol = Protocol\Factory::getInstance('Cli');
     }
     $this->protocol->parse($_SERVER['argv']);
     return Core\Route::route($this->protocol);
 }
예제 #7
0
파일: Http.php 프로젝트: 446244451/zphp
 public function run()
 {
     if (!$this->protocol) {
         $this->protocol = Protocol\Factory::getInstance('Http');
     }
     $this->protocol->parse($_REQUEST);
     return Core\Route::route($this->protocol);
 }
예제 #8
0
파일: Swoole.php 프로젝트: ymnl007/zphpdemo
 private function route($server)
 {
     try {
         Core\Route::route($server);
     } catch (\Exception $e) {
         $server->display($e->getMessage());
     }
     return $server;
 }
예제 #9
0
 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;
 }
예제 #10
0
 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);
 }
예제 #11
0
파일: Tcp.php 프로젝트: jonny77/zmail
 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);
     }
 }
예제 #12
0
파일: ZRpack.php 프로젝트: tempbottle/zphp
 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;
 }
예제 #13
0
 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);
 }
예제 #14
0
 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);
 }
예제 #15
0
 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);
 }
예제 #16
0
 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);
 }
예제 #17
0
 public function onClose()
 {
     Request::setFd(func_get_arg(1));
     Request::parse(['a' => 'chat', 'm' => 'offline']);
     ZRoute::route();
 }
예제 #18
0
파일: Rpc.php 프로젝트: tempbottle/zphp
 public function api($params)
 {
     Protocol\Request::setServer(Protocol\Factory::getInstance('Rpc'));
     Protocol\Request::parse($params);
     return Core\Route::route();
 }
예제 #19
0
파일: Http.php 프로젝트: xifat/zphp
 public function run()
 {
     $server = Protocol\Factory::getInstance('Http');
     $server->parse($_REQUEST);
     Core\Route::route($server);
 }
예제 #20
0
 public function run()
 {
     $server = Protocol\Factory::getInstance('Protocol\\WebSocket');
     $server->parse($_REQUEST);
     return Core\Route::route($server);
 }
예제 #21
0
파일: Swoole.php 프로젝트: jxw7733/zphpdemo
 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;
     }
 }
예제 #22
0
파일: Http.php 프로젝트: heesey/zphp
 public function run()
 {
     Protocol\Request::setServer(Protocol\Factory::getInstance('Http'));
     Protocol\Request::parse($_REQUEST);
     return Core\Route::route();
 }
예제 #23
0
파일: Cli.php 프로젝트: xifat/zphp
 public function run()
 {
     $server = Protocol\Factory::getInstance('Cli');
     $server->parse($_SERVER['argv']);
     Core\Route::route($server);
 }
예제 #24
0
파일: Rpc.php 프로젝트: xifat/zphp
 public function api($params)
 {
     $server = Protocol\Factory::getInstance('Rpc');
     $server->parse($params);
     return Core\Route::route($server);
 }