int response_to = 0; // max timeout wating for a response
int rmtype; // received message type
- fprintf(stderr, "[INFO] Policy Callback got a message, type=%d, length=%d\n", mtype, len);
+ string arg ((const char*)payload.get(), len); // RMR payload might not have a nil terminanted char
- const char *arg = (const char*)payload.get();
-
- fprintf(stderr, "[INFO] Payload is %s\n", arg);
+ cout << "[INFO] Policy Callback got a message, type=" << mtype << ", length="<< len << "\n";
+ cout << "[INFO] Payload is " << arg << endl;
PolicyHandler handler;
Reader reader;
- StringStream ss(arg);
+ StringStream ss(arg.c_str());
reader.Parse(ss,handler);
//Set the threshold value
if (handler.found_threshold) {
- fprintf(stderr, "[INFO] Setting RSRP Threshold to A1-P value: %d\n", handler.threshold);
+ cout << "[INFO] Setting RSRP Threshold to A1-P value: " << handler.threshold << endl;
rsrp_threshold = handler.threshold;
}
int rmtype; // received message type
int delay = 1000000; // mu-sec delay; default 1s
+ string json ((char *)payload.get(), len); // RMR payload might not have a nil terminanted char
+
cout << "[INFO] Prediction Callback got a message, type=" << mtype << ", length=" << len << "\n";
- cout << "[INFO] Payload is " << payload.get() << endl;
+ cout << "[INFO] Payload is " << json << endl;
- const char* arg = (const char*)payload.get();
PredictionHandler handler;
-
try {
Reader reader;
- StringStream ss(arg);
+ StringStream ss(json.c_str());
reader.Parse(ss,handler);
} catch (...) {
cout << "[ERROR] Got an exception on stringstream read parse\n";
string message_body = "{\"UEPredictionSet\": " + ues_list + "}";
- const char *body = message_body.c_str();
-
send_payload = msg->Get_payload(); // direct access to payload
- snprintf( (char *) send_payload.get(), 2048, "%s", body );
+ snprintf( (char *) send_payload.get(), 2048, "%s", message_body.c_str() );
- /*
- we are sending a string, so we have to include the nil byte in the RMR message
- to keep things simple in the receiver side
- */
- plen = strlen( (char *) send_payload.get() ) + 1;
+ plen = strlen( (char *)send_payload.get() );
cout << "[INFO] Prediction Request length=" << plen << ", payload=" << send_payload.get() << endl;
* sends a prediction request to the QP Driver xApp.
*/
void ad_callback( Message& mbuf, int mtype, int subid, int len, Msg_component payload, void* data ) {
- const char *json = (const char *) payload.get();
+ string json ((char *)payload.get(), len); // RMR payload might not have a nil terminanted char
cout << "[INFO] AD Callback got a message, type=" << mtype << ", length=" << len << "\n";
cout << "[INFO] Payload is " << json << "\n";
AnomalyHandler handler;
Reader reader;
- StringStream ss(json);
+ StringStream ss(json.c_str());
reader.Parse(ss,handler);
// just sending ACK to the AD xApp
unique_ptr<Xapp> xfw;
void ts_callback( Message& mbuf, int mtype, int subid, int len, Msg_component payload, void* data ) {
+ string json ((char *)payload.get(), len);
+
cout << "[AD] TS Callback got a message, type=" << mtype << ", length=" << len << "\n";
- cout << "[AD] Payload is " << payload.get() << endl;
+ cout << "[AD] Payload is " << json << endl;
// we only send one message, so we expect to receive only one as well
xfw->Stop();
payload = msg->Get_payload();
snprintf( (char *) payload.get(), 2048, "%s", ad_msg );
- /*
- we are sending a string, so we have to include the nil byte to send with RMR and keep
- things simple in the receiver side
- */
- plen = strlen( (char *) payload.get() ) + 1;
+ plen = strlen( (char *) payload.get() );
cout << "[AD] Sending a message to TS, length: " << plen << "\n";
cout << "[AD] Message body " << payload.get() << endl;
void prediction_callback( Message& mbuf, int mtype, int subid, int len, Msg_component payload, void* data ) {
- cout << "[QP] Prediction Callback got a message, type=" << mtype << ", length=" << len << "\n";
- cout << "[QP] Payload is " << payload.get() << endl;
+ string json ((char *) payload.get(), len);
- int randomNumber;
- srand( (unsigned int) time(0) );
+ cout << "[QP] Prediction Callback got a message, type=" << mtype << ", length=" << len << "\n";
+ cout << "[QP] Payload is " << json << endl;
- const char *json = (const char *) payload.get();
Document document;
- document.Parse(json);
+ document.Parse(json.c_str());
const Value& uePred = document["UEPredictionSet"];
if ( uePred.Size() > 0 ) {
}
}
- /*
- we are sending a string, so we have to include the nil byte to send with RMR and keep
- things simple in the receiver side
- */
- int len = body.size() + 1;
+ int len = body.size();
cout << "[QP] Sending a message to TS, length=" << len << "\n";
cout << "[QP] Message body " << body << endl;
int main(int argc, char const *argv[]) {
int nthreads = 1;
+ srand( (unsigned int) time(0) );
+
char* port = (char *) "4580";
cout << "[QP] listening on port " << port << endl;