Ticket #4315: 4315-lobby-kick-v1.patch

File 4315-lobby-kick-v1.patch, 2.3 KB (added by sbirmi, 7 years ago)

Return to main menu if we are kicked. See comment 5 in #4315 for details and questions.

  • binaries/data/mods/public/gui/credits/texts/programming.json

     
    176176            {"nick": "Sandarac"},
    177177            {"nick": "sanderd17", "name": "Sander Deryckere"},
    178178            {"nick": "sathyam", "name": "Sathyam Vellal"},
     179            {"nick": "sbirmi", "name": "Sharad Birmiwal"},
    179180            {"nick": "sbte", "name": "Sven Baars"},
    180181            {"nick": "scroogie", "name": "André Gemünd"},
    181182            {"nick": "scythetwirler", "name": "Casey X."},
  • binaries/data/mods/public/gui/lobby/lobby.js

     
    156156                }),
    157157                "isSpecial": true
    158158            });
     159            // I am getting kicked
     160            if (msg.text == g_Username) {
     161                warn("Got disconnected from the lobby");
     162                returnToMainMenu();
     163            }
     164            return {'kicked': true};
    159165        },
    160166        "presence": msg => {
    161167        },
     
    728734}
    729735
    730736/**
     737 * Parse the result of g_NetMessageTypes's response (if any).
     738 *
     739 * @param {Object} result - the response from netMessageResultAttr
     740 * @param {string} attr - the attribute in the response
     741 * @param {any} defaultValue - default value to return if attribute
     742 *                           is not found in the response
     743 */
     744function netMessageResultAttr(result, attr, defaultValue)
     745{
     746    if (result === undefined)
     747        return defaultValue;
     748    if (result.hasOwnProperty(attr))
     749        return result[attr];
     750    return defaultValue;
     751}
     752
     753/**
    731754 * Processes GUI messages sent by the XmppClient.
    732755 */
    733756function onTick()
     
    751774            warn("Unrecognised message level: " + msg.level);
    752775            continue;
    753776        }
    754         g_NetMessageTypes[msg.type][msg.level](msg);
     777        let result = g_NetMessageTypes[msg.type][msg.level](msg);
    755778
    756779        // To improve performance, only update the playerlist GUI when
    757780        // the last update in the current stack is processed
    758         if (msg.type == "chat" && Engine.LobbyGetMucMessageCount() == 0)
     781        if (msg.type == "chat" && Engine.LobbyGetMucMessageCount() == 0 &&
     782            netMessageResultAttr(result, "kicked", false) == false)
    759783            updatePlayerList();
    760784    }
    761785}