handle dead commands when the connection is lost before the reply gets processed
This commit is contained in:
parent
53afd65beb
commit
e76502cf0e
4 changed files with 23 additions and 1 deletions
|
@ -166,8 +166,14 @@ void RemoteClient::doDisconnectFromServer()
|
|||
messageLength = 0;
|
||||
|
||||
QList<PendingCommand *> pc = pendingCommands.values();
|
||||
for (int i = 0; i < pc.size(); i++)
|
||||
for (int i = 0; i < pc.size(); i++) {
|
||||
Response response;
|
||||
response.set_response_code(Response::RespNotConnected);
|
||||
response.set_cmd_id(pc[i]->getCommandContainer().cmd_id());
|
||||
pc[i]->processResponse(response);
|
||||
|
||||
delete pc[i];
|
||||
}
|
||||
pendingCommands.clear();
|
||||
|
||||
setStatus(StatusDisconnected);
|
||||
|
|
|
@ -177,6 +177,9 @@ void TabDeckStorage::actUpload()
|
|||
|
||||
void TabDeckStorage::uploadFinished(const Response &r, const CommandContainer &commandContainer)
|
||||
{
|
||||
if (r.response_code() != Response::RespOk)
|
||||
return;
|
||||
|
||||
const Response_DeckUpload &resp = r.GetExtension(Response_DeckUpload::ext);
|
||||
const Command_DeckUpload &cmd = commandContainer.session_command(0).GetExtension(Command_DeckUpload::ext);
|
||||
|
||||
|
@ -208,6 +211,9 @@ void TabDeckStorage::actOpenRemoteDeck()
|
|||
|
||||
void TabDeckStorage::openRemoteDeckFinished(const Response &r)
|
||||
{
|
||||
if (r.response_code() != Response::RespOk)
|
||||
return;
|
||||
|
||||
const Response_DeckDownload &resp = r.GetExtension(Response_DeckDownload::ext);
|
||||
|
||||
// WndDeckEditor *deckEditor = new WndDeckEditor;
|
||||
|
@ -243,6 +249,9 @@ void TabDeckStorage::actDownload()
|
|||
|
||||
void TabDeckStorage::downloadFinished(const Response &r, const CommandContainer &/*commandContainer*/, const QVariant &extraData)
|
||||
{
|
||||
if (r.response_code() != Response::RespOk)
|
||||
return;
|
||||
|
||||
const Response_DeckDownload &resp = r.GetExtension(Response_DeckDownload::ext);
|
||||
QString filePath = extraData.toString();
|
||||
|
||||
|
|
|
@ -162,6 +162,9 @@ void TabReplays::actOpenRemoteReplay()
|
|||
|
||||
void TabReplays::openRemoteReplayFinished(const Response &r)
|
||||
{
|
||||
if (r.response_code() != Response::RespOk)
|
||||
return;
|
||||
|
||||
const Response_ReplayDownload &resp = r.GetExtension(Response_ReplayDownload::ext);
|
||||
GameReplay *replay = new GameReplay;
|
||||
replay->ParseFromString(resp.replay_data());
|
||||
|
@ -197,6 +200,9 @@ void TabReplays::actDownload()
|
|||
|
||||
void TabReplays::downloadFinished(const Response &r, const CommandContainer &commandContainer, const QVariant &extraData)
|
||||
{
|
||||
if (r.response_code() != Response::RespOk)
|
||||
return;
|
||||
|
||||
const Response_ReplayDownload &resp = r.GetExtension(Response_ReplayDownload::ext);
|
||||
QString filePath = extraData.toString();
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
message Response {
|
||||
enum ResponseCode {
|
||||
RespNotConnected = -1;
|
||||
RespNothing = 0;
|
||||
RespOk = 1;
|
||||
RespNotInRoom = 2;
|
||||
|
|
Loading…
Reference in a new issue