You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#include "extapi_service.hpp"
#include "configs/project_setting.hpp"
#include "iflytop/components/zcanreceiver/zcanreceiverhost.hpp"
#include "iflytop/core/components/stringutils.hpp"
#include "iflytop/core/core.hpp"
#include "version.hpp"
using namespace iflytop; using namespace core; using namespace std; using namespace nlohmann; #define BIND
namespace iflytop {};
/*******************************************************************************
* TOOLS * *******************************************************************************/ static void getJsonValFromJson(json j, int& val) { if (j.is_string()) { string valstr = j; val = atoi(valstr.c_str()); } else if (j.is_number()) { val = j; } else { throw std::runtime_error("getJsonValFromJson(int) error"); } }
template <typename T> static T jsonGet(json j) { T val; getJsonValFromJson(j, val); return val; }
void ExtAPIService::dosystem(string order) { logger->info("do:{}", order); system(order.c_str()); }
void ExtAPIService::initialize() { GET_TO_SERVICE(m_zconfig);
m_restfulServer.reset(new RestfulServer()); m_restfulServer->regAPI("/hello_world", RESTFUL_SERVER_BIND(ExtAPIService::hello_world)); m_restfulServer->start(20000, 20001, "0.0.0.0");
m_iflytopwsService.reset(new IflytopFrontEndService()); m_iflytopwsService->initialize("0.0.0.0"); m_iflytopwsService->startListen(); };
HttpResponsePtr ExtAPIService::hello_world( //
HttpRequestPtr request, shared_ptr<RestfulServer::Context> context, std::shared_ptr<ConnectionState>) { return std::make_shared<HttpResponse>(200, "OK", HttpErrorCode::Ok, WebSocketHttpHeaders(), "hello_world"); }
|