/** * Removes a space from the list of observed spaces. * If the space is not in the list of observed spaces, nothing happens. * @param spaceId Identifier of the space to observe. */ @Override public void removeSpace(String spaceId) { Space space = spaceHandler.getSpace(spaceId); if (handledSpaces.remove(space)){ SpaceChannel channel = space.getPubSubChannel(); Map<String, String> properties = channel.getProperties(); datawrapper.deleteCachedDataObjectsForSpace(properties.get("node")); if (getMode() == Mode.ONLINE){ try { LeafNode node = (LeafNode) getNode(properties.get("node"), properties.get("domain")); node.removeItemEventListener(this); } catch (UnknownEntityException e) { Log.d("DATAHANDLER", "An UnknownEntityException was thrown while removing a registered space.", e); } } } }
private void XMPPPublisher(String xmlString, String SCHEMA, String mtype, Node pubNode){ SimplePayload payload = new SimplePayload(mtype,SCHEMA, xmlString); @SuppressWarnings({ "unchecked", "rawtypes" }) PayloadItem payloadItem = new PayloadItem(null, payload); Log.i(appTAG, classTAG+": Message Published to:"+pubNode.getId()); try { ((LeafNode)pubNode).publish(payloadItem); } catch (NotConnectedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
protected LeafNode getRandomPubnode(PubSubManager pubMgr, boolean persistItems, boolean deliverPayload) throws XMPPException { ConfigureForm form = new ConfigureForm(FormType.submit); form.setPersistentItems(persistItems); form.setDeliverPayloads(deliverPayload); form.setAccessModel(AccessModel.open); return (LeafNode)pubMgr.createNode("/test/Pubnode" + System.currentTimeMillis(), form); }
/** * Publish an avatar data. * * @param id the id of the avatar data * @param data the data of the avatar */ private void publishAvatarData(String id, byte[] data) { AvatarExtension avatar = new AvatarExtension(data); PayloadItem<AvatarExtension> item = new PayloadItem<AvatarExtension>(id, avatar); LeafNode node = mPep.getPEPNode(AVATARDATA_NODE); node.publish(item); }
@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; } }
protected LeafNode getPubnode(boolean persistItems, boolean deliverPayload) throws XMPPException { return getRandomPubnode(getManager(), persistItems, deliverPayload); }
/** * Get a PepNode. * This node is obtain without checking its existence as PEP should auto create it. * * @param nodeName the node name * @return the node */ public LeafNode getPEPNode(String nodeName) { LeafNode node = new LeafNode(con, nodeName); node.setTo(to); return node; }
/** * Send the metadata of the avatar you want to publish. * By sending this metadata, you publish an avatar. * * @param id the id of the metadata item * @param metadata the metadata to publish */ public void publishAvatarMetaData(String id, AvatarMetadataExtension metadata) { PayloadItem<AvatarMetadataExtension> item = new PayloadItem<AvatarMetadataExtension>(id, metadata); LeafNode node = mPep.getPEPNode(AVATARMETADATA_NODE); node.publish(item); }