Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Shared Collection events With Guest users

Avatar

Level 2
Problem:

As a guest I would like to subscribe to a shared collection
that I have permission to see and display it's items.



Solution:

Create a shared collection with either the AFCSDevConsole or
with a user logged in with Owner permissions first, then access the
shared collection from the guest application via it's shared ID.



Unexpected behavior:

When a guest user subscribes to a shared collection by
supplying it's shared id property the events it receives when an
item is added to the shared collection do not act as I expected
from my understanding of sharedCollection.addItem(item);. My
expected result is that the guest application would receive an add
event and would see that the collection has grown by one. Instead
the guest application receives multiple update events and a replace
event leaving the length of the shared collection from it's point
of view unchanged. The item in the shared collection always stays
at index 0 and is replaced by subsequent additions.

Furthermore the user logged in with owner permissions is able
to see the collection as it really is in the room.

I am guessing that there is something I am missing and this
is how it is intended to work. What am I missing in order view
changes correctly to a shared collection that I do not create, but
instead retrieve from the room using it's shared id?
2 Replies

Avatar

Former Community Member
Hi CS,



Thanks for the feedback - The secret here is "idField".



The docs for sharedCollection state (
http://livedocs.adobe.com/labs/acrobatcom/com/adobe/rtc/sharedModel/SharedCollection.html)
:



"The collection does not share sort order - any sorting
desired should be performed on each respective client. As such,
addItemAt isn't supported, although addItem is. The collection
makes update decisions on items based on a unique id - items added
to the collection should either implement the IUID interface, or
provide a field which is guaranteed to be unique for this
collection. The SharedCollection exposes an idField property to
specify which field to use as unique id, in the case the items do
not implement IUID."



So, I can see you're using "uniqueID" in each item, but
unfortunately the collection doesn't know you've supplied it as a
unique field. Just tell the collection

theCollection.idField = "uniqueID";

In onCreationComplete(), and the example starts to work.



We're going to make some code changes to throw an error in
the case you're not either implementing IUID or specifying an
idField, to give more guidance as to what you need to do. This
should be in for the next drop - sorry for the frustration, but at
least you're helping those who come after you =).



hope this helps

nigel



Avatar

Level 2
Thanks Nigel.

I had a feeling there was a unique id issue involved in there
somewhere.

I was adding the idField to the owner application, but not to
the guest applications.



I was under the assumption that the settings from the shared
collection creation would be inherited when retrieved via sharedID.
Doh.