本文整理汇总了Java中org.jivesoftware.smackx.disco.ServiceDiscoveryManager.getInstanceFor方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceDiscoveryManager.getInstanceFor方法的具体用法?Java ServiceDiscoveryManager.getInstanceFor怎么用?Java ServiceDiscoveryManager.getInstanceFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smackx.disco.ServiceDiscoveryManager
的用法示例。
在下文中一共展示了ServiceDiscoveryManager.getInstanceFor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doInBackground
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
protected EntityViewActivity doInBackground(EntityViewActivity... activity) {
// Get the XMMPConnection from the manager
AbstractXMPPConnection conn = XMPPConnectionManager.getConnection();
// Obtain the ServiceDiscoveryManager associated with my XMPP connection
this.discoManager = ServiceDiscoveryManager.getInstanceFor(conn);
Entity entity = activity[0].myEntity;
try {
if ( entity.getNode() != null && entity.getNode() != "" ) {
activity[0].myLeafInfo = discoManager.discoverInfo( entity.getJid() , entity.getNode() );
} else {
activity[0].myLeafInfo = discoManager.discoverInfo( entity.getJid() );
}
Log.d(LOGTAG, "Got Info!");
} catch (Exception ex) {
Log.w(LOGTAG, "XMPP Disco error " + ex);
errorMessage = ex.toString() ;
}
return activity[0];
}
示例2: setServiceEnabled
import org.jivesoftware.smackx.disco.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.
*/
private static void setServiceEnabled(final XMPPConnection connection,
final boolean isEnabled) {
ServiceDiscoveryManager manager = ServiceDiscoveryManager
.getInstanceFor(connection);
List<String> namespaces = new ArrayList<String>();
namespaces.addAll(Arrays.asList(NAMESPACE));
namespaces.add(DataPacketExtension.NAMESPACE);
if (!IBB_ONLY) {
namespaces.add(Bytestream.NAMESPACE);
}
for (String namespace : namespaces) {
if (isEnabled) {
manager.addFeature(namespace);
} else {
manager.removeFeature(namespace);
}
}
}
示例3: isServiceEnabled
import org.jivesoftware.smackx.disco.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 XMPPConnection connection) {
ServiceDiscoveryManager manager = ServiceDiscoveryManager
.getInstanceFor(connection);
List<String> namespaces = new ArrayList<String>();
namespaces.addAll(Arrays.asList(NAMESPACE));
namespaces.add(DataPacketExtension.NAMESPACE);
if (!IBB_ONLY) {
namespaces.add(Bytestream.NAMESPACE);
}
for (String namespace : namespaces) {
if (!manager.includesFeature(namespace)) {
return false;
}
}
return true;
}
示例4: VersionManager
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
private VersionManager(final XMPPConnection connection) {
super(connection);
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
sdm.addFeature(Version.NAMESPACE);
connection.registerIQRequestHandler(new AbstractIqRequestHandler(Version.ELEMENT, Version.NAMESPACE, IQ.Type.get,
Mode.async) {
@Override
public IQ handleIQRequest(IQ iqRequest) {
if (ourVersion == null) {
return IQ.createErrorResponse(iqRequest, new XMPPError(Condition.not_acceptable));
}
return Version.createResultFor(iqRequest, ourVersion);
}
});
}
示例5: setup
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Initialize fields used in the tests.
*/
@Before
public void setup() {
// mock connection
connection = mock(XMPPConnection.class);
// create service discovery manager for mocked connection
ServiceDiscoveryManager.getInstanceFor(connection);
// initialize Socks5ByteStreamManager to get the InitiationListener
byteStreamManager = Socks5BytestreamManager.getBytestreamManager(connection);
// get the InitiationListener from Socks5ByteStreamManager
initiationListener = Whitebox.getInternalState(byteStreamManager, InitiationListener.class);
// create a SOCKS5 Bytestream initiation packet
initBytestream = Socks5PacketUtils.createBytestreamInitiation(initiatorJID, targetJID,
sessionID);
initBytestream.addStreamHost(proxyJID, proxyAddress, 7777);
}
示例6: discoverItemsByFeature
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
private List<String> discoverItemsByFeature(XmppURI uri, List<String> features) throws XMPPException, IOException, SmackException {
// discover items
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(this.connectionManager.getConnection());
DiscoverItems discoverItems = discoveryManager.discoverItems(uri.getDomain());
List<DiscoverItems.Item> items = discoverItems.getItems();
List<String> result = new ArrayList<>();
// discover infos per item and check if specified feature set is supported
for (DiscoverItems.Item item : items) {
DiscoverInfo discoverInfo = discoveryManager.discoverInfo(item.getEntityID());
boolean conatinsAllFeatures = true;
for (String feature : features) {
if (!discoverInfo.containsFeature(feature)) {
conatinsAllFeatures = false;
break;
}
}
if (conatinsAllFeatures) {
result.add(item.getEntityID());
} else if (logger.isDebugEnabled()) {
logger.debug("Entity {} does not support the specified features.", item.getEntityID());
}
}
return result;
}
示例7: initServiceDiscovery
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
private void initServiceDiscovery() {
debug(TAG, "init service discovery");
// register connection features
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(mConnection);
if (!sdm.includesFeature(DISCO_FEATURE))
sdm.addFeature(DISCO_FEATURE);
if (!sdm.includesFeature(DeliveryReceipt.NAMESPACE))
sdm.addFeature(DeliveryReceipt.NAMESPACE);
sdm.addFeature(HttpFileUploadManager.NAMESPACE);
DeliveryReceiptManager.getInstanceFor(mConnection).dontAutoAddDeliveryReceiptRequests();
DeliveryReceiptManager.getInstanceFor(mConnection).setAutoReceiptMode(DeliveryReceiptManager.AutoReceiptMode.disabled);
}
示例8: perform
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
String entID = sampler.getPropertyAsString(ENTITY_ID);
res.setSamplerData("Entity ID: " + entID);
ServiceDiscoveryManager discoMgr = ServiceDiscoveryManager.getInstanceFor(sampler.getXMPPConnection());
IQ info;
if (Type.valueOf(sampler.getPropertyAsString(TYPE)) == Type.info) {
info = discoMgr.discoverInfo(entID);
} else {
info = discoMgr.discoverItems(entID);
}
res.setResponseData(info.toXML().toString().getBytes());
return res;
}
示例9: DisplayedManager
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
private DisplayedManager(XMPPConnection connection) {
super(connection);
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
sdm.addFeature(Displayed.NAMESPACE);
connection.addAsyncStanzaListener(packet -> {
Displayed receipt = Displayed.from((Message) packet);
for (ReceiptReceivedListener listener : receiptReceivedListeners) {
listener.onReceiptReceived(packet.getFrom(), packet.getTo(), receipt.getId(), packet);
}
}, MESSAGES_WITH_DISPLAYED);
}
示例10: ReceivedManager
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
private ReceivedManager(XMPPConnection connection) {
super(connection);
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
sdm.addFeature(Received.NAMESPACE);
connection.addAsyncStanzaListener(packet -> {
Received receipt = Received.from((Message) packet);
for (ReceiptReceivedListener listener : receiptReceivedListeners) {
listener.onReceiptReceived(packet.getFrom(), packet.getTo(), receipt.getId(), packet);
}
}, MESSAGES_WITH_RECEIVED);
}
示例11: DeliveredReceiptManager
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
private DeliveredReceiptManager(XMPPConnection connection) {
super(connection);
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
sdm.addFeature(DeliveredReceipt.NAMESPACE);
connection.addAsyncStanzaListener(packet -> {
DeliveredReceipt receipt = DeliveredReceipt.from((Message) packet);
for (ReceiptReceivedListener listener : receiptReceivedListeners) {
listener.onReceiptReceived(packet.getFrom(), packet.getTo(), receipt.getId(), packet);
}
}, MESSAGES_WITH_DELIVERED_RECEIPT);
}
示例12: ReadReceiptManager
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
private ReadReceiptManager(XMPPConnection connection) {
super(connection);
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
sdm.addFeature(ReadReceipt.NAMESPACE);
connection.addAsyncStanzaListener(packet -> {
ReadReceipt receipt = ReadReceipt.from((Message) packet);
for (ReceiptReceivedListener listener : receiptReceivedListeners) {
listener.onReceiptReceived(packet.getFrom(), packet.getTo(), receipt.getId(), packet);
}
}, MESSAGES_WITH_READ_RECEIPT);
}
示例13: setUp
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
// Uncomment this to enable debug output
// SmackConfiguration.DEBUG = true;
connection = new DummyConnection();
connection.connect();
connection.login();
ServiceDiscoveryManager.getInstanceFor(connection);
}
示例14: shouldDisableService
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* The SOCKS5 Bytestream feature should be removed form the service discovery manager if Socks5
* bytestream feature is disabled.
*/
@Test
public void shouldDisableService() {
Socks5BytestreamManager byteStreamManager = Socks5BytestreamManager.getBytestreamManager(connection);
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
assertTrue(discoveryManager.includesFeature(Bytestream.NAMESPACE));
byteStreamManager.disableService();
assertFalse(discoveryManager.includesFeature(Bytestream.NAMESPACE));
}
示例15: shouldHaveOneManagerForEveryConnection
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Test that {@link Socks5BytestreamManager#getBytestreamManager(XMPPConnection)} returns one
* bytestream manager for every connection
*/
@Test
public void shouldHaveOneManagerForEveryConnection() {
// mock two connections
XMPPConnection connection1 = mock(XMPPConnection.class);
XMPPConnection connection2 = mock(XMPPConnection.class);
/*
* create service discovery managers for the connections because the
* ConnectionCreationListener is not called when creating mocked connections
*/
ServiceDiscoveryManager.getInstanceFor(connection1);
ServiceDiscoveryManager.getInstanceFor(connection2);
// get bytestream manager for the first connection twice
Socks5BytestreamManager conn1ByteStreamManager1 = Socks5BytestreamManager.getBytestreamManager(connection1);
Socks5BytestreamManager conn1ByteStreamManager2 = Socks5BytestreamManager.getBytestreamManager(connection1);
// get bytestream manager for second connection
Socks5BytestreamManager conn2ByteStreamManager1 = Socks5BytestreamManager.getBytestreamManager(connection2);
// assertions
assertEquals(conn1ByteStreamManager1, conn1ByteStreamManager2);
assertNotSame(conn1ByteStreamManager1, conn2ByteStreamManager1);
}