本文整理汇总了Java中org.jivesoftware.smackx.pubsub.PayloadItem.getPayload方法的典型用法代码示例。如果您正苦于以下问题:Java PayloadItem.getPayload方法的具体用法?Java PayloadItem.getPayload怎么用?Java PayloadItem.getPayload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smackx.pubsub.PayloadItem
的用法示例。
在下文中一共展示了PayloadItem.getPayload方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: eventReceived
import org.jivesoftware.smackx.pubsub.PayloadItem; //导入方法依赖的package包/类
@Override
public void eventReceived(String from, String node, List<Item> items) {
if (!"urn:xmpp:avatar:metadata".equals(node))
return;
Item i = items.get(0);
if (i instanceof PayloadItem) {
PayloadItem<PacketExtension> pi = (PayloadItem<PacketExtension>) i;
PacketExtension ex = pi.getPayload();
if (ex instanceof AvatarMetadataExtension) {
AvatarMetadataExtension ext = (AvatarMetadataExtension) ex;
String id = i.getId();
List<Info> infos = ext.getInfos();
if (infos.size() > 0 && mAutoDownload) {
Info info = selectAvatar(infos);
if (!mCache.contains(id))
downloadAvatar(from, id, info);
}
fireListeners(from, id, infos);
}
}
}
示例2: handlePublishedItems
import org.jivesoftware.smackx.pubsub.PayloadItem; //导入方法依赖的package包/类
/**
* Item handler of this data handler implementation. Checks if received items are already cached,
* if not, it caches them. Ultimately it sends the items to the subscribed listeners.
*/
@Override
public void handlePublishedItems(ItemPublishEvent<PayloadItem<SimplePayload>> items){
String spaceId = getSpaceId(items.getNodeId());
if (spaceId == null) return;
List<String> toRequest = new ArrayList<String>();
for (PayloadItem<SimplePayload> item:items.getItems()){
if (item.getPayload() == null && !pendingPayloadRequests.containsKey(item.getId())){
toRequest.add(item.getId());
continue;
}
DataObject obj = parseItemToDataObject(item);
if (dataObjectFilter == null || dataObjectFilter.isDataObjectValid(obj)) {
if (!datawrapper.isDataObjectAlreadyCached(item.getId())){
datawrapper.saveDataObject(items.getNodeId(), obj, item.getId());
}
for (DataObjectListener listener:listeners){
listener.handleDataObject(obj, spaceId);
}
}
}
if (!toRequest.isEmpty()){
for (String id:toRequest){
try {
retrievePayload(items.getNodeId(), id);
} catch (Exception e) {
//Ignore
continue;
}
}
}
}
示例3: processMetadataEvent
import org.jivesoftware.smackx.pubsub.PayloadItem; //导入方法依赖的package包/类
void processMetadataEvent(JID jid, ItemsExtension itemsExt) {
List<? extends ExtensionElement> items = itemsExt.getItems();
if (items.isEmpty()) {
LOGGER.warning("no items in items event");
return;
}
// there should be only one item
ExtensionElement e = items.get(0);
if (!(e instanceof PayloadItem)) {
LOGGER.warning("element not a payloaditem");
return;
}
PayloadItem item = (PayloadItem) e;
ExtensionElement metadataExt = item.getPayload();
if (!(metadataExt instanceof AvatarMetadataExtension)) {
LOGGER.warning("payload not avatar metadata");
return;
}
AvatarMetadataExtension metadata = (AvatarMetadataExtension) metadataExt;
List<AvatarMetadataExtension.Info> infos = metadata.getInfos();
if (infos.isEmpty()) {
// this means the contact disabled avatar publishing
mHandler.onNotify(jid, "");
return;
}
// assuming infos are always in the same order
for (AvatarMetadataExtension.Info info : infos) {
if (AvatarHandler.SUPPORTED_TYPES.contains(info.getType())) {
mHandler.onNotify(jid, info.getId());
break;
} else {
LOGGER.info("image type not supported: "+info.getType());
}
}
}
示例4: getAvatar
import org.jivesoftware.smackx.pubsub.PayloadItem; //导入方法依赖的package包/类
@Override
public byte[] getAvatar() {
try {
LeafNode node = mPubsub.getPEPNode(AVATARDATANODE);
List<Item> items = node.getItems(Arrays.asList(mId));
PayloadItem<AvatarExtension> item = (PayloadItem<AvatarExtension>) items.get(0);
AvatarExtension avatar = item.getPayload();
return avatar.getData();
} catch (XMPPException e) {
return null;
}
}