This commit is contained in:
2020-09-02 17:40:11 +08:00
parent 5fa97ded93
commit 7adad560dd
+9 -2
View File
@@ -170,8 +170,15 @@ class Server extends Application
$class = $this->dispatch($config['type']);
$this->baseServer = new $class($config['host'], $config['port'], SWOOLE_PROCESS, $config['mode']);
$this->baseServer->set($settings);
if (!$event->exists(Event::SERVER_WORKER_START, [$this, 'onLoadWebsocketHandler'])) {
$event->on(Event::SERVER_WORKER_START, [$this, 'onLoadWebsocketHandler']);
if ($this->baseServer instanceof WebSocket) {
if (!$event->exists(Event::SERVER_WORKER_START, [$this, 'onLoadWebsocketHandler'])) {
$event->on(Event::SERVER_WORKER_START, [$this, 'onLoadWebsocketHandler']);
}
} else if ($this->baseServer instanceof Http) {
if (!$event->exists(Event::SERVER_WORKER_START, [$this, 'onLoadHttpHandler'])) {
$event->on(Event::SERVER_WORKER_START, [$this, 'onLoadHttpHandler']);
}
}
} else {
$newListener = $this->baseServer->addlistener($config['host'], $config['port'], $config['mode']);