use of org.jivesoftware.smackx.packet.DiscoverInfo in project Smack by igniterealtime.
the class MultiUserChatTest method testPrivateIQ.
/**
* Tests that IQ packets can be sent to/from room occupants. This case will try to discover
* information about other room occupants.
*/
public void testPrivateIQ() {
try {
// User2 joins the new room
MultiUserChat muc2 = new MultiUserChat(getConnection(1), room);
muc2.join("testbot2");
// User2 discovers information about User1
DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(getConnection(1)).discoverInfo(room + "/testbot", null);
assertNotNull("No info was discovered from room occupant", info);
assertEquals("Wrong IQ type", IQ.Type.result, info.getType());
assertEquals("Wrong IQ sender", room + "/testbot", info.getFrom());
// User2 leaves the room
muc2.leave();
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.jivesoftware.smackx.packet.DiscoverInfo in project Smack by igniterealtime.
the class EntityUseCases method testDiscoverPubsubInfo.
public void testDiscoverPubsubInfo() throws Exception {
DiscoverInfo supportedFeatures = getManager().getSupportedFeatures();
assertNotNull(supportedFeatures);
}
use of org.jivesoftware.smackx.packet.DiscoverInfo in project Smack by igniterealtime.
the class EntityUseCases method testDiscoverNodeInfo.
public void testDiscoverNodeInfo() throws Exception {
LeafNode myNode = getManager().createNode("DiscoNode" + System.currentTimeMillis());
DiscoverInfo info = myNode.discoverInfo();
assertTrue(info.getIdentities().hasNext());
Identity ident = info.getIdentities().next();
assertEquals("leaf", ident.getType());
}
use of org.jivesoftware.smackx.packet.DiscoverInfo in project ecf by eclipse.
the class MultiUserChat method getServiceNames.
/**
* Returns a collection with the XMPP addresses of the Multi-User Chat services.
*
* @param connection the XMPP connection to use for discovering Multi-User Chat services.
* @return a collection with the XMPP addresses of the Multi-User Chat services.
* @throws XMPPException if an error occured while trying to discover MUC services.
*/
public static Collection<String> getServiceNames(Connection connection) throws XMPPException {
final List<String> answer = new ArrayList<String>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
DiscoverItems items = discoManager.discoverItems(connection.getServiceName());
for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext(); ) {
DiscoverItems.Item item = it.next();
try {
DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
if (info.containsFeature("http://jabber.org/protocol/muc")) {
answer.add(item.getEntityID());
}
} catch (XMPPException e) {
// Trouble finding info in some cases. This is a workaround for
// discovering info on remote servers.
}
}
return answer;
}
use of org.jivesoftware.smackx.packet.DiscoverInfo in project ecf by eclipse.
the class Socks5BytestreamManager method supportsSocks5.
/**
* Returns <code>true</code> if the given target JID supports feature SOCKS5 Bytestream.
*
* @param targetJID the target JID
* @return <code>true</code> if the given target JID supports feature SOCKS5 Bytestream
* otherwise <code>false</code>
* @throws XMPPException if there was an error querying target for supported features
*/
private boolean supportsSocks5(String targetJID) throws XMPPException {
ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(this.connection);
DiscoverInfo discoverInfo = serviceDiscoveryManager.discoverInfo(targetJID);
return discoverInfo.containsFeature(NAMESPACE);
}
Aggregations