Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve Participant List, Send Message to Channel and Real JID lookup of participants proxy JID #89

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update based on feedback
Change-Id: Iab547e141952b29f4c9703035d2a1808927554c4
  • Loading branch information
tarun018 committed Aug 23, 2017
commit 50cf8d06b3ad081bc6213335b0f035fac45d645d
14 changes: 6 additions & 8 deletions Swiften/Examples/MIXListAndJoin/MIXListAndJoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ static void handleChannelLeft(const JID& jid) {
std::cout << "Successfully left channel " << jid << std::endl;
}

static void handleRosterPopulated() {
auto xmppRoster = client->getRoster();
static void handleSyncSuccess() {
auto channels = mixRegistry_->getChannels();
int channelCount = 0;
std::cout << "Already Joined channels: " << std::endl;
for (auto item : xmppRoster->getItems()) {
for (auto channel : channels) {
channelCount++;
std::cout << "\t" << channelCount << ". " << item.getName() << " - " << item.getJID() << std::endl;
std::cout << "\t" << channelCount << ". " << channel->getChannelJID() << std::endl;
}
if (channelCount == 0) {
std::cout << "No channels already joined." << std::endl;
Expand Down Expand Up @@ -106,13 +106,11 @@ static void handleChannelNodesSupported(std::shared_ptr<DiscoItems> items, Error

// Initialize MIX Registry and send join request.
mixRegistry_ = client->getMIXRegistry();
mixRegistry_->onSyncSuccess.connect(&handleSyncSuccess);
mixRegistry_->onChannelJoined.connect(&handleChannelJoined);
mixRegistry_->onChannelJoinFailed.connect(&handleChannelJoinFailed);
mixRegistry_->onChannelLeft.connect(&handleChannelLeft);

auto xmppRoster = client->getRoster();
xmppRoster->onInitialRosterPopulated.connect(&handleRosterPopulated);
client->requestRoster(true);
client->requestRoster();
}

static void handleChannelItemsResponse(std::shared_ptr<DiscoItems> items, ErrorPayload::ref error) {
Expand Down
3 changes: 2 additions & 1 deletion Swiften/MIX/MIXRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Swift {

MIXRegistry::MIXRegistry(const JID& ownJID, IQRouter* iqRouter, XMPPRoster* xmppRoster) : ownJID_(ownJID), iqRouter_(iqRouter), xmppRoster_(xmppRoster) {
xmppRoster_->onInitialRosterPopulated.connect(boost::bind(&MIXRegistry::syncRegistryWithRoster, this));
scopedConnection_ = xmppRoster_->onInitialRosterPopulated.connect(boost::bind(&MIXRegistry::syncRegistryWithRoster, this));
}

MIXRegistry::~MIXRegistry() {
Expand All @@ -31,6 +31,7 @@ void MIXRegistry::syncRegistryWithRoster() {
}
xmppRoster_->onJIDAdded.connect(boost::bind(&MIXRegistry::handleJIDAdded, this, _1));
xmppRoster_->onJIDRemoved.connect(boost::bind(&MIXRegistry::handleJIDRemoved, this, _1));
onSyncSuccess();
}

void MIXRegistry::joinChannel(const JID& channelJID, const std::unordered_set<std::string>& nodes) {
Expand Down
3 changes: 3 additions & 0 deletions Swiften/MIX/MIXRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <unordered_set>

#include <boost/signals2.hpp>
#include <boost/signals2/connection.hpp>

#include <Swiften/Base/API.h>
#include <Swiften/Elements/ErrorPayload.h>
Expand Down Expand Up @@ -70,11 +71,13 @@ namespace Swift {
boost::signals2::signal<void (const JID& /* joinedChannel */)> onChannelJoined;
boost::signals2::signal<void (ErrorPayload::ref /* joinResponse */)> onChannelJoinFailed;
boost::signals2::signal<void (const JID& /* leavedChannel */)> onChannelLeft;
boost::signals2::signal<void ()> onSyncSuccess;

private:
JID ownJID_;
IQRouter* iqRouter_;
XMPPRoster* xmppRoster_;
MIXInstanceMap entries_;
boost::signals2::scoped_connection scopedConnection_;
};
}