Inheritance: extends Swoole, implements Laravoole\Wrapper\ServerInterface
 public function start($config, $settings)
 {
     // override
     $config['deal_with_public'] = false;
     parent::init($config);
     $this->settings = $settings;
     if (!empty($this->settings)) {
         $this->server->set($this->settings);
     }
     $this->server->on('Start', [$this, 'onServerStart']);
     $this->server->on('Receive', [$this, 'onReceive']);
     $this->server->on('Shutdown', [$this, 'onServerShutdown']);
     $this->server->on('WorkerStart', [$this, 'onWorkerStart']);
     $this->server->start();
 }
Ejemplo n.º 2
0
 public function endResponse($response, $content)
 {
     if (isset($response->request)) {
         // This is a websocket request
         $data = $this->connections[$response->request->fd]['protocol']::encode($response->http_status, $response->request->method, $content, $response->request->echo);
         $this->server->push($response->request->fd, $data);
     } else {
         // This is a http request
         parent::endResponse($response, $content);
     }
 }