modify plugin name
This commit is contained in:
+23
-4
@@ -90,11 +90,31 @@ class Http extends Component
|
|||||||
{
|
{
|
||||||
$this->configs = $config;
|
$this->configs = $config;
|
||||||
foreach ($config as $value) {
|
foreach ($config as $value) {
|
||||||
|
$this->_addListener($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function addListener(string $type, string $host, int $port, int $mode, array $settings = [])
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $value
|
||||||
|
* @return void
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws Exception
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
protected function _addListener($value)
|
||||||
|
{
|
||||||
$value = $this->resolveCallback($value);
|
$value = $this->resolveCallback($value);
|
||||||
if ($value['type'] == Constant::SERVER_TYPE_HTTP) {
|
if ($value['type'] == Constant::SERVER_TYPE_HTTP) {
|
||||||
$onRequest = $value['events'][Constant::REQUEST] ?? null;
|
$onRequest = $value['events'][Constant::REQUEST] ?? null;
|
||||||
if (is_null($onRequest)) {
|
if (is_null($onRequest)) {
|
||||||
throw new \Exception('Server callback con\'t null.');
|
throw new Exception('Server callback con\'t null.');
|
||||||
}
|
}
|
||||||
$server = new Coroutine\Http\Server($value['host'], $value['port'], null, true);
|
$server = new Coroutine\Http\Server($value['host'], $value['port'], null, true);
|
||||||
|
|
||||||
@@ -111,7 +131,7 @@ class Http extends Component
|
|||||||
$close = $value['events'][Constant::CLOSE] ?? null;
|
$close = $value['events'][Constant::CLOSE] ?? null;
|
||||||
$message = $value['events'][Constant::MESSAGE] ?? null;
|
$message = $value['events'][Constant::MESSAGE] ?? null;
|
||||||
if (is_null($message)) {
|
if (is_null($message)) {
|
||||||
throw new \Exception('Server callback con\'t null.');
|
throw new Exception('Server callback con\'t null.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$server = new Coroutine\Http\Server($value['host'], $value['port'], null, true);
|
$server = new Coroutine\Http\Server($value['host'], $value['port'], null, true);
|
||||||
@@ -138,7 +158,7 @@ class Http extends Component
|
|||||||
} else {
|
} else {
|
||||||
$message = $value['events'][Constant::RECEIVE] ?? null;
|
$message = $value['events'][Constant::RECEIVE] ?? null;
|
||||||
if (is_null($message)) {
|
if (is_null($message)) {
|
||||||
throw new \Exception('Server callback con\'t null.');
|
throw new Exception('Server callback con\'t null.');
|
||||||
}
|
}
|
||||||
$conn = $value['events'][Constant::CONNECT] ?? null;
|
$conn = $value['events'][Constant::CONNECT] ?? null;
|
||||||
$close = $value['events'][Constant::CLOSE] ?? null;
|
$close = $value['events'][Constant::CLOSE] ?? null;
|
||||||
@@ -165,7 +185,6 @@ class Http extends Component
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function start()
|
public function start()
|
||||||
|
|||||||
+1
-1
@@ -99,7 +99,7 @@ class Server extends HttpService
|
|||||||
|
|
||||||
$this->getEventDispatch()->dispatch(new OnServerBeforeStart());
|
$this->getEventDispatch()->dispatch(new OnServerBeforeStart());
|
||||||
|
|
||||||
return $this->manager->getServer()->start();
|
return $this->manager->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user