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

Conversation

tarun018
Copy link
Contributor

No description provided.

Update roster encoding for MIX channel
Update roster parser and serializer

License:
This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.

Test-Information:
Added tests for joining and leaving channels via MIXRegistry, which passes.
Tested on Ubuntu 16.04 LTS.

Change-Id: Idb9683f45734ac58daa58736fe199dc014b9352a
License:
This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.

Test-Information:
Tests added for joining and leaving MIX channels as in XEP-0369, which passes.
Tested on Ubuntu 16.04 LTS.

Change-Id: Ib85d6e866e09db060b9b2da428f074dfbfd26385
@tarun018
Copy link
Contributor Author

tarun018 commented Aug 21, 2017

Client 1

./Swiften/Examples/MIXListAndJoin/MIXListAndJoin another@example.com/some mixtest2 example.com
Connecting...Connected
Request list of channels.
List of rooms at example.com
	1. coven - coven@example.com

Request supported nodes for MIX channel: coven@example.com
Nodes supported by channel coven@example.com
	1. urn:xmpp:mix:nodes:participants
	2. urn:xmpp:mix:nodes:messages
	3. urn:xmpp:mix:nodes:presence
	4. urn:xmpp:mix:nodes:jidmap

Already Joined channels: 
No channels already joined.

Successfully joined channel coven@example.com
[warning] Swiften/MIX/MIXRegistry.cpp:40 joinChannel: Channel already joined: coven@example.com

Participants of channel coven@example.com
	1. 99ba30b1-0d0a-4739-95ad-fc1eb3c12a49#coven@example.com

Lookup of participant in channel coven@example.com
	1. 99ba30b1-0d0a-4739-95ad-fc1eb3c12a49#coven@example.com - another@example.com

[ coven@example.com ] : Hello, I am here! some

Client 2

./Swiften/Examples/MIXListAndJoin/MIXListAndJoin some@example.com/some mixtest example.com
Connecting...Connected
Request list of channels.
List of rooms at example.com
	1. coven - coven@example.com

Request supported nodes for MIX channel: coven@example.com
Nodes supported by channel coven@example.com
	1. urn:xmpp:mix:nodes:participants
	2. urn:xmpp:mix:nodes:messages
	3. urn:xmpp:mix:nodes:presence
	4. urn:xmpp:mix:nodes:jidmap

Already Joined channels: 
No channels already joined.

Successfully joined channel coven@example.com
[warning] Swiften/MIX/MIXRegistry.cpp:40 joinChannel: Channel already joined: coven@example.com

Participants of channel coven@example.com
	1. c0a202ff-adce-4a07-8d90-577b4e986321#coven@example.com
	2. 99ba30b1-0d0a-4739-95ad-fc1eb3c12a49#coven@example.com

Lookup of participant in channel coven@example.com
	1. 99ba30b1-0d0a-4739-95ad-fc1eb3c12a49#coven@example.com - another@example.com
	2. c0a202ff-adce-4a07-8d90-577b4e986321#coven@example.com - some@example.com

This allows different client of same user to connect to server and retrieves already connected channels.

License:
This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.

Test-Information:
Tests added for joining and leaving MIX channels as in XEP-0369, which passes.
Tested on Ubuntu 16.04 LTS.

Change-Id: I31d0b68528ea0653685e6bcbc66e8131cb2c0eb4
@tarun018 tarun018 force-pushed the MIXLimber2 branch 2 times, most recently from 9df1414 to 8e4d121 Compare August 21, 2017 22:36
@tarun018 tarun018 changed the title Retrieve Participant List and real JID lookup of participants Retrieve Participant List, Send Message to Channel and Real JID lookup of participants proxy JID Aug 21, 2017
@tarun018 tarun018 force-pushed the MIXLimber2 branch 4 times, most recently from 51c7c18 to dcfc392 Compare August 22, 2017 10:22
Change-Id: I98bda1d18847cd1fabffde2c0f92fced31d2a5f3
Change-Id: Iab547e141952b29f4c9703035d2a1808927554c4
Change-Id: Ie4a349c6b9ef35f08f367885755446c316f1e20e
…p of participants proxy JID

Adds sending message to channel and server forwarding message to participants and reflecting back message to originator.
Adds JID lookup request by client and corresponding response by MIX Mock Server.
Adds requesting participant list by client and response from mock server.

License:
This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.

Change-Id: I53091a13422598f200134ac08cc3095cd140b792
Copy link
Collaborator

@tfar tfar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some first round feedback.

@@ -67,6 +73,35 @@ class SimpleMIXChannelRegistry {
std::unordered_set<std::string> channels_;
};

class MIXParticipantInformation {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this class used for? From the name it would appear it represents the information corresponding to a single member in a MIX channel. However, then why are both data members optional?

Copy link
Contributor Author

@tarun018 tarun018 Aug 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding MIXParticipantInformation class, the data members are optional to indicate whether the field has been set or not. Instead of using two different maps for roster and proxyJID, I am saving them as one MIXParticipantInformation class. But both roster and proxyJID are set differently, roster is set when client->requestRoster is called and proxyJID is set when channel is successfully joined. This class will also hold nick of user in next PR.

This functionality is equivalent to testing whether proxyJIDMap and rosterMap has proxyJID and roster for corresponding user.

@@ -95,6 +130,20 @@ class Server {
}
stanza->setFrom(session->getRemoteJID());

auto i = participantInformationMap_.find(session->getRemoteJID().toBare());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method handleElementReceived now mixes different parts of a XMPP server. I think at the top level it should only route the stanzas to the appropriate method, handleElementRecievedForMIXChannel and so. These should then probably take a stanza and a session. Inside of them you could have an if, elseif to test for IQ and Message. Probably there should be methods for that for clarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, will update this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've now passed stanza to corresponding handler functions i.e. handleElementRecievedForMIXChannel, handleElementRecievedForAccount and handleElementRecievedForMIXService.

However retrieving / setting of information_ field in handleElementReceived is just either creating a new MIXParticipantInformation object for a new user or retrieving an already stored object for current user. Therefore, it is better to store information_ here, rather than checking participantInformationMap_ has current user JID in every handler function and then retrieving a information_ instance.

@@ -241,6 +386,50 @@ class Server {
return rosterPayload;
}

std::shared_ptr<PubSub> getParticipantsOfChannel(const JID& channelJID) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a traditional getter method. Mind naming it differently, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to getParticipants(channelJID).

}

auto iq = std::dynamic_pointer_cast<IQ>(stanza);
if (!iq) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if (message) … if (!iq) sounds like an if/else if pattern. Could you rewrite it as such, please. That way you can remove the returns and the control flow is more obvious.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@@ -386,7 +396,7 @@ class Server {
return rosterPayload;
}

std::shared_ptr<PubSub> getParticipantsOfChannel(const JID& channelJID) {
std::shared_ptr<PubSub> getParticipants(const JID& channelJID) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this name change?

Copy link
Contributor Author

@tarun018 tarun018 Aug 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating to retrieveChannelParticipants().

@tarun018 tarun018 force-pushed the MIXLimber2 branch 2 times, most recently from 8dd3658 to 2c4a802 Compare August 25, 2017 10:52
@tarun018
Copy link
Contributor Author

Updated based on feedback.

Change-Id: Ie68aba5e6ab3995b8195056c6a1cc20e69edac2e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants