Skip to content

Commit

Permalink
remove server
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesneimog committed Nov 25, 2024
1 parent 5dd7459 commit 8ba467c
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions Resources/Pd/pd4web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <windows.h>
#endif

#include <httplib.h>
//#include <httplib.h>

static bool global_pd4web_check = false;
static t_class *pd4web_class;
Expand All @@ -38,7 +38,7 @@ class Pd4Web {
std::string cmd;

// Server
httplib::Server *server;
// httplib::Server *server;
std::string projectRoot;
std::string objRoot;

Expand Down Expand Up @@ -390,6 +390,7 @@ static void pd4web_set(Pd4Web *x, t_symbol *s, int argc, t_atom *argv) {
return;
}

/*
// ─────────────────────────────────────
static void pd4web_browser(Pd4Web *x, float f) {
if (!x->isReady) {
Expand Down Expand Up @@ -428,6 +429,8 @@ static void pd4web_browser(Pd4Web *x, float f) {
}
}
*/

// ─────────────────────────────────────
static void pd4web_version(Pd4Web *x) {
std::string cmd = x->pd4web + " --version";
Expand Down Expand Up @@ -551,18 +554,18 @@ static void *pd4web_new(t_symbol *s, int argc, t_atom *argv) {
x->tpl = 0;
x->version = PD4WEB_EXTERNAL_VERSION;

x->server = new httplib::Server();
if (!x->server->is_valid()) {
pd_error(x, "[pd4web] Failed to create Server");
}
// x->server = new httplib::Server();
// if (!x->server->is_valid()) {
// pd_error(x, "[pd4web] Failed to create Server");
// }
return x;
}

// ─────────────────────────────────────
static void pd4web_free(Pd4Web *x) {
httplib::Client client("http://localhost:8080");
auto res = client.Get("/stop");
delete x->server;
//httplib::Client client("http://localhost:8080");
//auto res = client.Get("/stop");
//delete x->server;
x->cancel = true;
post("[pd4web] Stopping pd4web...");
while (x->running) {
Expand All @@ -578,7 +581,7 @@ extern "C" void pd4web_setup(void) {

class_addmethod(pd4web_class, (t_method)pd4web_get, gensym("get"), A_GIMME, A_NULL);
class_addmethod(pd4web_class, (t_method)pd4web_set, gensym("set"), A_GIMME, A_NULL);
class_addmethod(pd4web_class, (t_method)pd4web_browser, gensym("browser"), A_FLOAT, A_NULL);
//class_addmethod(pd4web_class, (t_method)pd4web_browser, gensym("browser"), A_FLOAT, A_NULL);
class_addmethod(pd4web_class, (t_method)pd4web_update, gensym("update"), A_GIMME, 0);
class_addmethod(pd4web_class, (t_method)pd4web_update, gensym("git"), A_GIMME, 0);
class_addmethod(pd4web_class, (t_method)pd4web_clear_install, gensym("uninstall"), A_NULL);
Expand Down

0 comments on commit 8ba467c

Please sign in to comment.