views:

79

answers:

2

I am currently developing an application using dropbox c# API.

DropBox is able to capture changes on their server and also the changes in their client almost immediately.

What technique they use to synchronize this 2 replicas?

Wish someone can provide me some clue to start with, I try to avoid the timer base synchronization.

Thanks.

A: 

For client changes, they might use file system watcher. If there is a change in dropbox folder, they ll trigger the API to update the drop box server.

I am not sure about the server side changes, But there should be some timer mechanism to poll the server to see the changes..

Cheers

Ramesh Vel
if they using timer mechanism, means it polls almost every seconds. Is there any technology that similar like push mail, but is for protocol other than email?
VHanded
It doesnt have to be every seconds, something like AJAX COMET long polls.. client will initiate a connection, and server will only respond if there is a change. So the client initiate next poll after retrieving the first response.. something like that.......
Ramesh Vel
A: 

I don't know what they use. But you can use filesystemwatcher from c#. That will allow you to catch a file change event. It is not the easiest thing to work with, but simple to use.

To make sure that old revisions of the file to not overwrite the new, I guess they use a revision counter, which is often the case.

To identify if the file is changed from the current stored file, I imagine they may use a number of checks

if (local[file.name].size != server[file.name].size)
{
    file.changed = true;
}
else if (local[file.name].md5 != server[file.name].md5)
{
    file.changed = true;
}
else
{
    file.changed = false;
}
Matthew
I understand this part, what I don't understand is how the client knows the files are changed in server side. Dropbox client is able to detect the changes on server almost immediately, and similar technology I can use?
VHanded
Filesystemwatcher will detect a even on the file-system, like the change of a file. That is more than likely what is being used. The other guy said the exact same thing. see http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx
Matthew
I should change my question: how to detect server changes immediately?
VHanded
If you want to detect if there is a server change use the same method as direct push. Have the client connect to the server. And send a message to the client from the server using that open socket on the event of a change.
Matthew
yes, do you have any code to refer to? Or any reference that I can view? Thanks.
VHanded
here you go http://tinyurl.com/2bjfnzy
Matthew