Skip to content
Snippets Groups Projects
Commit 5f9a2f51 authored by Stefan Spettel's avatar Stefan Spettel
Browse files

feat(pcf): Implemented de-registration towards NRF

parent 3e075a34
No related branches found
No related tags found
1 merge request!12Refactor HTTP client and NRF service
Pipeline #33275 passed
......@@ -64,6 +64,9 @@ void my_app_signal_handler(int s) {
if (pcf_api_server_2) {
pcf_api_server_2->stop();
}
if (pcf_app_inst) {
pcf_app_inst->stop();
}
}
//------------------------------------------------------------------------------
// We are doing a check to see if an existing process already runs this program.
......
......@@ -77,4 +77,10 @@ pcf_app::~pcf_app() {
std::shared_ptr<pcf_smpc> pcf_app::get_pcf_smpc_service() {
return pcf_smpc_service;
}
void pcf_app::stop() {
if (pcf_nrf_inst) {
pcf_nrf_inst->deregister_to_nrf();
}
}
\ No newline at end of file
......@@ -57,6 +57,12 @@ class pcf_app {
std::shared_ptr<pcf_smpc> get_pcf_smpc_service();
/**
* Stops all the ongoing processes and procedures of the PCF APP layer,
* deregisters at NRF
*/
void stop();
private:
pcf_profile nf_instance_profile; // PCF profile
std::string pcf_instance_id; // PCF instance id
......
......@@ -203,3 +203,21 @@ void pcf_nrf::trigger_nf_heartbeat_procedure(uint64_t ms) {
pcf_nrf::~pcf_nrf() {
Logger::pcf_sbi().debug("Delete PCF_NRF instance...");
}
//------------------------------------------------------------------------------
void pcf_nrf::deregister_to_nrf() {
std::string body_response;
std::string response_header;
Logger::pcf_sbi().info("Sending NF de-registration request");
http_response_codes_e res =
pcf_client_inst->send_delete(nrf_url, body_response, response_header);
if (res != http_response_codes_e::HTTP_RESPONSE_CODE_NO_CONTENT) {
Logger::pcf_sbi().warn(
"NF Deregistration failed! Wrong response code: %d", res);
} else {
Logger::pcf_sbi().info("NF Deregistration successful");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment