0xc3 1 dzień temu
rodzic
commit
426d51694e

+ 0 - 2
src/saura/app/app.cpp

@@ -8,8 +8,6 @@ App::App() {
 
   os_ctx = std::make_unique<OS>();
   os_ctx->set_root_window_title(get_app_base()->get_title());
-
-  server_api_ctx = std::make_shared<ServerAPI>();
 }
 
 App::~App() {}

+ 0 - 2
src/saura/app/app.hpp

@@ -2,7 +2,6 @@
 #define SAURA_APP_HPP_
 
 #include "saura/core/os/os.hpp"
-#include "saura/core/server/server.hpp"
 
 #include <SDL3/SDL_render.h>
 #include <SDL3/SDL_video.h>
@@ -12,7 +11,6 @@ namespace saura {
 class App {
 private:
   std::unique_ptr<OS> os_ctx;
-  std::shared_ptr<ServerAPI> server_api_ctx;
 
   bool is_running;
 

+ 14 - 6
src/saura/cmd/sandbox/sandbox.cpp

@@ -5,18 +5,26 @@
 #include <imgui.h>
 #include <imgui_internal.h>
 
+#include "server/server.hpp"
+
 namespace saura {
 struct SandboxApp : AppBase {
-  void start() override { spdlog::info("Sandbox start!"); }
+  std::shared_ptr<ServerAPI> server_api_ctx;
+
+  void start() override {
+      spdlog::info("Sandbox start!");
+
+      server_api_ctx = std::make_shared<ServerAPI>();
+  }
 
   void update(double dt) override {
-      ImGui::SetNextWindowPos({0.0f, 0.0f});
-      ImGui::SetNextWindowSize(ImGui::GetIO().DisplaySize);
-      ImGui::Begin("Demo", 0, ImGuiWindowFlags_NoDecoration);
+    ImGui::SetNextWindowPos({0.0f, 0.0f});
+    ImGui::SetNextWindowSize(ImGui::GetIO().DisplaySize);
+    ImGui::Begin("Demo", 0, ImGuiWindowFlags_NoDecoration);
 
-      ImGui::Text("%s", this->get_title().c_str());
+    ImGui::Text("%s", this->get_title().c_str());
 
-      ImGui::End();
+    ImGui::End();
   }
 
   void stop() override { spdlog::info("Sandbox stop!"); }

+ 8 - 2
src/saura/core/server/server.cpp → src/saura/cmd/sandbox/server/server.cpp

@@ -3,6 +3,9 @@
 #include <cpr/api.h>
 #include <cpr/cprtypes.h>
 #include <cpr/timeout.h>
+
+#include <spdlog/spdlog.h>
+
 #include <thread>
 
 namespace saura {
@@ -17,13 +20,16 @@ ServerAPI::~ServerAPI() {
 
 void ServerAPI::check_is_live() {
   while (true) {
-    auto res =
-        cpr::Get(cpr::Url{"http://localhost:8090/ping"}, cpr::Timeout{1000});
+    auto res = cpr::Get(cpr::Url{"http://api.localhost:8090/ping"},
+                        cpr::Timeout{1000});
     if (res.status_code == 200) {
       is_live = true;
     } else {
       is_live = false;
     }
+
+    spdlog::info("server.status_code: {0}", res.status_code);
+
     std::this_thread::sleep_for(std::chrono::seconds(1));
   }
 }

+ 0 - 0
src/saura/core/server/server.hpp → src/saura/cmd/sandbox/server/server.hpp