本文整理汇总了Java中org.jivesoftware.smackx.packet.DiscoverInfo.Identity类的典型用法代码示例。如果您正苦于以下问题:Java Identity类的具体用法?Java Identity怎么用?Java Identity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Identity类属于org.jivesoftware.smackx.packet.DiscoverInfo包,在下文中一共展示了Identity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSmackInfo
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的package包/类
/**
* Tests info discovery of a Smack client.
*/
public void testSmackInfo() {
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager
.getInstanceFor(getConnection(0));
try {
// Discover the information of another Smack client
DiscoverInfo info = discoManager.discoverInfo(getFullJID(1));
// Check the identity of the Smack client
Iterator<Identity> identities = info.getIdentities();
assertTrue("No identities were found", identities.hasNext());
Identity identity = identities.next();
assertEquals("Name in identity is wrong", discoManager.getIdentityName(),
identity.getName());
assertEquals("Category in identity is wrong", "client", identity.getCategory());
assertEquals("Type in identity is wrong", discoManager.getIdentityType(),
identity.getType());
assertFalse("More identities were found", identities.hasNext());
}
catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
示例2: discoverGateway
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的package包/类
/**
* Discovers {@link DiscoveryInfo} and {@link DiscoveryInfo.Identity} of a gateway
* and creates a {@link Gateway} object representing this gateway.
* @param itemJID
* @throws XMPPException
*/
private void discoverGateway(String itemJID) throws XMPPException{
DiscoverInfo info = sdManager.discoverInfo(itemJID);
Iterator<Identity> i = info.getIdentities();
while(i.hasNext()){
Identity identity = i.next();
String category = identity.getCategory();
if(category.toLowerCase().equals("gateway")){
gateways.put(itemJID, new Gateway(connection,itemJID));
if(itemJID.contains(connection.getHost())){
localGateways.put(itemJID,
new Gateway(connection,itemJID,info,identity));
}
else{
nonLocalGateways.put(itemJID,
new Gateway(connection,itemJID,info,identity));
}
break;
}
}
}
示例3: discoverGateway
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的package包/类
/**
* Discovers {@link DiscoveryInfo} and {@link DiscoveryInfo.Identity} of a
* gateway and creates a {@link Gateway} object representing this gateway.
*
* @param itemJID
* @throws XMPPException
*/
private void discoverGateway(String itemJID) throws XMPPException {
DiscoverInfo info = sdManager.discoverInfo(itemJID);
Iterator<Identity> i = info.getIdentities();
while (i.hasNext()) {
Identity identity = i.next();
String category = identity.getCategory();
if (category.toLowerCase().equals("gateway")) {
gateways.put(itemJID, new Gateway(connection, itemJID));
if (itemJID.contains(connection.getHost())) {
localGateways.put(itemJID, new Gateway(connection, itemJID,
info, identity));
} else {
nonLocalGateways.put(itemJID, new Gateway(connection,
itemJID, info, identity));
}
break;
}
}
}
示例4: testSmackInfo
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的package包/类
/**
* Tests info discovery of a Smack client.
*/
public void testSmackInfo() {
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager
.getInstanceFor(getConnection(0));
try {
// Discover the information of another Smack client
DiscoverInfo info = discoManager.discoverInfo(getFullJID(1));
// Check the identity of the Smack client
Iterator<Identity> identities = info.getIdentities();
assertTrue("No identities were found", identities.hasNext());
Identity identity = identities.next();
assertEquals("Name in identity is wrong", ServiceDiscoveryManager.getIdentityName(),
identity.getName());
assertEquals("Category in identity is wrong", "client", identity.getCategory());
assertEquals("Type in identity is wrong", ServiceDiscoveryManager.getIdentityType(),
identity.getType());
assertFalse("More identities were found", identities.hasNext());
}
catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
示例5: testDiscoverNodeInfo
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的package包/类
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());
}
示例6: discoverInfo
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的package包/类
private void discoverInfo() throws XMPPException{
info = sdManager.discoverInfo(entityJID);
Iterator<Identity> iterator = info.getIdentities();
while(iterator.hasNext()){
Identity temp = iterator.next();
if(temp.getCategory().equalsIgnoreCase("gateway")){
this.identity = temp;
break;
}
}
}
示例7: getIdentities
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的package包/类
/**
* Returns all identities of this client as unmodifiable Collection
*
* @return
*/
public Set<DiscoverInfo.Identity> getIdentities() {
Set<Identity> res = new HashSet<Identity>(identities);
// Add the default identity that must exist
res.add(defaultIdentity);
return Collections.unmodifiableSet(res);
}
示例8: discoverInfo
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的package包/类
private void discoverInfo() throws XMPPException {
info = sdManager.discoverInfo(entityJID);
Iterator<Identity> iterator = info.getIdentities();
while (iterator.hasNext()) {
Identity temp = iterator.next();
if (temp.getCategory().equalsIgnoreCase("gateway")) {
this.identity = temp;
break;
}
}
}
示例9: getIdentityName
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的package包/类
/**
* Returns the name of the client that will be returned when asked for the client identity
* in a disco request. The name could be any value you need to identity this client.
*
* @return the name of the client that will be returned when asked for the client identity
* in a disco request.
*/
public static String getIdentityName() {
DiscoverInfo.Identity identity = identities.get(0);
if (identity != null) {
return identity.getName();
} else {
return null;
}
}
示例10: getIdentityType
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的package包/类
/**
* Returns the type of client that will be returned when asked for the client identity in a
* disco request. The valid types are defined by the category client. Follow this link to learn
* the possible types: <a href="http://xmpp.org/registrar/disco-categories.html#client">Jabber::Registrar</a>.
*
* @return the type of client that will be returned when asked for the client identity in a
* disco request.
*/
public static String getIdentityType() {
DiscoverInfo.Identity identity = identities.get(0);
if (identity != null) {
return identity.getType();
} else {
return null;
}
}
示例11: setIdentityType
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的package包/类
/**
* Sets the type of client that will be returned when asked for the client identity in a
* disco request. The valid types are defined by the category client. Follow this link to learn
* the possible types: <a href="http://xmpp.org/registrar/disco-categories.html#client">Jabber::Registrar</a>.
*
* @param type the type of client that will be returned when asked for the client identity in a
* disco request.
*/
public static void setIdentityType(String type) {
DiscoverInfo.Identity identity = identities.get(0);
if (identity != null) {
identity.setType(type);
} else {
identity = new DiscoverInfo.Identity(DEFAULT_IDENTITY_CATEGORY, DEFAULT_IDENTITY_NAME, type);
identities.add(identity);
}
}
示例12: determineProxies
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的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: AdHocCommandManager
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的package包/类
private AdHocCommandManager(Connection connection) {
this.connection = new WeakReference<Connection>(connection);
this.serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
// Register the new instance and associate it with the connection
instances.put(connection, this);
// Add the feature to the service discovery manage to show that this
// connection supports the AdHoc-Commands protocol.
// This information will be used when another client tries to
// discover whether this client supports AdHoc-Commands or not.
ServiceDiscoveryManager.getInstanceFor(connection).addFeature(
DISCO_NAMESPACE);
// Set the NodeInformationProvider that will provide information about
// which AdHoc-Commands are registered, whenever a disco request is
// received
ServiceDiscoveryManager.getInstanceFor(connection)
.setNodeInformationProvider(discoNode,
new NodeInformationProvider() {
public List<DiscoverItems.Item> getNodeItems() {
List<DiscoverItems.Item> answer = new ArrayList<DiscoverItems.Item>();
Collection<AdHocCommandInfo> commandsList = getRegisteredCommands();
for (AdHocCommandInfo info : commandsList) {
DiscoverItems.Item item = new DiscoverItems.Item(
info.getOwnerJID());
item.setName(info.getName());
item.setNode(info.getNode());
answer.add(item);
}
return answer;
}
public List<String> getNodeFeatures() {
return null;
}
public List<Identity> getNodeIdentities() {
return null;
}
@Override
public List<PacketExtension> getNodePacketExtensions() {
return null;
}
});
// The packet listener and the filter for processing some AdHoc Commands
// Packets
PacketListener listener = new PacketListener() {
public void processPacket(Packet packet) {
AdHocCommandData requestData = (AdHocCommandData) packet;
processAdHocCommand(requestData);
}
};
PacketFilter filter = new PacketTypeFilter(AdHocCommandData.class);
connection.addPacketListener(listener, filter);
sessionsSweeper = null;
}
示例14: Gateway
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的package包/类
Gateway(Connection connection, String entityJID, DiscoverInfo info, Identity identity){
this(connection, entityJID);
this.info = info;
this.identity = identity;
}
示例15: getIdentity
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的package包/类
private Identity getIdentity() throws XMPPException{
if(identity==null){
discoverInfo();
}
return identity;
}