本文整理汇总了Java中org.jivesoftware.smackx.packet.DiscoverInfo.setFrom方法的典型用法代码示例。如果您正苦于以下问题:Java DiscoverInfo.setFrom方法的具体用法?Java DiscoverInfo.setFrom怎么用?Java DiscoverInfo.setFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smackx.packet.DiscoverInfo
的用法示例。
在下文中一共展示了DiscoverInfo.setFrom方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: discoverInfoByCaps
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Returns the discovered information of a given XMPP entity addressed by
* its JID if it's known by the entity caps manager.
*
* @param entityID
* the address of the XMPP entity
* @return the disovered info or null if no such info is available from the
* entity caps manager.
* @throws XMPPException
* if the operation failed for some reason.
*/
public DiscoverInfo discoverInfoByCaps(String entityID)
throws XMPPException {
DiscoverInfo info = capsManager.getDiscoverInfoByUser(entityID);
if (info != null) {
DiscoverInfo newInfo = cloneDiscoverInfo(info);
newInfo.setFrom(entityID);
return newInfo;
} else {
return null;
}
}
示例2: discoverInfoByCaps
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Returns the discovered information of a given XMPP entity addressed by its JID
* if it's known by the entity caps manager.
*
* @param entityID the address of the XMPP entity
* @return the disovered info or null if no such info is available from the
* entity caps manager.
* @throws XMPPException if the operation failed for some reason.
*/
public DiscoverInfo discoverInfoByCaps(String entityID) throws XMPPException {
DiscoverInfo info = capsManager.getDiscoverInfoByUser(entityID);
if (info != null) {
DiscoverInfo newInfo = cloneDiscoverInfo(info);
newInfo.setFrom(entityID);
return newInfo;
}
else {
return null;
}
}
示例3: updateLocalEntityCaps
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的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);
}
}
示例4: cleanupDicsoverInfo
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
private static void cleanupDicsoverInfo(DiscoverInfo info) {
info.setFrom(null);
info.setTo(null);
info.setPacketID(null);
}
示例5: updateLocalEntityCaps
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的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);
}
}
示例6: cleanupDicsoverInfo
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
private static void cleanupDicsoverInfo(DiscoverInfo info) {
info.setFrom(null);
info.setTo(null);
info.setPacketID(null);
}