-
Notifications
You must be signed in to change notification settings - Fork 64
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
base: master
Are you sure you want to change the base?
Conversation
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
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
9df1414
to
8e4d121
Compare
51c7c18
to
dcfc392
Compare
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
There was a problem hiding this 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.
Limber/MIXMockServer.cpp
Outdated
@@ -67,6 +73,35 @@ class SimpleMIXChannelRegistry { | |||
std::unordered_set<std::string> channels_; | |||
}; | |||
|
|||
class MIXParticipantInformation { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Limber/MIXMockServer.cpp
Outdated
@@ -95,6 +130,20 @@ class Server { | |||
} | |||
stanza->setFrom(session->getRemoteJID()); | |||
|
|||
auto i = participantInformationMap_.find(session->getRemoteJID().toBare()); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, will update this.
There was a problem hiding this comment.
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.
Limber/MIXMockServer.cpp
Outdated
@@ -241,6 +386,50 @@ class Server { | |||
return rosterPayload; | |||
} | |||
|
|||
std::shared_ptr<PubSub> getParticipantsOfChannel(const JID& channelJID) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to getParticipants(channelJID).
Limber/MIXMockServer.cpp
Outdated
} | ||
|
||
auto iq = std::dynamic_pointer_cast<IQ>(stanza); | ||
if (!iq) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
Limber/MIXMockServer.cpp
Outdated
@@ -386,7 +396,7 @@ class Server { | |||
return rosterPayload; | |||
} | |||
|
|||
std::shared_ptr<PubSub> getParticipantsOfChannel(const JID& channelJID) { | |||
std::shared_ptr<PubSub> getParticipants(const JID& channelJID) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this name change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating to retrieveChannelParticipants()
.
8dd3658
to
2c4a802
Compare
Updated based on feedback. |
No description provided.