Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c260ac6df4 | |||
| 7479bed4e4 | |||
| 39394f76d5 |
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Server\Contract;
|
|
||||||
|
|
||||||
use Swoole\Http\Response;
|
|
||||||
|
|
||||||
interface OnDownloadInterface
|
|
||||||
{
|
|
||||||
|
|
||||||
public function dispatch(Response $response);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Server\Events;
|
||||||
|
|
||||||
|
class OnServerBeforeStart
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
+7
-4
@@ -7,9 +7,10 @@ namespace Server;
|
|||||||
use Annotation\Inject;
|
use Annotation\Inject;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Kiri\Abstracts\Config;
|
use Kiri\Abstracts\Config;
|
||||||
use Kiri\Events\EventProvider;
|
use Kiri\Events\EventDispatch;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use Kiri\Kiri;
|
use Kiri\Kiri;
|
||||||
|
use Server\Events\OnServerBeforeStart;
|
||||||
use Swoole\Coroutine;
|
use Swoole\Coroutine;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
@@ -29,10 +30,10 @@ class ServerCommand extends Command
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var EventProvider
|
* @var EventDispatch
|
||||||
*/
|
*/
|
||||||
#[Inject(EventProvider::class)]
|
#[Inject(EventDispatch::class)]
|
||||||
public EventProvider $eventProvider;
|
public EventDispatch $eventProvider;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,6 +106,8 @@ class ServerCommand extends Command
|
|||||||
|
|
||||||
Kiri::app()->getRouter()->read_files();
|
Kiri::app()->getRouter()->read_files();
|
||||||
|
|
||||||
|
$this->eventProvider->dispatch(new OnServerBeforeStart());
|
||||||
|
|
||||||
$manager->start();
|
$manager->start();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
+9
-5
@@ -5,10 +5,12 @@ namespace Server;
|
|||||||
use Annotation\Inject;
|
use Annotation\Inject;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Kiri\Abstracts\Config;
|
use Kiri\Abstracts\Config;
|
||||||
use Kiri\Di\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
use Kiri\Error\Logger;
|
use Kiri\Error\Logger;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use Kiri\Kiri;
|
use Kiri\Kiri;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use Server\Abstracts\BaseProcess;
|
use Server\Abstracts\BaseProcess;
|
||||||
use Server\Contract\OnCloseInterface;
|
use Server\Contract\OnCloseInterface;
|
||||||
@@ -334,10 +336,12 @@ class ServerManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $events
|
* @param array $events
|
||||||
* @param Server|Port $server
|
* @param Server|Port $server
|
||||||
*/
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
private function addServiceEvents(array $events, Server|Port $server)
|
private function addServiceEvents(array $events, Server|Port $server)
|
||||||
{
|
{
|
||||||
foreach ($events as $name => $event) {
|
foreach ($events as $name => $event) {
|
||||||
|
|||||||
Reference in New Issue
Block a user