Expand my Community achievements bar.

SharedCollection and RECONNECT

Avatar

Level 2



quote:



It's often the case that you'll want to reset the state of
any shared model once a reconnect occurs, since you'll re-sync all
of the messages on the service again. For example, SimpleChatModel
should clear its history, since it's about to re-receive all
previous messages. In order to detect a reconnect, simply listen to
CollectionNodeEvent.RECONNECT.





After reading Niggel's comments on reconnect from another
post.
This is what I have perceived.

I have looked at SharedCollection.as and found that this
class does not do anything on reconnect. Should not it remove all
of its items on reconnect to receive latest from the service? to
handle a scenario where you have 10 elements when it first got
synced, then it disconnects , during time the time it is
disconnected, items on services become 5. When this
SharedCollection re sync will it receives onItemRetract for items
that were purged during the time it was disconnected?

Any thought on this please?
5 Replies

Avatar

Former Community Member
Hi,



Yes when you reconnect the SharedCollection it currently
shows up the existing items and if during the disconnect , things
were added or removed it might not show it. I will get back to you
with details after running on my side.



Thanks

Regards

Hironmay Basu

Avatar

Former Community Member
Hi,



I have now fixed the SharedCollection so that it resyncs from
the services the current number of items and updates them so that
any changes during disconnect is also reflected. It will be updated
in the next SDK drop but in case , you need to fix it in your local
source, you need to override the onSyncChange function in
SharedCollection with the code which is attached with this reply or
fix it in your local source.



Thanks for finding us issues like this. We greatly appreciate
your help in making our framework better.



Regards

Hironmay Basu

Avatar

Level 2
Thanks Hironmay for your reply,



Another question if we have a collectionNode created and
already subscribed and we call subscribe() again on it, will it
fire SYNCRONIZATION_CHANGE event? any insight on this please







Avatar

Former Community Member
Hi

When you call subscribe on a collectionNode , it actually
subscribes to the server and gets all the messages to get it to the
current state of application. Once the current state is reached, it
throws the Synchronization Change event. For most of our afcs model
components like SharedManagers/SharedModels , we call subscribe
within the component.

When you have disconnect , we also throw the event with
isSynchronized property of the collectionnode being false and when
you gets reconnected again, after you get all the messages and sync
to the current state of the appliation, the synchronization change
event is again fired , this time the isSynchronized property value
being true.



Calling subscribe() multiple times if the collectionnode is
already syncd to the current state will not fire this event. It
will be only fired if you are not updated with the current state.



Hope this helps.



Thanks

Hironmay Basu

Avatar

Former Community Member
Hi,



As an added info, the best place to clear your
SharedCollection when it reconnects is to have it in the handler
function of CollectionNodeEvent.RECONNECT event. Though adding in
SYNCHRONIZATION_CHANGE event with it being false also works like a
code earlier sent by me, but the best place to add is when
reconnect event is fired.



Thanks

Hironmay Basu