Package org.jivesoftware.smackx.packet.DiscoverItems

Examples of org.jivesoftware.smackx.packet.DiscoverItems.Item


        DiscoverItems discoverItems = serviceDiscoveryManager.discoverItems(this.connection.getServiceName());
        Iterator<Item> itemIterator = discoverItems.getItems();

        // query all items if they are SOCKS5 proxies
        while (itemIterator.hasNext()) {
            Item item = itemIterator.next();

            // skip blacklisted servers
            if (this.proxyBlacklist.contains(item.getEntityID())) {
                continue;
            }

            try {
                DiscoverInfo proxyInfo;
                proxyInfo = serviceDiscoveryManager.discoverInfo(item.getEntityID());
                Iterator<Identity> identities = proxyInfo.getIdentities();

                // item must have category "proxy" and type "bytestream"
                while (identities.hasNext()) {
                    Identity identity = identities.next();

                    if ("proxy".equalsIgnoreCase(identity.getCategory())
                                    && "bytestreams".equalsIgnoreCase(identity.getType())) {
                        proxies.add(item.getEntityID());
                        break;
                    }

                    /*
                     * server is not a SOCKS5 proxy, blacklist server to skip next time a Socks5
                     * bytestream should be established
                     */
                    this.proxyBlacklist.add(item.getEntityID());

                }
            }
            catch (XMPPException e) {
                // blacklist errornous server
                this.proxyBlacklist.add(item.getEntityID());
            }
        }

        return proxies;
    }
View Full Code Here

TOP

Related Classes of org.jivesoftware.smackx.packet.DiscoverItems.Item

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.