public function update(Server $server) : Promise
{
switch ($this->state = $server->state()) {
case Server::STOPPED:
$this->routeDispatcher = null;
break;
case Server::STARTING:
if (empty($this->routes)) {
return new Failure(new \DomainException("Router start failure: no routes registered"));
}
$this->routeDispatcher = simpleDispatcher(function ($rc) use($server) {
$this->buildRouter($rc, $server);
});
break;
}
return new Success();
}