HttpRequestDemo.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include "Sample.h"
  5. namespace Urho3D
  6. {
  7. class HttpRequest;
  8. class Text;
  9. }
  10. /// Http request example.
  11. /// This example demonstrates:
  12. /// - How to use Http request API
  13. class HttpRequestDemo : public Sample
  14. {
  15. URHO3D_OBJECT(HttpRequestDemo, Sample);
  16. public:
  17. /// Construct.
  18. explicit HttpRequestDemo(Context* context);
  19. /// Setup after engine initialization and before running the main loop.
  20. void Start() override;
  21. protected:
  22. /// Return XML patch instructions for screen joystick layout for a specific sample app, if any.
  23. String GetScreenJoystickPatchString() const override { return
  24. "<patch>"
  25. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Hat0']]\">"
  26. " <attribute name=\"Is Visible\" value=\"false\" />"
  27. " </add>"
  28. "</patch>";
  29. }
  30. private:
  31. /// Create the user interface.
  32. void CreateUI();
  33. /// Subscribe to application-wide logic update events.
  34. void SubscribeToEvents();
  35. /// Handle the logic update event.
  36. void HandleUpdate(StringHash eventType, VariantMap& eventData);
  37. String message_;
  38. SharedPtr<Text> text_;
  39. SharedPtr<HttpRequest> httpRequest_;
  40. };