mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-24 10:23:02 -07:00
[Client] Bound stale-membership room join heal to one attempt
The RespContextError heal (leave + rejoin) previously recurred unconditionally, so a server that kept returning RespContextError for a reason other than stale membership would loop forever. Track room ids that already received a heal and surface the error dialog after one attempt instead of retrying indefinitely.
This commit is contained in:
parent
ffc938c977
commit
b98d725bc7
2 changed files with 19 additions and 1 deletions
|
|
@ -229,6 +229,7 @@ void TabServer::joinRoomFinished(const Response &r,
|
||||||
|
|
||||||
switch (r.response_code()) {
|
switch (r.response_code()) {
|
||||||
case Response::RespOk:
|
case Response::RespOk:
|
||||||
|
healedRoomJoins.remove(roomId);
|
||||||
break;
|
break;
|
||||||
case Response::RespNameNotFound:
|
case Response::RespNameNotFound:
|
||||||
if (setCurrent) {
|
if (setCurrent) {
|
||||||
|
|
@ -238,10 +239,24 @@ void TabServer::joinRoomFinished(const Response &r,
|
||||||
emit roomJoinFailed(roomId);
|
emit roomJoinFailed(roomId);
|
||||||
return;
|
return;
|
||||||
case Response::RespContextError:
|
case Response::RespContextError:
|
||||||
|
if (healedRoomJoins.contains(roomId)) {
|
||||||
|
// A stale-membership heal was already attempted once; if the server still
|
||||||
|
// rejects the join there is nothing left to do client-side, so surface it.
|
||||||
|
if (setCurrent) {
|
||||||
|
QMessageBox::critical(
|
||||||
|
this, tr("Error"),
|
||||||
|
tr("The server thinks you are in the server room but your client is unable to display it. "
|
||||||
|
"Try restarting your client."));
|
||||||
|
}
|
||||||
|
emit roomJoinFailed(roomId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// The server already had us registered in the room even though no tab was open,
|
// The server already had us registered in the room even though no tab was open,
|
||||||
// usually because two join attempts for the same room overlapped. Leaving and
|
// usually because two join attempts for the same room overlapped. Leaving and
|
||||||
// rejoining makes the server reply with a fresh RespOk so the tab is displayed
|
// rejoining makes the server reply with a fresh RespOk so the tab is displayed
|
||||||
// without requiring a client restart.
|
// without requiring a client restart. This is attempted only once: if the server
|
||||||
|
// keeps replying with RespContextError we must not loop forever.
|
||||||
|
healedRoomJoins.insert(roomId);
|
||||||
leaveAndRejoinRoom(roomId, setCurrent);
|
leaveAndRejoinRoom(roomId, setCurrent);
|
||||||
return;
|
return;
|
||||||
case Response::RespUserLevelTooLow:
|
case Response::RespUserLevelTooLow:
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QSet>
|
||||||
#include <QTextBrowser>
|
#include <QTextBrowser>
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
|
|
||||||
|
|
@ -67,6 +68,8 @@ private:
|
||||||
bool shouldEmitUpdate = false;
|
bool shouldEmitUpdate = false;
|
||||||
/** Room ids with a join command in flight, mapped to whether the tab should be focused once it opens. */
|
/** Room ids with a join command in flight, mapped to whether the tab should be focused once it opens. */
|
||||||
QMap<int, bool> pendingRoomJoins;
|
QMap<int, bool> pendingRoomJoins;
|
||||||
|
/** Room ids for which a stale-membership heal (leave + rejoin) has already been attempted. */
|
||||||
|
QSet<int> healedRoomJoins;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TabServer(TabSupervisor *_tabSupervisor, AbstractClient *_client);
|
TabServer(TabSupervisor *_tabSupervisor, AbstractClient *_client);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue