drewmccormack / ensembles

A synchronization framework for Core Data.
MIT License
1.63k stars 131 forks source link

Added support of MultipeerConnectivity #150

Closed cflorion closed 10 years ago

cflorion commented 10 years ago

Hello Drew,

After a few months away I am back giving a try making Ensembles work with the MultipeerConnectivity framework. This is a first version, is it designed as you thought it should be ?

My apologies about putting SSZipArchive directly in the Idiomatic project. I tried to put it as a submodule but I failed, I suck at config in general...

Thanks a lot!

drewmccormack commented 10 years ago

Looks very useful. Thanks!

A few questions: 1) Have you actually tested it? Does it sync? 2) Seems you zip up missing files, and send them over, and then just unzip. Is that correct? (Seems an elegant solution.) 3) I didn't see any tracking of removed files, but that may not actually be necessary. I think each peer should clean them up locally on their own.

Great stuff. I will probably go through and clean up the code a bit before merging it into the repo, but this is an enormous step forward. Thanks!

cflorion commented 10 years ago

1) Yes it does sync. Though I have to find a way to Unit Test it... 2) Exactly. 3) Indeed. I didn't take care of removed files, I'll have a look at it !

drewmccormack commented 10 years ago

I've had more time to go through the code now. I think we should make one change to the design: at the moment, the CDEMultipeerCloudFileSystem handles the advertising and browsing. The problem with this is that it restricts how the app can implement a pairing UI. There are standard classes that provide UI for pairing, but you can't use these if the browser and advertiser are embedded in the cloud file system.

I propose the following: 1) We remove any reference to the browser and advertiser objects. The host app will handle this. 2) The cloud file system also doesn't create an MCSession. 3) Instead, the host app locates peers and configures an MCSession ready to sync. It then passes this to the cloud file system, to a method like

- (void)synchronizeFilesViaMulitpeerSession:(MCSession *)session withCompletion:(CDECompletionBlock)block;

This should simplify the class a lot, and give the host app maximum flexibility in how it connects to peers.

Thoughts?

cflorion commented 10 years ago

Good call. I indeed picked this design because it suited my needs. But I agree, the way the MultipeerConnectivity framework is handled shouldn't depend on Ensembles but on the developer's implementation of it. I'll give it another try with your feedbacks and I'll let you know ;)