本文整理汇总了Java中org.jivesoftware.smackx.ServiceDiscoveryManager.getInstanceFor方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceDiscoveryManager.getInstanceFor方法的具体用法?Java ServiceDiscoveryManager.getInstanceFor怎么用?Java ServiceDiscoveryManager.getInstanceFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smackx.ServiceDiscoveryManager
的用法示例。
在下文中一共展示了ServiceDiscoveryManager.getInstanceFor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: publishCommands
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Publish the commands to an specific JID.
*
* @param jid the full JID to publish the commands to.
* @throws XMPPException if the operation failed for some reason.
*/
public void publishCommands(String jid) throws XMPPException {
ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager
.getInstanceFor(connection);
// Collects the commands to publish as items
DiscoverItems discoverItems = new DiscoverItems();
Collection<AdHocCommandInfo> xCommandsList = getRegisteredCommands();
for (AdHocCommandInfo info : xCommandsList) {
DiscoverItems.Item item = new DiscoverItems.Item(info.getOwnerJID());
item.setName(info.getName());
item.setNode(info.getNode());
discoverItems.addItem(item);
}
serviceDiscoveryManager.publishItems(jid, discoNode, discoverItems);
}
示例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: isServiceEnabled
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Checks to see if all file transfer related services are enabled on the
* connection.
*
* @param connection The connection to check
* @return True if all related services are enabled, false if they are not.
*/
public static boolean isServiceEnabled(final Connection connection) {
ServiceDiscoveryManager manager = ServiceDiscoveryManager
.getInstanceFor(connection);
List<String> namespaces = new ArrayList<String>();
namespaces.addAll(Arrays.asList(NAMESPACE));
namespaces.add(InBandBytestreamManager.NAMESPACE);
if (!IBB_ONLY) {
namespaces.add(Socks5BytestreamManager.NAMESPACE);
}
for (String namespace : namespaces) {
if (!manager.includesFeature(namespace)) {
return false;
}
}
return true;
}
示例4: setServiceEnabled
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Enable the Jabber services related to file transfer on the particular
* connection.
*
* @param connection The connection on which to enable or disable the services.
* @param isEnabled True to enable, false to disable.
*/
public static void setServiceEnabled(final Connection connection,
final boolean isEnabled) {
ServiceDiscoveryManager manager = ServiceDiscoveryManager
.getInstanceFor(connection);
List<String> namespaces = new ArrayList<String>();
namespaces.addAll(Arrays.asList(NAMESPACE));
namespaces.add(InBandBytestreamManager.NAMESPACE);
if (!IBB_ONLY) {
namespaces.add(Socks5BytestreamManager.NAMESPACE);
}
for (String namespace : namespaces) {
if (isEnabled) {
if (!manager.includesFeature(namespace)) {
manager.addFeature(namespace);
}
} else {
manager.removeFeature(namespace);
}
}
}
示例5: publishCommands
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Publish the commands to an specific JID.
*
* @param jid
* the full JID to publish the commands to.
* @throws XMPPException
* if the operation failed for some reason.
*/
public void publishCommands(String jid) throws XMPPException {
ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager
.getInstanceFor(connection);
// Collects the commands to publish as items
DiscoverItems discoverItems = new DiscoverItems();
Collection<AdHocCommandInfo> xCommandsList = getRegisteredCommands();
for (AdHocCommandInfo info : xCommandsList) {
DiscoverItems.Item item = new DiscoverItems.Item(info.getOwnerJID());
item.setName(info.getName());
item.setNode(info.getNode());
discoverItems.addItem(item);
}
serviceDiscoveryManager.publishItems(jid, discoNode, discoverItems);
}
示例6: 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;
}
示例7: setServiceEnabled
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Enable the Jabber services related to file transfer on the particular
* connection.
*
* @param connection
* The connection on which to enable or disable the services.
* @param isEnabled
* True to enable, false to disable.
*/
public static void setServiceEnabled(final Connection connection,
final boolean isEnabled) {
ServiceDiscoveryManager manager = ServiceDiscoveryManager
.getInstanceFor(connection);
List<String> namespaces = new ArrayList<String>();
namespaces.addAll(Arrays.asList(NAMESPACE));
namespaces.add(InBandBytestreamManager.NAMESPACE);
if (!IBB_ONLY) {
namespaces.add(Socks5BytestreamManager.NAMESPACE);
}
for (String namespace : namespaces) {
if (isEnabled) {
if (!manager.includesFeature(namespace)) {
manager.addFeature(namespace);
}
} else {
manager.removeFeature(namespace);
}
}
}
示例8: isServiceEnabled
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Checks to see if all file transfer related services are enabled on the
* connection.
*
* @param connection
* The connection to check
* @return True if all related services are enabled, false if they are not.
*/
public static boolean isServiceEnabled(final Connection connection) {
ServiceDiscoveryManager manager = ServiceDiscoveryManager
.getInstanceFor(connection);
List<String> namespaces = new ArrayList<String>();
namespaces.addAll(Arrays.asList(NAMESPACE));
namespaces.add(InBandBytestreamManager.NAMESPACE);
if (!IBB_ONLY) {
namespaces.add(Socks5BytestreamManager.NAMESPACE);
}
for (String namespace : namespaces) {
if (!manager.includesFeature(namespace)) {
return false;
}
}
return true;
}
示例9: getSpaceConfiguration
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Retrieves the configuration of the space.
* @param space The space to get the configuration for.
* @return The parsed result or, if there was an error, null.
* @throws SpaceManagementException Thrown when no response was received from the server.
*/
private SpaceConfiguration getSpaceConfiguration(Space space) throws SpaceManagementException{
if (space == null){
throw new IllegalArgumentException("The given space must not be null");
}
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
DiscoverInfo info;
try {
info = discoveryManager.discoverInfo(SERVICE_PREFIX + space.getDomain(), space.getId());
} catch (XMPPException e) {
if (e.getXMPPError().getCode() == 404) {
return null;
} else {
throw new SpaceManagementException("The Server didn't respond.", Type.OTHER, e);
}
}
Element config = parsePacketToElement(info);
return parseSpaceConfiguration(config);
}
示例10: 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;
}
示例11: checkIfPrivacyIsSupported
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
private boolean checkIfPrivacyIsSupported(XMPPConnection conn) {
ServiceDiscoveryManager servDisc = ServiceDiscoveryManager.getInstanceFor(conn);
DiscoverInfo info = null;
//Re: SPARK-1483 comment the loop as it causes Out Of Memory (infinite loop) if info not found
//If really necessary to try more times, a Thread Pool may be used: java ScheduledThreadPoolExecutor for example
//while (info == null){
try {
String xmppHost = DNSUtil.resolveXMPPDomain(conn.getServiceName()).getHost();
info = servDisc.discoverInfo(xmppHost);
} catch (XMPPException e) {
// We could not query the server
}
//}
if (info != null) {
for (Iterator<Feature> i = info.getFeatures(); i.hasNext();) {
String s = i.next().getVar();
if (s.contains("jabber:iq:privacy")) {
return true;
}
}
}
return false;
}
示例12: isRegistered
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Checks if the user is registered with a gateway.
*
* @param con the XMPPConnection.
* @param transport the transport.
* @return true if the user is registered with the transport.
*/
public static boolean isRegistered(XMPPConnection con, Transport transport) {
if (!con.isConnected()) {
return false;
}
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(con);
try {
DiscoverInfo info = discoveryManager.discoverInfo(transport.getServiceName());
return info.containsFeature("jabber:iq:registered");
}
catch (XMPPException e) {
Log.error(e);
}
return false;
}
示例13: setUp
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
SmackConfiguration.setAutoEnableEntityCaps(true);
con0 = getConnection(0);
con1 = getConnection(1);
ecm0 = EntityCapsManager.getInstanceFor(getConnection(0));
ecm1 = EntityCapsManager.getInstanceFor(getConnection(1));
sdm0 = ServiceDiscoveryManager.getInstanceFor(con0);
sdm1 = ServiceDiscoveryManager.getInstanceFor(con1);
letsAllBeFriends();
}
示例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: isEmailAvailable
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* The workgroup service may be configured to send email. This queries the Workgroup Service
* to see if the email service has been configured and is available.
*
* @return true if the email service is available, otherwise return false.
*/
public boolean isEmailAvailable() {
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
try {
String workgroupService = StringUtils.parseServer(workgroupJID);
DiscoverInfo infoResult = discoManager.discoverInfo(workgroupService);
return infoResult.containsFeature("jive:email:provider");
}
catch (XMPPException e) {
return false;
}
}