改名
This commit is contained in:
+11
-3
@@ -9,8 +9,11 @@ use Kiri\Abstracts\Component;
|
|||||||
use Kiri\Abstracts\Config;
|
use Kiri\Abstracts\Config;
|
||||||
use Kiri\Consul\Agent;
|
use Kiri\Consul\Agent;
|
||||||
use Kiri\Di\NoteManager;
|
use Kiri\Di\NoteManager;
|
||||||
|
use Kiri\Events\EventProvider;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use Kiri\Kiri;
|
use Kiri\Kiri;
|
||||||
|
use Server\Events\OnStart;
|
||||||
|
use Server\ServerManager;
|
||||||
use Server\SInterface\OnCloseInterface;
|
use Server\SInterface\OnCloseInterface;
|
||||||
use Server\SInterface\OnConnectInterface;
|
use Server\SInterface\OnConnectInterface;
|
||||||
use Server\SInterface\OnReceiveInterface;
|
use Server\SInterface\OnReceiveInterface;
|
||||||
@@ -33,12 +36,18 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa
|
|||||||
#[Inject(Annotation::class)]
|
#[Inject(Annotation::class)]
|
||||||
public Annotation $annotation;
|
public Annotation $annotation;
|
||||||
|
|
||||||
|
|
||||||
|
#[Inject(EventProvider::class)]
|
||||||
|
public EventProvider $eventProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function init(): void
|
public function init(): void
|
||||||
{
|
{
|
||||||
|
$this->eventProvider->on(OnStart::class, [$this, 'register']);
|
||||||
|
|
||||||
$this->annotation->read(APP_PATH . 'rpc', 'Rpc');
|
$this->annotation->read(APP_PATH . 'rpc', 'Rpc');
|
||||||
|
|
||||||
$data = $this->annotation->runtime(APP_PATH . 'rpc');
|
$data = $this->annotation->runtime(APP_PATH . 'rpc');
|
||||||
@@ -58,21 +67,20 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->register();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
*/
|
*/
|
||||||
public function register()
|
public function register(Server $server)
|
||||||
{
|
{
|
||||||
$config = Config::get('rpc');
|
$config = Config::get('rpc');
|
||||||
|
|
||||||
$agent = Kiri::getDi()->get(Agent::class);
|
$agent = Kiri::getDi()->get(Agent::class);
|
||||||
$data = $agent->service->register($config['registry']['config']);
|
$data = $agent->service->register($config['registry']['config']);
|
||||||
if ($data->getStatusCode() != 200) {
|
if ($data->getStatusCode() != 200) {
|
||||||
exit($data->getBody()->getContents());
|
$server->shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user