本文整理汇总了Java中org.jivesoftware.smackx.packet.DiscoverInfo.Identity类的典型用法代码示例。如果您正苦于以下问题:Java Identity类的具体用法?Java Identity怎么用?Java Identity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Identity类属于org.jivesoftware.smackx.packet.DiscoverInfo包,在下文中一共展示了Identity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
}
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:27,代码来源:ServiceDiscoveryManagerTest.java
示例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;
}
}
}
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:28,代码来源:GatewayManager.java
示例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;
}
}
}
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:28,代码来源:GatewayManager.java
示例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());
}
}
开发者ID:bejayoharen,项目名称:java-bells,代码行数:27,代码来源:ServiceDiscoveryManagerTest.java
示例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());
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:10,代码来源:EntityUseCases.java
示例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;
}
}
}
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:12,代码来源:Gateway.java
示例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);
}
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:12,代码来源:ServiceDiscoveryManager.java
示例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;
}
}
}
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:12,代码来源:Gateway.java
示例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;
}
}
开发者ID:bejayoharen,项目名称:java-bells,代码行数:16,代码来源:ServiceDiscoveryManager.java
示例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;
}
}
开发者ID:bejayoharen,项目名称:java-bells,代码行数:17,代码来源:ServiceDiscoveryManager.java
示例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);
}
}
开发者ID:bejayoharen,项目名称:java-bells,代码行数:18,代码来源:ServiceDiscoveryManager.java
示例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;
}
开发者ID:ice-coffee,项目名称:EIM,代码行数:57,代码来源:Socks5BytestreamManager.java
示例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;
}
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:65,代码来源:AdHocCommandManager.java
示例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;
}
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:6,代码来源:Gateway.java
示例15: getIdentity
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的package包/类
private Identity getIdentity() throws XMPPException{
if(identity==null){
discoverInfo();
}
return identity;
}
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:7,代码来源:Gateway.java
示例16: updateLocalEntityCaps
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的package包/类
/**
* Updates the local user Entity Caps information with the data provided
*
* If we are connected and there was already a presence send, another
* presence is send to inform others about your new Entity Caps node string.
*
* @param discoverInfo
* the local users discover info (mostly the service discovery
* features)
* @param identityType
* the local users identity type
* @param identityName
* the local users identity name
* @param extendedInfo
* the local users extended info
*/
public void updateLocalEntityCaps() {
Connection connection = weakRefConnection.get();
DiscoverInfo discoverInfo = new DiscoverInfo();
discoverInfo.setType(IQ.Type.RESULT);
discoverInfo.setNode(getLocalNodeVer());
if (connection != null)
discoverInfo.setFrom(connection.getUser());
sdm.addDiscoverInfoTo(discoverInfo);
currentCapsVersion = generateVerificationString(discoverInfo, "sha-1");
addDiscoverInfoByNode(ENTITY_NODE + '#' + currentCapsVersion, discoverInfo);
if (lastLocalCapsVersions.size() > 10) {
String oldCapsVersion = lastLocalCapsVersions.poll();
sdm.removeNodeInformationProvider(ENTITY_NODE + '#' + oldCapsVersion);
}
lastLocalCapsVersions.add(currentCapsVersion);
caps.put(currentCapsVersion, discoverInfo);
if (connection != null)
jidCaps.put(connection.getUser(), new NodeVerHash(ENTITY_NODE, currentCapsVersion, "sha-1"));
final List<Identity> identities = new LinkedList<Identity>(ServiceDiscoveryManager.getInstanceFor(connection).getIdentities());
sdm.setNodeInformationProvider(ENTITY_NODE + '#' + currentCapsVersion, new NodeInformationProvider() {
List<String> features = sdm.getFeaturesList();
List<PacketExtension> packetExtensions = sdm.getExtendedInfoAsList();
@Override
public List<Item> getNodeItems() {
return null;
}
@Override
public List<String> getNodeFeatures() {
return features;
}
@Override
public List<Identity> getNodeIdentities() {
return identities;
}
@Override
public List<PacketExtension> getNodePacketExtensions() {
return packetExtensions;
}
});
// Send an empty presence, and let the packet intercepter
// add a <c/> node to it.
// See http://xmpp.org/extensions/xep-0115.html#advertise
// We only send a presence packet if there was already one send
// to respect ConnectionConfiguration.isSendPresence()
if (connection != null && connection.isAuthenticated() && presenceSend) {
Presence presence = new Presence(Presence.Type.available);
connection.sendPacket(presence);
}
}
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:75,代码来源:EntityCapsManager.java
示例17: 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;
}
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:7,代码来源:Gateway.java
示例18: getIdentity
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的package包/类
private Identity getIdentity() throws XMPPException {
if (identity == null) {
discoverInfo();
}
return identity;
}
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:7,代码来源:Gateway.java
示例19: 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;
}
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:62,代码来源:Socks5BytestreamManager.java
示例20: updateLocalEntityCaps
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity; //导入依赖的package包/类
/**
* Updates the local user Entity Caps information with the data provided
*
* If we are connected and there was already a presence send, another
* presence is send to inform others about your new Entity Caps node string.
*
* @param discoverInfo
* the local users discover info (mostly the service discovery
* features)
* @param identityType
* the local users identity type
* @param identityName
* the local users identity name
* @param extendedInfo
* the local users extended info
*/
public void updateLocalEntityCaps() {
Connection connection = weakRefConnection.get();
DiscoverInfo discoverInfo = new DiscoverInfo();
discoverInfo.setType(IQ.Type.RESULT);
discoverInfo.setNode(getLocalNodeVer());
if (connection != null)
discoverInfo.setFrom(connection.getUser());
sdm.addDiscoverInfoTo(discoverInfo);
currentCapsVersion = generateVerificationString(discoverInfo, "sha-1");
addDiscoverInfoByNode(ENTITY_NODE + '#' + currentCapsVersion, discoverInfo);
if (lastLocalCapsVersions.size() > 10) {
String oldCapsVersion = lastLocalCapsVersions.poll();
sdm.removeNodeInformationProvider(ENTITY_NODE + '#' + oldCapsVersion);
}
lastLocalCapsVersions.add(currentCapsVersion);
caps.put(currentCapsVersion, discoverInfo);
if (connection != null)
jidCaps.put(connection.getUser(), new NodeVerHash(ENTITY_NODE, currentCapsVersion, "sha-1"));
sdm.setNodeInformationProvider(ENTITY_NODE + '#' + currentCapsVersion, new NodeInformationProvider() {
List<String> features = sdm.getFeaturesList();
List<Identity> identities = new LinkedList<Identity>(ServiceDiscoveryManager.getIdentities());
List<PacketExtension> packetExtensions = sdm.getExtendedInfoAsList();
@Override
public List<Item> getNodeItems() {
return null;
}
@Override
public List<String> getNodeFeatures() {
return features;
}
@Override
public List<Identity> getNodeIdentities() {
return identities;
}
@Override
public List<PacketExtension> getNodePacketExtensions() {
return packetExtensions;
}
});
// Send an empty presence, and let the packet intercepter
// add a <c/> node to it.
// See http://xmpp.org/extensions/xep-0115.html#advertise
// We only send a presence packet if there was already one send
// to respect ConnectionConfiguration.isSendPresence()
if (connection != null && connection.isAuthenticated() && presenceSend) {
Presence presence = new Presence(Presence.Type.available);
connection.sendPacket(presence);
}
}
开发者ID:bejayoharen,项目名称:java-bells,代码行数:75,代码来源:EntityCapsManager.java
注:本文中的org.jivesoftware.smackx.packet.DiscoverInfo.Identity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论