Ticket #3171: t3171_clear_muc_messages_v2_a18.patch
File t3171_clear_muc_messages_v2_a18.patch, 2.6 KB (added by , 9 years ago) |
---|
-
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 … … 618 621 619 622 m_GuiMessageQueue.pop_front(); 620 623 } 621 624 622 625 /** 626 * Remove all muc updates from the message queue. 627 */ 628 void XmppClient::ClearMucMessages() 629 { 630 // TODO: use mutex lock here? 631 bool clean; 632 do 633 { 634 clean = true; 635 for (std::deque<GUIMessage>::iterator it = m_GuiMessageQueue.begin(); it!=m_GuiMessageQueue.end(); ++it) 636 { 637 GUIMessage message = *it; 638 if (message.type == L"muc") 639 { 640 m_GuiMessageQueue.erase(it); 641 clean = false; 642 break; 643 } 644 } 645 } while (!clean); 646 } 647 648 /** 623 649 * Send a standard MUC textual message. 624 650 */ 625 651 void XmppClient::SendMUCMessage(const std::string& message) 626 652 { 627 653 m_mucRoom->send(message); -
source/lobby/XmppClient.h
131 131 std::wstring data; 132 132 std::wstring from; 133 133 std::wstring message; 134 134 }; 135 135 void GuiPollMessage(ScriptInterface& scriptInterface, JS::MutableHandleValue ret); 136 void ClearMucMessages(); 136 137 void SendMUCMessage(const std::string& message); 137 138 protected: 138 139 void PushGuiMessage(XmppClient::GUIMessage message); 139 140 void CreateSimpleMessage(const std::string& type, const std::string& text, const std::string& level = "standard", const std::string& data = ""); 140 141