Commit d4678312 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Sending notification for NF Status profile change

parent 722fe5e7
...@@ -269,6 +269,8 @@ void nrf_client::notify_subscribed_event( ...@@ -269,6 +269,8 @@ void nrf_client::notify_subscribed_event(
json_data["nfProfile"] = json_profile; json_data["nfProfile"] = json_profile;
} }
// TODO: profileChanges in case of "NF_PROFILE_CHANGED" instead of NF Profile
std::string body = json_data.dump(); std::string body = json_data.dump();
for (auto uri : uris) { for (auto uri : uris) {
......
...@@ -90,11 +90,13 @@ void nrf_profile::set_nf_status(const std::string& status) { ...@@ -90,11 +90,13 @@ void nrf_profile::set_nf_status(const std::string& status) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_profile::get_nf_status(std::string& status) const { void nrf_profile::get_nf_status(std::string& status) const {
std::shared_lock lock(heartbeart_mutex);
status = nf_status; status = nf_status;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
std::string nrf_profile::get_nf_status() const { std::string nrf_profile::get_nf_status() const {
std::shared_lock lock(heartbeart_mutex);
return nf_status; return nf_status;
} }
...@@ -723,7 +725,7 @@ void nrf_profile::handle_heartbeart_timeout_nfregistration(uint64_t ms) { ...@@ -723,7 +725,7 @@ void nrf_profile::handle_heartbeart_timeout_nfregistration(uint64_t ms) {
"%d", "%d",
nf_instance_id.c_str(), ms); nf_instance_id.c_str(), ms);
// Set status to SUSPENDED and unsubscribe to the HBT // Set status to SUSPENDED and unsubscribe to the HBT
if (!is_updated) { if (!get_status_updated()) {
set_nf_status("SUSPENDED"); set_nf_status("SUSPENDED");
} }
...@@ -741,8 +743,11 @@ void nrf_profile::handle_heartbeart_timeout_nfupdate(uint64_t ms) { ...@@ -741,8 +743,11 @@ void nrf_profile::handle_heartbeart_timeout_nfupdate(uint64_t ms) {
"current " "current "
"ms %ld", "ms %ld",
nf_instance_id.c_str(), ms, current_ms); nf_instance_id.c_str(), ms, current_ms);
if (!is_updated) { if (!get_status_updated()) {
set_nf_status("SUSPENDED"); set_nf_status("SUSPENDED");
// TODO: Notify to the subscribers
// notifCondition with ["monitoredAttributes": [ "/nfStatus""]
m_event_sub.nf_status_profile_changed(nf_instance_id);
} }
set_status_updated(false); set_status_updated(false);
} }
...@@ -753,6 +758,18 @@ void nrf_profile::set_status_updated(bool status) { ...@@ -753,6 +758,18 @@ void nrf_profile::set_status_updated(bool status) {
is_updated = status; is_updated = status;
} }
//------------------------------------------------------------------------------
void nrf_profile::get_status_updated(bool& status) {
std::shared_lock lock(heartbeart_mutex);
status = is_updated;
}
//------------------------------------------------------------------------------
bool nrf_profile::get_status_updated() {
std::shared_lock lock(heartbeart_mutex);
return is_updated;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_profile::add_amf_info(const amf_info_t& info) { void amf_profile::add_amf_info(const amf_info_t& info) {
amf_info = info; amf_info = info;
......
...@@ -497,6 +497,20 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> { ...@@ -497,6 +497,20 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
*/ */
void set_status_updated(bool status); void set_status_updated(bool status);
/*
* Get status updated
* @param void
* @return status
*/
bool get_status_updated();
/*
* Get status updated
* @param status
* @return void
*/
void get_status_updated(bool& status);
protected: protected:
nrf_event& m_event_sub; nrf_event& m_event_sub;
bs2::connection bs2::connection
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment