diff options
-rw-r--r-- | protocols/Steam/src/steam_proto.h | 10 | ||||
-rw-r--r-- | protocols/Steam/src/steam_queue.cpp | 26 |
2 files changed, 28 insertions, 8 deletions
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h index 7824578824..705b2e080b 100644 --- a/protocols/Steam/src/steam_proto.h +++ b/protocols/Steam/src/steam_proto.h @@ -69,16 +69,16 @@ struct QueueItem SteamWebApi::HttpRequest *request; void *arg; RESPONSE responseCallback; - RESPONSE responseFailedCallback; + //RESPONSE responseFailedCallback; QueueItem(SteamWebApi::HttpRequest *request) : - request(request), arg(NULL), responseCallback(NULL), responseFailedCallback(NULL) { } + request(request), arg(NULL), responseCallback(NULL)/*, responseFailedCallback(NULL)*/ { } QueueItem(SteamWebApi::HttpRequest *request, RESPONSE response) : - request(request), arg(NULL), responseCallback(response), responseFailedCallback(NULL) { } + request(request), arg(NULL), responseCallback(response)/*, responseFailedCallback(NULL)*/ { } - QueueItem(SteamWebApi::HttpRequest *request, RESPONSE response, RESPONSE responseFailedCallback) : - request(request), arg(NULL), responseCallback(response), responseFailedCallback(responseFailedCallback) { } + //QueueItem(SteamWebApi::HttpRequest *request, RESPONSE response, RESPONSE responseFailedCallback) : + // request(request), arg(NULL), responseCallback(response), responseFailedCallback(responseFailedCallback) { } ~QueueItem() { delete request; responseCallback = NULL; } }; diff --git a/protocols/Steam/src/steam_queue.cpp b/protocols/Steam/src/steam_queue.cpp index a134aa9890..d5eb363ca0 100644 --- a/protocols/Steam/src/steam_queue.cpp +++ b/protocols/Steam/src/steam_queue.cpp @@ -45,9 +45,15 @@ void CSteamProto::StopQueue() {
mir_cslock lock(requests_queue_lock);
- int count = requestsQueue.getCount();
- while (count > 0)
- requestsQueue.remove(--count);
+ while (requestsQueue.getCount() > 0)
+ {
+ QueueItem *item = requestsQueue[0];
+ requestsQueue.remove(0);
+
+ // We call ExecuteRequest() but as we have set isTerminated=true it will only run callback to behave correctly (free arguments, raise errors, etc.)
+ if (item != NULL)
+ ExecuteRequest(item);
+ }
}
// logoff
@@ -76,6 +82,13 @@ void CSteamProto::PushRequest(SteamWebApi::HttpRequest *request, RESPONSE respon void CSteamProto::PushRequest(SteamWebApi::HttpRequest *request, RESPONSE response, void *arg)
{
+ if (isTerminated || !IsOnline())
+ {
+ // Call response callback so it can react properly (free arguments, raise errors, etc.)
+ if (response != NULL)
+ (this->*(response))(NULL, arg);
+ }
+
if (isTerminated)
return;
@@ -91,6 +104,13 @@ void CSteamProto::PushRequest(SteamWebApi::HttpRequest *request, RESPONSE respon void CSteamProto::ExecuteRequest(QueueItem *item)
{
+ if (isTerminated || !IsOnline())
+ {
+ // Call response callback so it can react properly (free arguments, raise errors, etc.)
+ if (item->responseCallback != NULL)
+ (this->*(item->responseCallback))(NULL, item->arg);
+ }
+
if (isTerminated)
return;
|