I'm creating a flash site, that you can download stuff from, I need a log to know what the people are downloading and when. I know that I can't simply load the XML log file, add to it and then save it again as this may overwrite an entry that happened during the upload/download of the xml log?
Any ideas how to do this, or even better are there any components to do this?
Yes, I do understand you can do that, however, what happens if two or more people are downloading, and attempt to write the XML file back! Some data is going to be lost. Do you understand now?
To make this clearer,
Person A decide to download a file, and the site reads the XML to the client machine.
Person B decides to download a file at that same time and reads the XML file.
Person A writes the XML back to the server and with the new information in it.
Person B writes the XML back.
Oops! XML on persons B machine doesn't have the information from persons A XML so therefore lost.
Again thank you for the reply.
OK! This is my theory to solving this problem I have.
I'll have two xml files, the first being the log itself, the second we can call a lock file also xml.
The lock file consists of:
<file lock="false" />
When a person clicks to download a file, the swf downloads the lock file and checks to see if the lock property is false, if it is then it is set to true and sent back, then it can freely download and modify the log, then the lock file is set to false and sent back.
If on the other hand the lock property is true, it'll wait an amount of time before loading the lock file again, until the lock file says it is OK to load the XML log.
I'll do some tests over then next few days and keep you posted.
Just thought of an even better way of doing it! Which solves the multi-access to a single file problem.
Having not a single log file but one for each user IP, in other words, have a seperate log file for each computer that logs in.
If I save the XML as the users IP address and then there is no problem as no one else will have that IP address.
OK! Problem solved.
Europe, Middle East and Africa