<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                # swoole基類代碼 保存位置 extend\mikkle\tp_swoole\ServerBase.php ![](https://box.kancloud.cn/d56e429c55642e774a943089d115dcbb_483x246.png) > 本基類是抄襲tp官方abstract類 必須繼承才可使用 ~~~ <?php namespace mikkle\tp_swoole; /** * Created by PhpStorm. * Power By Mikkle * Copy From THINKphp * Email:776329498@qq.com * Date: 2017/11/6 * Time: 13:51 */ /** * Worker控制器擴展類 */ abstract class ServerBase { protected $swoole; protected $serverType; protected $sockType; protected $mode; protected $host = '0.0.0.0'; protected $port = 9501; protected $option = []; /** * 架構函數 * @access public */ public function __construct() { // 實例化 Swoole 服務 switch ($this->serverType) { case 'socket': $this->swoole = new \swoole_websocket_server($this->host, $this->port); $eventList = ['Open', 'Message', 'Close', 'HandShake','Request']; break; case 'http': $this->swoole = new \swoole_http_server($this->host, $this->port); $eventList = ['Request']; break; default: $this->swoole = new \swoole_server($this->host, $this->port, $this->mode, $this->sockType); $eventList = ['Start', 'ManagerStart', 'ManagerStop', 'PipeMessage', 'Task', 'Packet', 'Finish', 'Receive', 'Connect', 'Close', 'Timer', 'WorkerStart', 'WorkerStop', 'Shutdown', 'WorkerError']; } // 設置參數 if (!empty($this->option)) { $this->swoole->set($this->option); } // 初始化 $this->init(); // 設置回調 foreach ($eventList as $event) { if (method_exists($this, 'on' . $event)) { $this->swoole->on($event, [$this, 'on' . $event]); } } } protected function init() { } public function start() { $this->swoole->start(); } public function stop() { $this->swoole->stop(); } /** * 魔術方法 有不存在的操作的時候執行 * @access public * @param string $method 方法名 * @param array $args 參數 * @return mixed */ public function __call($method, $args) { call_user_func_array([$this->swoole, $method], $args); } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看