Files
@ 2e508b97c36f
Branch filter:
Location: libtransport.git/libtransport/HTTPRequestQueue.cpp - annotation
2e508b97c36f
1.3 KiB
text/x-c++hdr
Slack: get_oauth2_url now stores uin/password in the state data and use them when registering the user - this makes the registration easier from web interface side
5adb3d1f9733 5adb3d1f9733 26a01b8efa0a 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 26a01b8efa0a 5adb3d1f9733 83ba9855b521 26a01b8efa0a 26a01b8efa0a 26a01b8efa0a 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 26a01b8efa0a 83ba9855b521 83ba9855b521 83ba9855b521 83ba9855b521 26a01b8efa0a 26a01b8efa0a 26a01b8efa0a a025aa108559 26a01b8efa0a 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 a025aa108559 83ba9855b521 26a01b8efa0a 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 83ba9855b521 a025aa108559 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 a025aa108559 83ba9855b521 5adb3d1f9733 83ba9855b521 83ba9855b521 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 a025aa108559 83ba9855b521 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 | #include "transport/HTTPRequestQueue.h"
#include "transport/HTTPRequest.h"
#include "transport/Transport.h"
namespace Transport {
DEFINE_LOGGER(logger, "HTTPRequestQueue")
HTTPRequestQueue::HTTPRequestQueue(Component *component, int delay) {
m_delay = delay;
m_req = NULL;
m_queueTimer = component->getNetworkFactories()->getTimerFactory()->createTimer(500);
m_queueTimer->onTick.connect(boost::bind(&HTTPRequestQueue::sendNextRequest, this));
}
HTTPRequestQueue::~HTTPRequestQueue() {
m_queueTimer->stop();
if (m_req) {
m_req->onRequestFinished.disconnect(boost::bind(&HTTPRequestQueue::handleRequestFinished, this));
}
}
void HTTPRequestQueue::handleRequestFinished() {
m_req = NULL;
m_queueTimer->start();
}
void HTTPRequestQueue::sendNextRequest() {
if (m_queue.empty()) {
LOG4CXX_INFO(logger, "queue is empty");
m_req = NULL;
m_queueTimer->stop();
return;
}
if (m_req) {
LOG4CXX_INFO(logger, "we are handling the request");
return;
}
LOG4CXX_INFO(logger, "Starting new request");
m_req = m_queue.front();
m_queue.pop();
m_req->onRequestFinished.connect(boost::bind(&HTTPRequestQueue::handleRequestFinished, this));
m_req->execute();
}
void HTTPRequestQueue::queueRequest(HTTPRequest *req) {
m_queue.push(req);
LOG4CXX_INFO(logger, "request queued");
if (!m_req) {
sendNextRequest();
}
}
}
|