X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fxapp.cc;h=54b75fd0e39134a2b8144f6a1ca6617f3b733414;hb=91d30a6530398a9c7e50a15ea1cf9a027953bd39;hp=41016991669be965ea2ec3e1baa0d01ca48e4c0f;hpb=b85024cd183a527cd8d61353637850cb6d30cf36;p=ric-app%2Fhw.git diff --git a/src/xapp.cc b/src/xapp.cc index 4101699..54b75fd 100644 --- a/src/xapp.cc +++ b/src/xapp.cc @@ -20,7 +20,6 @@ * xapp.cc * * Created on: Mar, 2020 - * Author: Shraboni Jana */ #include "xapp.hpp" @@ -36,15 +35,27 @@ Xapp::~Xapp(void){ //Joining the threads int threadcnt = xapp_rcv_thread.size(); - for(int i=0; i~mutex(); + delete xapp_mutex; + } }; +//stop the xapp. +void Xapp::stop(void){ + // Get the mutex lock + std::lock_guard guard(*xapp_mutex); + rmr_ref->set_listen(false); + rmr_ref->~XappRmr(); + +} + void Xapp::init() { //get rnib information @@ -61,7 +72,7 @@ void Xapp::startup() { void Xapp::start_xapp_receiver(XappMsgHandler& mp_handler){ //start a receiver thread. Can be multiple receiver threads for more than 1 listening port. - + rmr_ref->set_listen(true); xapp_mutex = new std::mutex(); mdclog_write(MDCLOG_INFO,"Receiver Thread file= %s, line=%d",__FILE__,__LINE__); @@ -88,13 +99,13 @@ void Xapp::shutdown(){ void Xapp::startup_subscribe_requests(void ){ size_t data_size = ASN_BUFF_MAX_SIZE; unsigned char data[data_size]; - + std::string xapp_id = config_ref->operator [](XappSettings::SettingName::XAPP_ID); for(auto &it: rnib_gnblist){ int attempt = 0; - XappMsgHandler msg; + XappMsgHandler msg = XappMsgHandler(xapp_id); - /* bool res_encode = msg.encode_subscription_request(data, &data_size); - if(!res_encode) exit(0);*/ + //bool res_encode = msg.encode_subscription_request(data, &data_size); + //if(!res_encode) exit(0); char *strMsg = "HelloWorld\0"; strncpy((char *)data,strMsg,strlen(strMsg)); data_size = sizeof(data); @@ -106,6 +117,8 @@ void Xapp::startup_subscribe_requests(void ){ auto transmitter = std::bind(&XappRmr::xapp_rmr_send,rmr_ref, &rmr_header, (void*)data); transmitter(); //this will go to subscription manager. + //rmr_ref->xapp_rmr_call(&rmr_header,(char*)strMsg); + break; } } @@ -141,8 +154,11 @@ void Xapp::set_rnib_gnblist(void) { Document doc; doc.Parse((char*)result); assert(doc.HasMember("gnb_list")); + + const Value& gnblist = doc["gnb_list"]; assert(gnblist.IsArray()); + for (SizeType i = 0; i < gnblist.Size(); i++) // Uses SizeType instead of size_t { assert(gnblist[i].IsObject()); @@ -153,7 +169,8 @@ void Xapp::set_rnib_gnblist(void) { } closeSdl(); - free(result); + + //delete result; return; }