He studied in detail the work of sockets, up to the practical implementation of various ideas in several languages. Now there was a task to write a cloud text editor. (Joint text editing) Sel, wrote a server on which the txt file is located. When sending a GET request to the server, the server returns the contents of the document. For any other - the server saves the received data in the document.
Began to write an editor. Made the simplest logic: every second a file is synchronized with the server. But, there was a problem when the file on computer A changes, the server accepts it, updates the document on computer B and at the same time erases a part of the text that user B. wrote. Either way.
Developing an application in Xcode in c ++, I can redo it under swift, but this is not so important. So nevertheless how to implement logic of cloud editing?