Skip to content

Commit

Permalink
Change argument of app::enable_rest to REST port
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed May 12, 2023
1 parent efa2613 commit 3ca10b6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion flecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -44586,7 +44586,7 @@ int ecs_app_run(
#ifdef ECS_TARGET_EM
flecs_wasm_rest_server = ecs_rest_server_init(world, NULL);
#else
ecs_set(world, EcsWorld, EcsRest, {.port = 0});
ecs_set(world, EcsWorld, EcsRest, {.port = desc->port });
#endif
#else
ecs_warn("cannot enable remote API, REST addon not available");
Expand Down
8 changes: 5 additions & 3 deletions flecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -9630,8 +9630,9 @@ typedef struct ecs_app_desc_t {
ecs_ftime_t delta_time; /**< Frame time increment (0 for measured values) */
int32_t threads; /**< Number of threads. */
int32_t frames; /**< Number of frames to run (0 for infinite) */
bool enable_rest; /**< Allows HTTP clients to access ECS data */
bool enable_rest; /**< Enables ECS access over HTTP, necessary for explorer */
bool enable_monitor; /**< Periodically collect statistics */
uint16_t port; /**< HTTP port used by REST API */

ecs_app_init_action_t init; /**< If set, function is ran before starting the
* main loop. */
Expand Down Expand Up @@ -17477,8 +17478,9 @@ struct app_builder {
return *this;
}

app_builder& enable_rest(bool value = true) {
m_desc.enable_rest = value;
app_builder& enable_rest(uint16_t port = 0) {
m_desc.enable_rest = true;
m_desc.port = port;
return *this;
}

Expand Down
3 changes: 2 additions & 1 deletion include/flecs/addons/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ typedef struct ecs_app_desc_t {
ecs_ftime_t delta_time; /**< Frame time increment (0 for measured values) */
int32_t threads; /**< Number of threads. */
int32_t frames; /**< Number of frames to run (0 for infinite) */
bool enable_rest; /**< Allows HTTP clients to access ECS data */
bool enable_rest; /**< Enables ECS access over HTTP, necessary for explorer */
bool enable_monitor; /**< Periodically collect statistics */
uint16_t port; /**< HTTP port used by REST API */

ecs_app_init_action_t init; /**< If set, function is ran before starting the
* main loop. */
Expand Down
5 changes: 3 additions & 2 deletions include/flecs/addons/cpp/mixins/app/builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ struct app_builder {
return *this;
}

app_builder& enable_rest(bool value = true) {
m_desc.enable_rest = value;
app_builder& enable_rest(uint16_t port = 0) {
m_desc.enable_rest = true;
m_desc.port = port;
return *this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/addons/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ int ecs_app_run(
#ifdef ECS_TARGET_EM
flecs_wasm_rest_server = ecs_rest_server_init(world, NULL);
#else
ecs_set(world, EcsWorld, EcsRest, {.port = 0});
ecs_set(world, EcsWorld, EcsRest, {.port = desc->port });
#endif
#else
ecs_warn("cannot enable remote API, REST addon not available");
Expand Down

0 comments on commit 3ca10b6

Please sign in to comment.