Join room just once
This commit is contained in:
parent
b6ca47285f
commit
d0699848cf
2 changed files with 26 additions and 0 deletions
|
@ -132,6 +132,8 @@ class UserTest : public CPPUNIT_NS :: TestFixture, public BasicTest {
|
|||
}
|
||||
|
||||
void handlePresenceJoinRoom() {
|
||||
User *user = userManager->getUser("user@localhost");
|
||||
|
||||
Swift::Presence::ref response = Swift::Presence::create();
|
||||
response->setTo("#room@localhost/hanzz");
|
||||
response->setFrom("user@localhost/resource");
|
||||
|
@ -149,6 +151,25 @@ class UserTest : public CPPUNIT_NS :: TestFixture, public BasicTest {
|
|||
CPPUNIT_ASSERT_EQUAL(std::string("#room"), room);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("hanzz"), roomNickname);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("password"), roomPassword);
|
||||
|
||||
room = "";
|
||||
roomNickname = "";
|
||||
roomPassword = "";
|
||||
|
||||
// simulate that backend joined the room
|
||||
TestingConversation *conv = new TestingConversation(user->getConversationManager(), "#room", true);
|
||||
|
||||
received.clear();
|
||||
injectPresence(response);
|
||||
loop->processEvents();
|
||||
|
||||
// no presence received in server mode, just disco#info
|
||||
CPPUNIT_ASSERT_EQUAL(1, (int) received.size());
|
||||
CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::DiscoInfo>());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(""), room);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(""), roomNickname);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(""), roomPassword);
|
||||
}
|
||||
|
||||
void handlePresenceLeaveRoom() {
|
||||
|
|
|
@ -226,6 +226,11 @@ void User::handlePresence(Swift::Presence::ref presence) {
|
|||
onReadyToConnect();
|
||||
}
|
||||
std::string room = Buddy::JIDToLegacyName(presence->getTo());
|
||||
if (m_conversationManager->getConversation(room) != NULL) {
|
||||
LOG4CXX_INFO(logger, m_jid.toString() << ": User has already tried to join room " << room << " as " << presence->getTo().getResource());
|
||||
return;
|
||||
}
|
||||
|
||||
LOG4CXX_INFO(logger, m_jid.toString() << ": Going to join room " << room << " as " << presence->getTo().getResource());
|
||||
std::string password = "";
|
||||
if (presence->getPayload<Swift::MUCPayload>() != NULL) {
|
||||
|
|
Loading…
Add table
Reference in a new issue