Ticket #3171: t3171_clear_muc_messages_v1.patch

File t3171_clear_muc_messages_v1.patch, 5.9 KB (added by elexis, 9 years ago)

Clears all muc messages (presence updates) in the c++ part when fetching fresh player lists. Should fix the issue. TODO: Find a way to reproduce the originally described bug and prove that the bug fixes it. I will test it in a18 too.

  • binaries/data/mods/public/gui/lobby/lobby.js

     
    153153 *
    154154 * @return Array containing the player, presence, nickname, and rating listings.
    155155 */
    156156function updatePlayerList()
    157157{
     158
     159    Engine.ClearMucMessages();
    158160    var playersBox = Engine.GetGUIObjectByName("playersBox");
    159161    var playerList = [];
    160162    var presenceList = [];
    161163    var nickList = [];
    162164    var ratingList = [];
  • source/lobby/IXmppClient.h

     
    5252    virtual void GUIGetGameList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0;
    5353    virtual void GUIGetBoardList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0;
    5454    virtual void GUIGetProfile(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0;
    5555
    5656    virtual void GuiPollMessage(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0;
     57    virtual void ClearMucMessages() = 0;
    5758    virtual void SendMUCMessage(const std::string& message) = 0;
    5859};
    5960
    6061extern IXmppClient *g_XmppClient;
    6162extern bool g_rankedGame;
  • source/lobby/XmppClient.cpp

     
    620620
    621621    m_GuiMessageQueue.pop_front();
    622622}
    623623
    624624/**
     625 * Clear the GUI message queue.
     626 */
     627void XmppClient::ClearMucMessages()
     628{
     629    // TODO: use mutex lock here?
     630    bool clean;
     631    do
     632    {
     633        clean = true;
     634        for (std::deque<GUIMessage>::iterator it = m_GuiMessageQueue.begin(); it!=m_GuiMessageQueue.end(); ++it)
     635        {
     636            GUIMessage message = *it;
     637            if (message.type == L"muc")
     638            {
     639                debug_printf("Deleting muc message \n");
     640                m_GuiMessageQueue.erase(it);
     641                clean = false;
     642                break;
     643            }
     644        }
     645    } while (!clean);
     646}
     647
     648/**
    625649 * Send a standard MUC textual message.
    626650 */
    627651void XmppClient::SendMUCMessage(const std::string& message)
    628652{
    629653    m_mucRoom->send(message);
  • source/lobby/XmppClient.h

     
    132132        std::wstring from;
    133133        std::wstring message;
    134134        std::string datetime;
    135135    };
    136136    void GuiPollMessage(ScriptInterface& scriptInterface, JS::MutableHandleValue ret);
     137    void ClearMucMessages();
    137138    void SendMUCMessage(const std::string& message);
    138139    protected:
    139140    void PushGuiMessage(XmppClient::GUIMessage message);
    140141    void CreateSimpleMessage(const std::string& type, const std::string& text, const std::string& level = "standard", const std::string& data = "");
    141142
  • source/lobby/scripting/JSInterface_Lobby.cpp

     
    4949    scriptInterface.RegisterFunction<JS::Value, &JSI_Lobby::GetPlayerList>("GetPlayerList");
    5050    scriptInterface.RegisterFunction<JS::Value, &JSI_Lobby::GetGameList>("GetGameList");
    5151    scriptInterface.RegisterFunction<JS::Value, &JSI_Lobby::GetBoardList>("GetBoardList");
    5252    scriptInterface.RegisterFunction<JS::Value, &JSI_Lobby::GetProfile>("GetProfile");
    5353    scriptInterface.RegisterFunction<JS::Value, &JSI_Lobby::LobbyGuiPollMessage>("LobbyGuiPollMessage");
     54    scriptInterface.RegisterFunction<void, &JSI_Lobby::ClearMucMessages>("ClearMucMessages");
    5455    scriptInterface.RegisterFunction<void, std::wstring, &JSI_Lobby::LobbySendMessage>("LobbySendMessage");
    5556    scriptInterface.RegisterFunction<void, std::wstring, &JSI_Lobby::LobbySetPlayerPresence>("LobbySetPlayerPresence");
    5657    scriptInterface.RegisterFunction<void, std::wstring, &JSI_Lobby::LobbySetNick>("LobbySetNick");
    5758    scriptInterface.RegisterFunction<std::wstring, &JSI_Lobby::LobbyGetNick>("LobbyGetNick");
    5859    scriptInterface.RegisterFunction<void, std::wstring, std::wstring, &JSI_Lobby::LobbyKick>("LobbyKick");
     
    243244    g_XmppClient->GuiPollMessage(*(pCxPrivate->pScriptInterface), &poll);
    244245
    245246    return poll;
    246247}
    247248
     249void JSI_Lobby::ClearMucMessages(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
     250{
     251    if (g_XmppClient)
     252        g_XmppClient->ClearMucMessages();
     253}
     254
    248255void JSI_Lobby::LobbySendMessage(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), std::wstring message)
    249256{
    250257    if (!g_XmppClient)
    251258        return;
    252259       
  • source/lobby/scripting/JSInterface_Lobby.h

     
    4747    JS::Value GetPlayerList(ScriptInterface::CxPrivate* pCxPrivate);
    4848    JS::Value GetGameList(ScriptInterface::CxPrivate* pCxPrivate);
    4949    JS::Value GetBoardList(ScriptInterface::CxPrivate* pCxPrivate);
    5050    JS::Value GetProfile(ScriptInterface::CxPrivate* pCxPrivate);
    5151    JS::Value LobbyGuiPollMessage(ScriptInterface::CxPrivate* pCxPrivate);
     52    void ClearMucMessages(ScriptInterface::CxPrivate* pCxPrivate);
    5253    void LobbySendMessage(ScriptInterface::CxPrivate* pCxPrivate, std::wstring message);
    5354    void LobbySetPlayerPresence(ScriptInterface::CxPrivate* pCxPrivate, std::wstring presence);
    5455    void LobbySetNick(ScriptInterface::CxPrivate* pCxPrivate, std::wstring nick);
    5556    std::wstring LobbyGetNick(ScriptInterface::CxPrivate* pCxPrivate);
    5657    void LobbyKick(ScriptInterface::CxPrivate* pCxPrivate, std::wstring nick, std::wstring reason);