This code is from my dynamic library. The program, which is using it, does not enter the constructor of the AskReceiveAnswerObject class. What could be a reason for this behavior?
RequestObject.h
class RequestObject{
public:
virtual void life() = 0;
virtual bool isActive() = 0;
virtual void stop() = 0;
virtual std::string getNeededMessage() = 0;
virtual bool isYours(std::string message) = 0;
virtual ~RequestObject() = default;
RequestObject() = default;
};
class AskReceiveAnswerObject : public RequestObject{
bool isWaiting;
bool isRunning;
bool isDead;
Handlers::RequestHandler* handler;
SocketClient* client;
std::string request_body;
std::string response_body;
std::string needed_message;
public:
virtual void life();
virtual void stop();
virtual bool isActive();
virtual std::string getNeededMessage();
virtual bool isYours(std::string message);
virtual ~AskReceiveAnswerObject();
AskReceiveAnswerObject(
std::string request_body,
Handlers::RequestHandler* handler,
SocketClient* client);
std::string getResponseBody();
};
RequestObject.cpp
AskReceiveAnswerObject::AskReceiveAnswerObject(
std::string request_body,
Handlers::RequestHandler* handler,
SocketClient* client) : RequestObject(){
this->request_body = request_body;
this->handler = handler;
this->client = client;
this->isDead = false;
this->isWaiting = false;
this->isRunning = true;
}
And the call of the constructor:
std::string SocketClient::sendRequest(std::string request_body){
AskReceiveAnswerObject requestObject = AskReceiveAnswerObject(request_body, this->handler, this);
requestObject.life();
while(requestObject.isActive());
std::string response = requestObject.getResponseBody();
requestObject.stop();
return response;
}
Aucun commentaire:
Enregistrer un commentaire