Ticket #3171: t3171_clear_muc_messages_v3_r16728.patch
File t3171_clear_muc_messages_v3_r16728.patch, 4.0 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/gui/lobby/lobby.js
8 8 var g_mapSizes = {}; 9 9 const g_mapTypesText = [translateWithContext("map", "Skirmish"), translateWithContext("map", "Random"), translate("Scenario")]; 10 10 const g_mapTypes = ["skirmish", "random", "scenario"]; 11 11 var g_userRating = ""; // Rating of user, defaults to Unrated 12 12 var g_modPrefix = "@"; 13 var g_joined = false;14 13 // Block spammers for 30 seconds. 15 14 var SPAM_BLOCK_LENGTH = 30; 16 15 17 16 //////////////////////////////////////////////////////////////////////////////////////////////// 18 17 … … 634 633 case "join": 635 634 if (nick == g_Name) 636 635 { 637 636 // We just joined, we need to get the full player list 638 637 [playerList, presenceList, nickList, ratingList] = updatePlayerList(); 639 // Don't display any joins until our join request bounces back640 // Our join message should be the last one as we just got added to the stack641 g_joined = true;642 break;643 638 } 644 else if (g_joined)639 else 645 640 { 646 641 var [name, status, rating] = formatPlayerListEntry(nick, presence, "-"); 647 642 playerList.push(name); 648 643 presenceList.push(status); 649 644 nickList.push(nick); -
source/lobby/IXmppClient.h
52 52 virtual void GUIGetGameList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0; 53 53 virtual void GUIGetBoardList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0; 54 54 virtual void GUIGetProfile(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0; 55 55 56 56 virtual void GuiPollMessage(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0; 57 virtual void ClearMucMessages() = 0; 57 58 virtual void SendMUCMessage(const std::string& message) = 0; 58 59 }; 59 60 60 61 extern IXmppClient *g_XmppClient; 61 62 extern bool g_rankedGame; -
source/lobby/XmppClient.cpp
492 492 * 493 493 * @return A JS array containing all known players and their presences 494 494 */ 495 495 void XmppClient::GUIGetPlayerList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) 496 496 { 497 // Clear outdated presence updates, see #3171 498 this->ClearMucMessages(); 499 497 500 JSContext* cx = scriptInterface.GetContext(); 498 501 JSAutoRequest rq(cx); 499 502 500 503 scriptInterface.Eval("([])", ret); 501 504 … … 620 623 621 624 m_GuiMessageQueue.pop_front(); 622 625 } 623 626 624 627 /** 628 * Remove all muc updates from the message queue. 629 */ 630 void XmppClient::ClearMucMessages() 631 { 632 // TODO: use mutex lock here? 633 bool clean; 634 do 635 { 636 clean = true; 637 for (std::deque<GUIMessage>::iterator it = m_GuiMessageQueue.begin(); it!=m_GuiMessageQueue.end(); ++it) 638 { 639 GUIMessage message = *it; 640 if (message.type == L"muc") 641 { 642 m_GuiMessageQueue.erase(it); 643 clean = false; 644 break; 645 } 646 } 647 } while (!clean); 648 } 649 650 /** 625 651 * Send a standard MUC textual message. 626 652 */ 627 653 void XmppClient::SendMUCMessage(const std::string& message) 628 654 { 629 655 m_mucRoom->send(message); -
source/lobby/XmppClient.h
132 132 std::wstring from; 133 133 std::wstring message; 134 134 std::string datetime; 135 135 }; 136 136 void GuiPollMessage(ScriptInterface& scriptInterface, JS::MutableHandleValue ret); 137 void ClearMucMessages(); 137 138 void SendMUCMessage(const std::string& message); 138 139 protected: 139 140 void PushGuiMessage(XmppClient::GUIMessage message); 140 141 void CreateSimpleMessage(const std::string& type, const std::string& text, const std::string& level = "standard", const std::string& data = ""); 141 142