本文整理汇总了Java中org.jivesoftware.smackx.ServiceDiscoveryManager.discoverItems方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceDiscoveryManager.discoverItems方法的具体用法?Java ServiceDiscoveryManager.discoverItems怎么用?Java ServiceDiscoveryManager.discoverItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smackx.ServiceDiscoveryManager
的用法示例。
在下文中一共展示了ServiceDiscoveryManager.discoverItems方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getServiceNames
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* 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;
}
示例2: getServiceNames
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* 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;
}
示例3: initProxies
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
private void initProxies() {
proxies = new ArrayList<String>();
ServiceDiscoveryManager manager = ServiceDiscoveryManager
.getInstanceFor(connection);
try {
DiscoverItems discoItems = manager.discoverItems(connection.getServiceName());
Iterator<DiscoverItems.Item> it = discoItems.getItems();
while (it.hasNext()) {
DiscoverItems.Item item = it.next();
String proxy = checkIsProxy(manager, item);
if (proxy != null) {
proxies.add(proxy);
}
}
}
catch (XMPPException e) {
return;
}
if (proxies.size() > 0) {
initStreamHosts();
}
}
开发者ID:phoenixNirvana,项目名称:NewCommunication-Android,代码行数:23,代码来源:Socks5TransferNegotiatorManager.java
示例4: getConferenceServices
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
public Collection<String> getConferenceServices(String server) throws Exception {
List<String> answer = new ArrayList<String>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
DiscoverItems items = discoManager.discoverItems(server);
for (Iterator<Item> it = items.getItems(); it.hasNext();) {
Item item = it.next();
if (item.getEntityID().startsWith("conference") || item.getEntityID().startsWith("private")) {
answer.add(item.getEntityID());
}
else {
try {
DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
if (info.containsFeature("http://jabber.org/protocol/muc")) {
answer.add(item.getEntityID());
}
}
catch (XMPPException e) {
// Nothing to do
}
}
}
return answer;
}
示例5: getConferenceServices
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
private Collection<String> getConferenceServices(String server) throws Exception {
List<String> answer = new ArrayList<String>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
DiscoverItems items = discoManager.discoverItems(server);
for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
DiscoverItems.Item item = (DiscoverItems.Item)it.next();
if (item.getEntityID().startsWith("conference") || item.getEntityID().startsWith("private")) {
answer.add(item.getEntityID());
}
else {
try {
DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
if (info.containsFeature("http://jabber.org/protocol/muc")) {
answer.add(item.getEntityID());
}
}
catch (XMPPException e) {
Log.error("Problem when loading conference service.", e);
}
}
}
return answer;
}
示例6: displayRoomInformation
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
public void displayRoomInformation(final String roomJID) {
SwingWorker worker = new SwingWorker() {
RoomInfo roomInfo = null;
DiscoverItems items = null;
public Object construct() {
try {
roomInfo = MultiUserChat.getRoomInfo(SparkManager.getConnection(), roomJID);
ServiceDiscoveryManager manager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
items = manager.discoverItems(roomJID);
}
catch (XMPPException e) {
Log.error(e);
}
return "ok";
}
public void finished() {
setupRoomInformationUI(roomJID, roomInfo, items);
}
};
worker.start();
}
示例7: isSoftPhonePluginInstalled
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Does a service discovery on the server to see if a SIPpark Manager is
* enabled.
*
* @param con the XMPPConnection to use.
* @return true if SIPpark Manager is available.
*/
public static boolean isSoftPhonePluginInstalled(XMPPConnection con) {
if (!con.isConnected()) {
return false;
}
ServiceDiscoveryManager disco = ServiceDiscoveryManager
.getInstanceFor(con);
try {
DiscoverItems items = disco.discoverItems(con.getServiceName());
Iterator<DiscoverItems.Item> iter = items.getItems();
while (iter.hasNext()) {
DiscoverItems.Item item = iter.next();
if ("SIP Controller".equals(item.getName())) {
Log.debug("SIP Controller Found");
return true;
}
}
}
catch (XMPPException e) {
Log.error("isSparkPluginInstalled", e);
}
return false;
}
示例8: getHostedRooms
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Returns a collection of HostedRooms where each HostedRoom has the XMPP address of the room
* and the room's name. Once discovered the rooms hosted by a chat service it is possible to
* discover more detailed room information or join the room.
*
* @param connection the XMPP connection to use for discovering hosted rooms by the MUC service.
* @param serviceName the service that is hosting the rooms to discover.
* @return a collection of HostedRooms.
* @throws XMPPException if an error occured while trying to discover the information.
*/
public static Collection<HostedRoom> getHostedRooms(Connection connection, String serviceName)
throws XMPPException {
List<HostedRoom> answer = new ArrayList<HostedRoom>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
DiscoverItems items = discoManager.discoverItems(serviceName);
for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
answer.add(new HostedRoom(it.next()));
}
return answer;
}
示例9: getWorkgroupNames
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
public static Collection getWorkgroupNames() {
final List workgroupNames = new ArrayList();
ChatManager chatManager = ChatManager.getInstance();
ConnectionSettings connectionSettings = chatManager.getChatSettingsManager().getSettings();
if (connectionSettings == null) {
return workgroupNames;
}
String host = connectionSettings.getServerDomain();
XMPPConnection con = chatManager.getGlobalConnection();
if (con == null) {
return workgroupNames;
}
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con);
DiscoverItems result = null;
try {
result = discoManager.discoverItems("workgroup." + host);
}
catch (XMPPException e) {
return workgroupNames;
}
Iterator iter = result.getItems();
while (iter.hasNext()) {
DiscoverItems.Item item = (DiscoverItems.Item)iter.next();
String workgroupName = item.getName();
workgroupNames.add(workgroupName);
}
return workgroupNames;
}
示例10: serviceAvailable
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Check if the server support STUN Service.
*
* @param xmppConnection
* @return
*/
public static boolean serviceAvailable(Connection connection) {
if (!connection.isConnected()) {
return false;
}
LOGGER.debug("Service listing");
ServiceDiscoveryManager disco = ServiceDiscoveryManager
.getInstanceFor(connection);
try {
DiscoverItems items = disco.discoverItems(connection.getServiceName());
Iterator<DiscoverItems.Item> iter = items.getItems();
while (iter.hasNext()) {
DiscoverItems.Item item = iter.next();
DiscoverInfo info = disco.discoverInfo(item.getEntityID());
Iterator<DiscoverInfo.Identity> iter2 = info.getIdentities();
while (iter2.hasNext()) {
DiscoverInfo.Identity identity = iter2.next();
if (identity.getCategory().equals("proxy") && identity.getType().equals("stun"))
if (info.containsFeature(NAMESPACE))
return true;
}
LOGGER.debug(item.getName()+"-"+info.getType());
}
}
catch (XMPPException e) {
e.printStackTrace();
}
return false;
}
示例11: determineProxies
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Returns a list of JIDs of SOCKS5 proxies by querying the XMPP server. The SOCKS5 proxies are
* in the same order as returned by the XMPP server.
*
* @return list of JIDs of SOCKS5 proxies
* @throws XMPPException if there was an error querying the XMPP server for SOCKS5 proxies
*/
private List<String> determineProxies() throws XMPPException {
ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(this.connection);
List<String> proxies = new ArrayList<String>();
// get all items form XMPP server
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;
}
示例12: determineProxies
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Returns a list of JIDs of SOCKS5 proxies by querying the XMPP server. The
* SOCKS5 proxies are in the same order as returned by the XMPP server.
*
* @return list of JIDs of SOCKS5 proxies
* @throws XMPPException
* if there was an error querying the XMPP server for SOCKS5
* proxies
*/
private List<String> determineProxies() throws XMPPException {
ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager
.getInstanceFor(this.connection);
List<String> proxies = new ArrayList<String>();
// get all items form XMPP server
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;
}
示例13: retrieveAvailableSpaces
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Requests the spaces which are available for the user.
* @return List<Space> A List of all available spaces, with each having their name, id and domain set.
* @throws SpaceManagementException Thrown when there's an error response from the server.
*/
private List<Space> retrieveAvailableSpaces() throws SpaceManagementException{
if (getMode() == Mode.OFFLINE || connectionHandler.getNetworkInformation().getSpacesServiceJID() == null){
return null;
}
List<Space> spacesList = new ArrayList<Space>();
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
DiscoverItems itemsInfo;
try {
itemsInfo = discoveryManager.discoverItems(connectionHandler.getNetworkInformation().getSpacesServiceJID());
} catch (XMPPException e) {
throw new SpaceManagementException("Server didn't respond.", Type.OTHER, e);
}
Element element = parsePacketToElement(itemsInfo);
if ("result".equalsIgnoreCase(element.getAttributeValue("type"))){
List<Element> items = getChildren(element, "item");
if (items != null){
for (Element item:items){
String domain = item.getAttributeValue("jid").replace(SERVICE_PREFIX, "");
String[] node = item.getAttributeValue("node").split("#");
Space.Type type;
if (node.length>=2){
type = Space.Type.getType(node[0]);
if (type == Space.Type.OTHER){
type = Space.Type.PRIVATE;
}
} else {
type = Space.Type.PRIVATE;
}
spacesList.add(
de.imc.mirror.sdk.android.Space.createSpace(
item.getAttributeValue("name"),
item.getAttributeValue("node"),
domain,
null,
type,
null,
null,
PersistenceType.OFF,
null)
);
}
}
} //TODO error possible??
/*else if (iq.getType().equals("error")){
Log.d("SpaceHandler", iq.error.text.text);
throw new SpaceManagementException("An error response was received.", SpaceManagementException.Type.OTHER);
}*/
return spacesList;
}
示例14: getHostedRooms
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Returns a collection of HostedRooms where each HostedRoom has the XMPP
* address of the room and the room's name. Once discovered the rooms hosted
* by a chat service it is possible to discover more detailed room
* information or join the room.
*
* @param connection
* the XMPP connection to use for discovering hosted rooms by the
* MUC service.
* @param serviceName
* the service that is hosting the rooms to discover.
* @return a collection of HostedRooms.
* @throws XMPPException
* if an error occured while trying to discover the information.
*/
public static Collection<HostedRoom> getHostedRooms(Connection connection,
String serviceName) throws XMPPException {
List<HostedRoom> answer = new ArrayList<HostedRoom>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager
.getInstanceFor(connection);
DiscoverItems items = discoManager.discoverItems(serviceName);
for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
answer.add(new HostedRoom(it.next()));
}
return answer;
}
示例15: discoverCommands
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Discover the commands of an specific JID. The <code>jid</code> is a
* full JID.
*
* @param jid the full JID to retrieve the commands for.
* @return the discovered items.
* @throws XMPPException if the operation failed for some reason.
*/
public DiscoverItems discoverCommands(String jid) throws XMPPException {
ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager
.getInstanceFor(connection);
return serviceDiscoveryManager.discoverItems(jid, discoNode);
}