connection = null; $this->build(['layout' => 'column', 'padding' => 24, 'gap' => 12, 'children' => [ ['type' => 'label', 'text' => 'JumPHP runtime', 'style' => 'title'], ['type' => 'label', 'id' => 'mode', 'style' => 'muted', 'text' => ''], ['class' => RuntimeBadge::class, 'id' => 'badge'], ['class' => \JumPHP\Runtime\RuntimeBanner::class, 'id' => 'notice'], ['type' => 'button', 'id' => 'connect', 'text' => 'Connect to 127.0.0.1:6379', 'style' => 'primary', 'events' => ['click' => 'onConnectClick']], ['type' => 'label', 'id' => 'result', 'text' => ''], ['type' => 'button', 'id' => 'menu', 'text' => '< MENU', 'events' => ['click' => 'onMenuClick']], ]]); $this->mode->text = 'Network mode: ' . $this->engine->config->netMode() . ' (project.yaml net_mode)'; } public function onMenuClick(mixed $sender = null): void { $this->scenes()->switchTo(TitleScene::class); } public function onConnectClick(mixed $sender = null): void { $this->connection?->close(); $this->result->text = 'Connecting...'; $this->connection = $this->engine->tcp()->connect('127.0.0.1', 6379, 3.0); $this->connection->on('open', fn () => $this->result->text = 'Connected'); $this->connection->on('error', fn (string $why) => $this->result->text = 'Not connected: ' . $why); } }