Method, device, equipment, storage medium and computer program product for document editing synchronization
By enabling local document editing while offline and synchronizing the differences upon reconnection, the problem of low reliability in document editing synchronization is solved, achieving efficient and reliable consistent document content updates.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2024-12-17
- Publication Date
- 2026-06-19
Smart Images

Figure CN122240583A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer application technology, and in particular to a method, apparatus, device, storage medium, and computer program product for document editing synchronization. Background Technology
[0002] With the development of computer technology and terminal application technology, it is becoming increasingly common for different people to use different terminals to view and edit the same document. Therefore, document editing synchronization can support people to edit documents anytime and anywhere, as well as collaborative editing between multiple people, which meets the office needs of the Internet era and has thus been widely used.
[0003] Currently, the system cannot enable online documents offline; editing is limited to local documents. This can lead to issues with synchronizing offline edits, meaning that document synchronization after reconnecting to the network after going offline is unreliable. Therefore, improving the reliability of document editing synchronization is a pressing issue that needs to be addressed. Summary of the Invention
[0004] Therefore, it is necessary to provide a method, apparatus, computer equipment, storage medium, and computer program product for improving the reliability of document editing synchronization in response to the above-mentioned technical problems.
[0005] Firstly, this application provides a method for document editing synchronization. The method is applied to a first client, and a bidirectional communication connection exists between the first client and a second client. The method includes:
[0006] Retrieve synchronized document information with the second client;
[0007] In the event that the bidirectional communication connection is disconnected, in response to a document editing operation on the first synchronized document, the first synchronized document is updated to obtain the second synchronized document;
[0008] Determine the document difference data between the first synchronized document and the second synchronized document;
[0009] When the bidirectional communication connection is in a reconnection state, the document difference data is synchronized to the second client so that, if the synchronized document information matches, the second client updates the third synchronized document through the document difference data; the third synchronized document is a document stored on the second client and whose content is consistent with the first synchronized document.
[0010] Secondly, this application provides a method for document editing synchronization. The method is applied to a two-way communication server, which provides a two-way communication connection between a first client and a second client. The method includes:
[0011] Obtain the document difference data sent by the first client, and match the document difference data by synchronizing document information;
[0012] If the synchronized document information matches, determine the synchronized document that is in the latest document state and matches the document difference data;
[0013] Update synchronized documents by document difference data, obtain updated synchronized documents, and update the document status of updated synchronized documents to the latest document status;
[0014] Broadcast document difference data to clients in the set of synchronous clients to which the first client belongs.
[0015] Thirdly, this application provides a method for document editing synchronization. The method is applied to a second client, and a bidirectional communication connection exists between the second client and the first client. The method includes:
[0016] Obtain document difference data, which describes the data updated in the first synchronized document, and the document updated in the first synchronized document is the second synchronized document;
[0017] The matching third synchronized document is determined based on the document difference data; the third synchronized document is a document stored on the second client and whose content is consistent with the first synchronized document;
[0018] Extract the document difference content, the location of the difference content, and the context of the difference content from the document difference data, and locate the actual update location in the third synchronized document based on the location of the difference content and the context of the difference content.
[0019] The third synchronized document is updated based on the document differences at the actual update location, and the fourth synchronized document is obtained so that the document content of the fourth synchronized document is consistent with that of the second synchronized document.
[0020] Fourthly, this application also provides a document editing synchronization device. The device is deployed on a first client, and a bidirectional communication connection exists between the first client and a second client. The device includes:
[0021] The document information acquisition module is used to acquire synchronized document information with the second client;
[0022] The document update module is used to update the first synchronized document to obtain the second synchronized document in response to a document editing operation on the first synchronized document when the bidirectional communication connection is disconnected.
[0023] The difference data determination module is used to determine the document difference data between the first synchronized document and the second synchronized document;
[0024] The document synchronization module is used to synchronize document difference data to the second client when the bidirectional communication connection is in a reconnection state, so that the second client can update the third synchronized document through the document difference data when the synchronized document information matches. The third synchronized document is a document stored on the second client and has the same content as the first synchronized document.
[0025] In one embodiment, the document editing synchronization device further includes a communication connection module;
[0026] The communication connection module is used to send a communication connection request to the monitoring port of the bidirectional communication server, so that the monitoring port adds the first client identifier of the first client to the synchronous client set; the synchronous client set includes at least the second client identifier of the second client, and there is a bidirectional communication connection between the clients indicated by the client identifiers belonging to the synchronous client set;
[0027] The document synchronization module is specifically used to send document difference data to the bidirectional communication server when the bidirectional communication connection is in a reconnection state, so that the bidirectional communication server broadcasts the document difference data to the client indicated by the client identifier in the synchronization client set, so as to synchronize the document difference data to the second client.
[0028] In one embodiment, the document editing synchronization device further includes a document content processing module;
[0029] The document content processing module is used to store the second synchronized document and document difference data in local storage, and display the document content of the second synchronized document on the display interface;
[0030] The document synchronization module is specifically used to retrieve document difference data from local storage and send the document difference data to the two-way communication server when the bidirectional communication connection is in a reconnection state.
[0031] In one embodiment, the synchronized document information includes at least: document synchronization content and document version identifier; the synchronized document information is matched to the document version identifier, which is consistent with the document version identifier broadcast by the bidirectional communication server;
[0032] The document information acquisition module is used to acquire synchronized document information broadcast by the bidirectional communication server based on the synchronized client set; the synchronized client set includes at least the client identifier of the second client, and there is a bidirectional communication connection between the clients belonging to the synchronized client set.
[0033] In one embodiment, the document editing synchronization device further includes a request processing module;
[0034] The request processing module is used to obtain a conflict notification when the synchronized document information is inconsistent. The conflict notification describes that the document version identifier in the synchronized document information is inconsistent with the document version identifier broadcast by the bidirectional communication server. The module sends a version retrieval request to the bidirectional communication server to retrieve the latest document version identifier from the bidirectional communication server.
[0035] In one embodiment, the document update module is specifically configured to respond to a document editing operation on a first synchronized document and determine the edited content of the first synchronized document; if the edited content satisfies the update strategy, the first synchronized document is updated based on the edited content to obtain a second synchronized document.
[0036] In one embodiment, the document update module is specifically used to determine the content length of the edited content; if the content length reaches the content length threshold, it is determined that the edited content meets the update strategy.
[0037] In one embodiment, the document update module is specifically used to determine the previous update timestamp of the document update and the last timestamp of the input of the edit content; obtain the input duration composed of the previous update timestamp and the last timestamp; and determine that the edit content meets the update strategy when the input duration reaches the input duration threshold.
[0038] In one embodiment, the document update module is specifically used to identify units in the edited content and obtain unit identification results; if the unit identification results indicate the existence of semantic units, it is determined that the edited content meets the update strategy.
[0039] In one embodiment, the document synchronization module is further configured to determine the type of editing operation indicated by the document editing operation; synchronize the document difference data and the editing operation type to the second client; wherein, if the synchronized document information matches, the second client updates the third synchronized document through the document difference data and the editing operation type.
[0040] Fifthly, this application also provides a document editing synchronization device. The device is deployed on a two-way communication server, which provides a two-way communication connection between a first client and a second client. The device includes:
[0041] The difference data processing module is used to obtain the document difference data sent by the first client and match the document difference data by synchronizing document information;
[0042] The synchronized document determination module is used to determine the synchronized document that is in the latest document state when the synchronized document information matches.
[0043] The synchronized document update module is used to update synchronized documents through document difference data, obtain updated synchronized documents, and update the document status of the updated synchronized documents to the latest document status.
[0044] The difference data sending module is used to broadcast document difference data to clients in the set of synchronous clients to which the first client belongs.
[0045] Sixthly, this application also provides a document editing synchronization device. The device is deployed on a second client, and a bidirectional communication connection exists between the second client and the first client. The device includes:
[0046] The difference data acquisition module is used to acquire document difference data, which describes the data updated on the first synchronized document, and the document updated on the first synchronized document is the second synchronized document.
[0047] The synchronized document determination module is used to determine the matching third synchronized document based on document difference data; the third synchronized document is a document stored on the second client and whose content is consistent with the first synchronized document;
[0048] The difference location module is used to extract the document difference content, the location of the difference content, and the context of the difference content from the document difference data, and to locate the actual update location in the third synchronized document based on the difference content location and the difference content context.
[0049] The document synchronization module is used to update the third synchronized document based on the document differences at the actual update location, and obtain the fourth synchronized document so that the document content of the fourth synchronized document is consistent with that of the second synchronized document.
[0050] Seventhly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0051] Retrieve synchronized document information with the second client;
[0052] In the event that the bidirectional communication connection is disconnected, in response to a document editing operation on the first synchronized document, the first synchronized document is updated to obtain the second synchronized document;
[0053] Determine the document difference data between the first synchronized document and the second synchronized document;
[0054] When the bidirectional communication connection is in a reconnection state, the document difference data is synchronized to the second client so that, if the synchronized document information matches, the second client updates the third synchronized document through the document difference data; the third synchronized document is a document stored on the second client and whose content is consistent with the first synchronized document.
[0055] Eighthly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0056] Obtain the document difference data sent by the first client, and match the document difference data by synchronizing document information;
[0057] If the synchronized document information matches, determine the synchronized document that is in the latest document state and matches the document difference data;
[0058] Update synchronized documents by document difference data, obtain updated synchronized documents, and update the document status of updated synchronized documents to the latest document status;
[0059] Broadcast document difference data to clients in the set of synchronous clients to which the first client belongs.
[0060] Ninthly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0061] Obtain document difference data, which describes the data updated in the first synchronized document, and the document updated in the first synchronized document is the second synchronized document;
[0062] The matching third synchronized document is determined based on the document difference data; the third synchronized document is a document stored on the second client and whose content is consistent with the first synchronized document;
[0063] Extract the document difference content, the location of the difference content, and the context of the difference content from the document difference data, and locate the actual update location in the third synchronized document based on the location of the difference content and the context of the difference content.
[0064] The third synchronized document is updated based on the document differences at the actual update location, and the fourth synchronized document is obtained so that the document content of the fourth synchronized document is consistent with that of the second synchronized document.
[0065] Tenthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0066] Retrieve synchronized document information with the second client;
[0067] In the event that the bidirectional communication connection is disconnected, in response to a document editing operation on the first synchronized document, the first synchronized document is updated to obtain the second synchronized document;
[0068] Determine the document difference data between the first synchronized document and the second synchronized document;
[0069] When the bidirectional communication connection is in a reconnection state, the document difference data is synchronized to the second client so that, if the synchronized document information matches, the second client updates the third synchronized document through the document difference data; the third synchronized document is a document stored on the second client and whose content is consistent with the first synchronized document.
[0070] Eleventhly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0071] Obtain the document difference data sent by the first client, and match the document difference data by synchronizing document information;
[0072] If the synchronized document information matches, determine the synchronized document that is in the latest document state and matches the document difference data;
[0073] Update synchronized documents by document difference data, obtain updated synchronized documents, and update the document status of updated synchronized documents to the latest document status;
[0074] Broadcast document difference data to clients in the set of synchronous clients to which the first client belongs.
[0075] In a twelfth aspect, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0076] Obtain document difference data, which describes the data updated in the first synchronized document, and the document updated in the first synchronized document is the second synchronized document;
[0077] The matching third synchronized document is determined based on the document difference data; the third synchronized document is a document stored on the second client and whose content is consistent with the first synchronized document;
[0078] Extract the document difference content, the location of the difference content, and the context of the difference content from the document difference data, and locate the actual update location in the third synchronized document based on the location of the difference content and the context of the difference content.
[0079] The third synchronized document is updated based on the document differences at the actual update location, and the fourth synchronized document is obtained so that the document content of the fourth synchronized document is consistent with that of the second synchronized document.
[0080] In a thirteenth aspect, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0081] Retrieve synchronized document information with the second client;
[0082] In the event that the bidirectional communication connection is disconnected, in response to a document editing operation on the first synchronized document, the first synchronized document is updated to obtain the second synchronized document;
[0083] Determine the document difference data between the first synchronized document and the second synchronized document;
[0084] When the bidirectional communication connection is in a reconnection state, the document difference data is synchronized to the second client so that, if the synchronized document information matches, the second client updates the third synchronized document through the document difference data; the third synchronized document is a document stored on the second client and whose content is consistent with the first synchronized document.
[0085] In a sixteenth aspect, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0086] Obtain the document difference data sent by the first client, and match the document difference data by synchronizing document information;
[0087] If the synchronized document information matches, determine the synchronized document that is in the latest document state and matches the document difference data;
[0088] Update synchronized documents by document difference data, obtain updated synchronized documents, and update the document status of updated synchronized documents to the latest document status;
[0089] Broadcast document difference data to clients in the set of synchronous clients to which the first client belongs.
[0090] In a seventeenth aspect, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0091] Obtain document difference data, which describes the data updated in the first synchronized document, and the document updated in the first synchronized document is the second synchronized document;
[0092] The matching third synchronized document is determined based on the document difference data; the third synchronized document is a document stored on the second client and whose content is consistent with the first synchronized document;
[0093] Extract the document difference content, the location of the difference content, and the context of the difference content from the document difference data, and locate the actual update location in the third synchronized document based on the location of the difference content and the context of the difference content.
[0094] The third synchronized document is updated based on the document differences at the actual update location, and the fourth synchronized document is obtained so that the document content of the fourth synchronized document is consistent with that of the second synchronized document.
[0095] The aforementioned document editing synchronization method, apparatus, computer equipment, storage medium, and computer program product acquire synchronized document information with a second client. In the event of a disconnection of the bidirectional communication connection, in response to a document editing operation on a first synchronized document, the first synchronized document is updated to obtain a second synchronized document. Document difference data between the first and second synchronized documents is determined. If the bidirectional communication connection is reconnected, the document difference data is synchronized to the second client. This ensures that, if the synchronized document information matches, the second client updates a third synchronized document using the document difference data. The third synchronized document is stored on the second client and has content identical to the first synchronized document. Through this document editing synchronization method, since document editing on the first client takes effect locally immediately (i.e., even with a disconnected bidirectional communication connection), the feasibility of document editing on the first client is guaranteed, thus ensuring the reliability of document editing during network outages. Secondly, when the bidirectional communication connection is in a reconnection state, document synchronization is performed through document difference data. This means that it is not necessary to replace and update the entire document, but only to consider the difference data edited when the bidirectional communication connection is disconnected. This ensures more efficient and reliable updates of the edited difference data. In other words, after the network is disconnected and reconnected, asynchronous updates ensure that the second client updates the third synchronized document more reliably, thereby improving the reliability of document editing synchronization. Attached Figure Description
[0096] Figure 1 This is an application environment diagram of a document editing synchronization method in one embodiment;
[0097] Figure 2This is a flowchart illustrating a method for document editing synchronization applied to a first client in one embodiment;
[0098] Figure 3 This is a schematic diagram illustrating how a bidirectional communication server provides a bidirectional communication connection between a first client and a second client in one embodiment.
[0099] Figure 4 A schematic diagram illustrating the process of a bidirectional communication server providing a bidirectional communication connection between a first client and a second client in one embodiment;
[0100] Figure 5 This is a schematic diagram of the process of updating a first synchronized document to obtain a second synchronized document in one embodiment;
[0101] Figure 6 This is a flowchart illustrating a document editing synchronization method applied to a two-way communication server in one embodiment;
[0102] Figure 7 This is a flowchart illustrating a method for document editing synchronization applied to a second client in one embodiment;
[0103] Figure 8 This is a complete flowchart illustrating a document editing synchronization method in one embodiment;
[0104] Figure 9 This is a structural block diagram of a document editing synchronization device in one embodiment;
[0105] Figure 10 This is a structural block diagram of a document editing synchronization device in another embodiment;
[0106] Figure 11 This is a structural block diagram of the document editing synchronization device in another embodiment;
[0107] Figure 12 This is an internal structural diagram of a computer device in one embodiment;
[0108] Figure 13 This is a diagram of the internal structure of a computer device in another embodiment. Detailed Implementation
[0109] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0110] With the development of computer technology and terminal application technology, it is becoming increasingly common for different users to use different terminals to view and edit the same document. Therefore, document editing synchronization enables users to edit documents anytime, anywhere, and facilitates collaborative editing among multiple users, meeting the office needs of the internet age and thus gaining widespread application. Currently, users cannot access online documents offline; they are limited to editing local documents. This can lead to issues with synchronizing offline edits, meaning that the reliability of document editing synchronization is low after reconnecting to the network from an offline state. Therefore, improving the reliability of document editing synchronization is a pressing issue that needs to be addressed.
[0111] This application provides a method for improving the reliability of document editing synchronization. The document editing synchronization method provided in this application can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with bidirectional communication server 104 via a network. A data storage system can store the data that the bidirectional communication server 104 needs to process. The data storage system can be integrated onto the bidirectional communication server 104, or it can be located in the cloud or on another bidirectional communication server. Furthermore, in this embodiment, all clients are deployed on terminal 102. For example, if there are a first client and a second client with bidirectional communication connections, they are deployed on different terminals 102. Specifically, the bidirectional communication server 104 provides bidirectional communication connections for the first client and the second client.
[0112] Specifically, taking the document editing synchronization method applied to the first client as an example, the first client obtains synchronized document information with the second client. Then, in response to a document editing operation on the first synchronized document when the bidirectional communication connection is disconnected, the first synchronized document is updated to obtain the second synchronized document. The document difference data between the first and second synchronized documents is determined. Then, when the bidirectional communication connection is reconnected, the document difference data is synchronized to the second client. This ensures that, if the synchronized document information matches, the second client updates the third synchronized document using the document difference data. The third synchronized document is stored on the second client and has the same content as the first synchronized document. Thus, even when the bidirectional communication connection is disconnected, the feasibility of document editing by the first client is guaranteed, ensuring the reliability of document editing during network outages. Furthermore, when the bidirectional communication connection is reconnected, only the portion of the difference data edited when the bidirectional communication connection is disconnected is considered, ensuring more efficient and reliable updating of the edited difference data. In other words, after network reconnection, asynchronous updates ensure more reliable updates of the third synchronized document by the second client, thereby improving the reliability of document editing synchronization.
[0113] Similarly, taking the document editing synchronization method applied to a two-way communication server as an example, the two-way communication server obtains document difference data sent by the first client and matches it with synchronized document information. If the synchronized document information matches, the server determines the synchronized document with the latest document state that matches the document difference data, updates the synchronized document with the document difference data, obtains the updated synchronized document, updates the document state of the updated synchronized document to the latest document state, and broadcasts the document difference data to clients in the synchronization client set to which the first client belongs. Since the synchronized document update is based on the difference content when the two-way communication connection is in a reconnection state, synchronizing only the difference content reduces resource consumption and improves message processing efficiency. Furthermore, asynchronous updates ensure more reliable updates from the second client to the third synchronized document, thereby improving the efficiency and reliability of document editing synchronization.
[0114] Similarly, taking the document editing synchronization method applied to the second client as an example, the second client obtains document difference data, determines the matching third synchronized document based on the document difference data, then extracts the document difference content, the location of the difference content, and the difference content context from the document difference data, and locates the actual update position in the third synchronized document based on the difference content location and context. Finally, the third synchronized document is updated at the actual update position based on the document difference content to obtain the fourth synchronized document, so that the document content of the fourth synchronized document is consistent with that of the second synchronized document. Locating the update position with differences based on the difference content location and difference content context in the document difference data ensures the reliability of difference location, and then updating the difference content at the determined position further ensures that the correct difference content update adjustment is performed at a reliable difference position, thereby improving the reliability of document editing synchronization.
[0115] The terminal 102 can be, but is not limited to, various desktop computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, and smart in-vehicle devices. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted devices. The two-way communication server 104 can be implemented using a standalone two-way communication server or a cluster of multiple two-way communication servers. The document editing synchronization method provided in the application embodiment can be applied to various scenarios, including but not limited to offline document editing, online document editing, and document interaction.
[0116] The following examples illustrate this in detail: In one example, as... Figure 2 As shown, a method for document editing synchronization is provided, which can be applied to deployments on... Figure 1Taking the first client of terminal 102 as an example, a bidirectional communication connection exists between the first client and a second client deployed on another terminal. It is understood that this method can also be applied to a system including terminal 102 and bidirectional communication server 104, and implemented through the interaction between terminal 102 and bidirectional communication server 104. In this embodiment, the method includes the following steps:
[0117] Step 202: Obtain synchronized document information with the second client.
[0118] Synchronized document information describes the corresponding information synchronized between clients. Therefore, synchronized document information includes at least: document identifier, document synchronization content, and document version identifier. The document identifier uniquely identifies the document being synchronized. The document synchronization content characterizes the synchronized information within the document. For example, document synchronization content may include the document title and document body. In practical applications, document synchronization content may also include the participants in the document synchronization, such as a first object using the first client, a second object using the second client, etc.
[0119] The document version identifier is used to identify the version number of the document being synchronized. This identifier is maintained and updated by a two-way communication server, which provides a two-way communication connection between the first and second clients. Each document editing operation performed by a client causes the two-way communication server to update the document version identifier. Typically, the document version identifier is incremented once for each editing operation; for example, if the document version identifier is "001", then after one editing operation, the document version identifier will be updated to "002".
[0120] Specifically, the first client obtains the synchronized document information between itself and the second client, and the first client specifically obtains the synchronized document information broadcast by the bidirectional communication server. That is, the first client first sends a communication connection request to the monitoring port of the bidirectional communication server. The aforementioned communication connection request is used to request a bidirectional communication connection. Therefore, the monitoring port of the bidirectional communication server responds to the aforementioned communication connection request and adds the first client's first client identifier to the synchronized client set. The aforementioned synchronized client set includes a second client identifier used to identify the second client, and there is a bidirectional communication connection between the clients indicated by the client identifiers belonging to the synchronized client set. That is, if the synchronized client set includes a third client identifier used to identify the third client, then there is a bidirectional communication connection between the first client, the second client, and the third client.
[0121] Based on this, obtaining synchronized document information with the second client includes: obtaining synchronized document information broadcast by the bidirectional communication server based on the synchronized client set; the synchronized client set includes at least the client identifier of the second client, and there is a bidirectional communication connection between the clients belonging to the synchronized client set.
[0122] As described above, the synchronous client set includes at least the client identifier of the second client, and there is a bidirectional communication connection between clients belonging to the synchronous client set. Specifically, the bidirectional communication server stores the synchronous client set and provides bidirectional communication connections between clients identified by the client identifiers in the synchronous client set. After the client identifier of the first client is added to the synchronous client set, the bidirectional communication server broadcasts synchronous document information to the clients identified by the client identifiers belonging to the synchronous client set, enabling the first client to obtain the synchronous document information broadcast by the bidirectional communication server. At this time, the second client belonging to the synchronous client set can also obtain the synchronous document information. Furthermore, the synchronous document information broadcast by the bidirectional communication server can be synchronous or asynchronous with a small time difference; this is not limited here.
[0123] To facilitate understanding of the aforementioned steps, let's take the example of a two-way communication server providing a two-way communication connection between the first client and the second client. Figure 3 As shown, the bidirectional communication server 302 sends synchronization document information to the first client 304 and the second client 306 respectively via broadcast. Furthermore, as in the aforementioned example client, if the synchronization client set also includes a third client identifier for identifying a third client, then the third client can also obtain the synchronization document information. Here, there is no limitation on the client identifiers included in the synchronization client set; as long as they belong to the synchronization client set to which the first client belongs, other clients in the synchronization client set can obtain the same synchronization document information, ensuring the consistency of information synchronization.
[0124] In practical applications, the prerequisite for the first client to respond to document editing operations on the first synchronized document is that the first client needs to support document editing. This means the first client needs to create front-end code to support document editing operations, essentially creating a text editor. In this embodiment, HyperText Markup Language (HTML) and JavaScript are used. In practice, there exists code for a text editor that supports document editing operations, such as HTML code. The HTML code defines the text editor. After the synchronized document's page loads, the text editor created by the HTML code sends a bidirectional communication connection request to the bidirectional communication server and sets up an event monitor for the text editing operation. Whenever the user inputs in the text area, that is, when the event monitor detects a document editing operation, it encapsulates the document difference data obtained in subsequent steps into a message and sends it to the bidirectional communication server. Similarly, if the second client also has similar text editing operations and obtains document difference data, the first client can also detect the message carrying the document difference data received from the bidirectional communication server through the event monitor and update the document content using the document difference data, that is, synchronously update the document content in the text area of the text editor.
[0125] Step 204: In the event that the bidirectional communication connection is disconnected, in response to a document editing operation on the first synchronized document, the first synchronized document is updated to obtain the second synchronized document.
[0126] The phrase "disconnecting the bidirectional communication connection" describes the disconnection of the network connection between the first client and the bidirectional communication server. This means the first client is offline (i.e., has no network connection). Therefore, without a bidirectional communication connection, the first client cannot interact with the bidirectional communication server, and thus cannot communicate bidirectionally with the second client through the server. Secondly, the document editing operation specifically refers to the editing operation of the document content of the first synchronized document initiated by the document operation object. This document editing operation can be a document content deletion operation, a document content replacement operation, a document content input operation, etc. In other words, the document editing operation has an indicated editing operation type. For example, if the document editing operation is a document content deletion operation, then the indicated editing operation type is the document content deletion type. This means that the document operation object is deleting document content. The document editing operation can also carry the position of the deleted document content within the document, as well as the specific deleted document content.
[0127] Similarly, if a document editing operation is a document content replacement operation, then the indicated editing operation type is a document content replacement type. This means the document operation object is replacing document content. In this case, the document editing operation can also carry the position of the replaced document content within the document, the original document content, and the new document content. Likewise, if a document editing operation is a document content input operation, then the indicated editing operation type is a document content input type. This means the document operation object is inputting document content. In this case, the document editing operation can also carry the position of the input document content within the document, as well as the input document content itself. Since various editing methods can be used in practical applications, specific document editing operations and their types are not limited here.
[0128] Specifically, when the bidirectional communication connection is disconnected, meaning the first client cannot interact with the bidirectional communication server, the first client and the second client cannot communicate bidirectionally through the server. In this case, in response to a document editing operation on the first synchronized document, the first synchronized document is updated to obtain the second synchronized document. That is, in this embodiment, disconnecting the bidirectional communication connection does not affect document editing operations on the first synchronized document that needs to be synchronized. Therefore, when using the first client's document operation object to initiate a document editing operation on the document content of the first synchronized document, the first client can respond to the document editing operation and update the document content of the first synchronized document to obtain the second synchronized document.
[0129] To facilitate understanding, let's take the document content of the first synchronized document as "1234567" as an example. If the document editing operation is a document content deletion operation, then the document content deletion operation indicates the document content deletion type, which means that the content to be deleted is "1234567". If the document content deletion operation specifically deletes the document content "67", then the document content replacement operation specifically deletes the document content "67" from the document content "1234567" of the first synchronized document. Thus, the document content of the first synchronized document is updated, and the document content of the resulting second synchronized document is "12345".
[0130] Similarly, if the document editing operation is a document content replacement operation, then the document content replacement operation indicates the document content replacement type. That is, the content replacement is performed on the document content "1234567". If the document content replacement operation specifically replaces the document content "45" with "89", then the document content replacement operation specifically replaces part of the document content "45" in the document content "1234567" of the first synchronized document with another document content "89". Thus, the document content of the first synchronized document is updated, and the document content of the second synchronized document is "1238967".
[0131] Similarly, if the document editing operation is a document content input operation, then the document content input operation indicates the document content input type. This means that content is being input for the document content "1234567". The input can be placed at the last character or in the middle of the document content. If the document content input operation specifically enters "89", and it is entered directly after the document content, then the document content replacement operation specifically enters "89" after the document content "1234567" in the first synchronized document. This updates the document content of the first synchronized document, resulting in the document content of the second synchronized document being "123456789". Alternatively, the document content replacement operation specifically enters "89" between "45" and "67" in the document content "1234567" of the first synchronized document. This updates the document content of the first synchronized document, resulting in the document content of the second synchronized document being "123458967".
[0132] Step 206: Determine the document difference data between the first synchronized document and the second synchronized document.
[0133] The document difference data includes at least: document difference content, difference content location, and difference context content. The aforementioned document difference content describes the differences between the document content of the first synchronized document and the document content of the second synchronized document. The aforementioned difference content location describes the position of the document difference content within the document. It is understood that, considering the possibility of similar positions or identical content descriptions within the document, this embodiment also considers difference context content, which describes the preceding and following document content adjacent to the document difference content.
[0134] Specifically, the first client determines the document difference data between the first synchronized document and the second synchronized document. This means the first client compares the document content of the first synchronized document with the document content of the second synchronized document to determine the differences between them. Based on this, the client identifies the document difference content within the document difference data. After determining the document difference content, the client can also locate the position of the document difference content within the first synchronized document, as well as the preceding and following document content adjacent to it. Therefore, the document difference data includes at least: the document difference content, the position of the difference content, and the difference context. For ease of understanding, let's take the example above where the document content of the first synchronized document is "1234567" and the document content of the second synchronized document is "12345". In this case, the document difference content is specifically "67".
[0135] Furthermore, the first client can also determine the location of the differences between the first and second synchronized documents. That is, after determining the differences, the first client then determines the position of those differences within the first synchronized document. To facilitate understanding of the location of the differences, let's take the example above where the content of the first synchronized document is "1234567" and the content of the second synchronized document is "1238967". In this case, the specific difference is that "45" is replaced with "89", and the difference is located at the 4th and 5th characters in the first synchronized document.
[0136] Similarly, considering the possibility of similar positions or identical content descriptions within the documents, the first client can further determine the difference context between the first and second synchronized documents. That is, after determining the document difference content, the first client then determines the preceding and following document content adjacent to the difference content within the document. To facilitate understanding of the difference context, let's again use the example above where the first synchronized document content is "1234567" and the second synchronized document content is "1238967". In this case, the document difference content is "45" replaced with "89". The difference content is located at the 4th and 5th characters in the first synchronized document. The difference context content is the preceding document content "123" adjacent to the replaced content "45", and the following document content "67" adjacent to the replaced content "45". In other words, the difference context content determines that the replaced content "45" is located between document content "123" and document content "67".
[0137] In other words, by identifying the document differences between the first and second synchronized documents, it ensures that subsequent document content updates are based solely on these differences. This means that only the adjusted and changed parts of the difference data need to be synchronized, thereby improving the synchronization efficiency of documents while reducing the amount of data transmitted.
[0138] In practical applications, identifying document differences between the first and second synchronized documents can be achieved using a difference comparison algorithm, such as the Myers difference algorithm. Alternatively, it can be based on the diff-match-patch library. This embodiment uses the diff-match-patch library to calculate the document differences between the first and second synchronized documents. The diff-match-patch library can be used in Node.js projects and browsers. The following describes how the first client uses the diff-match-patch library to compare the differences between the first and second synchronized documents to determine document difference data. For example, using the diff-match-patch library to calculate document difference data between the first and second synchronized documents does not directly identify the modified content in the second synchronized document. Instead, it compares the document content of the first and second synchronized documents using "diff_main()" to automatically identify the document difference content. Based on the document difference content, it further determines the location and context of the difference content, thereby generating a difference patch (i.e., document difference data in this embodiment). This ensures that the document difference data includes not only the document difference content but also the location and context of the difference content, thus ensuring more accurate location of the text editing difference content on the bidirectional communication server and other clients.
[0139] Step 208: When the bidirectional communication connection is in a reconnection state, the document difference data is synchronized to the second client so that, if the synchronized document information matches, the second client updates the third synchronized document through the document difference data; the third synchronized document is a document stored on the second client and whose content is consistent with the first synchronized document.
[0140] As described above, disconnecting the bidirectional communication connection describes the disconnection of the network connection between the first client and the bidirectional communication server. The reconnection state means that the network connection between the first client and the bidirectional communication server is restored after the disconnection state. Therefore, the first client is online (i.e., has a network connection). When the bidirectional communication connection is in the reconnection state, the first client can re-interact with the bidirectional communication server, that is, the first client can conduct bidirectional communication with the second client through the bidirectional communication server.
[0141] Secondly, the third synchronized document is a document stored on the second client that has the same content as the first synchronized document. In other words, it's the synchronized document that is synchronized between the first and second clients when a two-way communication connection exists. Specifically, it includes the first synchronized document on the first client and the third synchronized document on the second client. It can be understood that the content of the first and third synchronized documents can be the synchronized content of the documents when synchronizing document information between the first and second clients. Alternatively, it can be the document content synchronized when a two-way communication connection exists; the specific content of the first and third synchronized documents is not limited here.
[0142] Specifically, since disconnecting the bidirectional communication connection does not affect the editing of the first synchronized document that needs to be synchronized, to ensure document synchronization between different clients while the first client can communicate bidirectionally with the second client through the bidirectional communication server, the first client synchronizes document difference data to the second client. During the process of synchronizing document difference data to the second client, the first client also sends the synchronization document information corresponding to the first synchronized document back to the bidirectional communication server. At this time, the bidirectional communication server needs to match the synchronization document information of the first client (i.e., the synchronization document information corresponding to the first synchronized document) with the synchronization document information broadcast to the second client by the bidirectional communication server. If the information matching result of the synchronization document information is consistent, the bidirectional communication server broadcasts the document difference data so that the second client can update the third synchronized document through the document difference data. That is, the second client locates the actual update position in the third synchronized document based on the position of the difference content and the context of the difference content, and updates the third synchronized document based on the document difference content at the actual update position, so as to ensure that the offline editing changes of the first synchronized document can be synchronized to the second client, ensuring the synchronization of document content between the first client and the second client.
[0143] Considering that synchronized document information includes at least: document identifier, document synchronized content, and document version identifier, the synchronized document information of the first client is matched with the synchronized document information broadcast by the bidirectional communication server to the second client. Given that the document synchronized content of the first client has been modified, it is necessary to match the document identifier and document version identifier of the synchronized document. This means determining whether the document identifier corresponding to the first synchronized document matches the document identifier broadcast by the bidirectional communication server, thus confirming whether the first synchronized document and the synchronized document locally stored on the bidirectional communication server are the documents being synchronized. Then, the document version identifier corresponding to the first synchronized document is matched with the document version identifier broadcast by the bidirectional communication server. Considering that each document editing operation performed by the client will cause the bidirectional communication server to update the document version identifier, the consistency of the document version identifier determines whether it is the initial document (without document editing operations) or a document after multiple identical document editing operations. This ensures that the third synchronized document updated by the second client based on document difference data is completely consistent with the document content of the first synchronized document.
[0144] Understandably, in practical applications, there may be situations where the information matching results of synchronized document information are inconsistent. That is, when multiple users are simultaneously editing the same remote file, information matching through synchronized document information can effectively avoid editing conflicts and ensure file consistency and integrity. The following describes the steps for handling this situation:
[0145] In an optional embodiment, the document editing synchronization method further includes: obtaining a conflict notification if the synchronized document information is inconsistent; the conflict notification describes that the document version identifier in the synchronized document information is inconsistent with the document version identifier broadcast by the bidirectional communication server; and sending a version retrieval request to the bidirectional communication server to retrieve the latest document version identifier from the bidirectional communication server.
[0146] As described above, the synchronization of document information involves at least matching the document version identifiers of the first and third synchronized documents. If the synchronization of document information is inconsistent, it means that the document version identifier in the synchronized document information is inconsistent with the document version identifier broadcast by the bidirectional communication server. Therefore, the conflict notification can be used to describe that the document version identifier in the synchronized document information is inconsistent with the document version identifier broadcast by the bidirectional communication server.
[0147] Secondly, as can be seen from the foregoing, the document identifier corresponding to the first synchronized document and the document identifier broadcast by the two-way communication server can also be matched. The situation where the synchronized document information is inconsistent can also be that the document identifier in the synchronized document information is inconsistent with the document identifier broadcast by the two-way communication server. Therefore, the conflict notification can be used to describe that the document identifier in the synchronized document information is inconsistent with the document identifier broadcast by the two-way communication server.
[0148] Specifically, if the two-way communication server determines that the synchronized document information is inconsistent, it will send a conflict notification to the first client. The first client receives the conflict notification and uses it to confirm that the document version identifier in the synchronized document information is inconsistent with the document version identifier broadcast by the two-way communication server. This means that while the first client is disconnecting the two-way communication connection, other clients with communication connections to the two-way communication server may have also performed document editing operations and completed synchronization. In this case, the two-way communication server updates the document content and synchronizes the updated document version identifier. Then, the two-way communication server broadcasts the latest document version identifier. However, because the first client has disconnected the two-way communication connection... Therefore, the first client cannot obtain the latest document version identifier, resulting in a mismatch between the document version identifier sent by the first client after reconnection and the latest document version identifier broadcast by the two-way communication server. Thus, in order for the first client to synchronize text content with other clients, it needs to send a version retrieval request to the two-way communication server, prompting the server to send the latest document version identifier to the first client. At this time, the server can also send document difference data edited by other clients to the first client. The first client can then update the document and re-determine the document difference data. The newly obtained latest document version identifier will then match the latest document version identifier broadcast by the two-way communication server. The re-determined document difference data can then be synchronized to the second client to ensure the reliability and accuracy of document data synchronization.
[0149] In practical applications, the bidirectional communication server needs to maintain document version identifiers for synchronized document files and update these identifiers each time a synchronized document is edited. Therefore, clients using bidirectional communication also need to send the document version identifiers for the modified document when sending document difference data. The bidirectional communication server compares the document version identifiers returned by the client with the server's current document version identifier (i.e., the latest broadcast document version identifier). If they are inconsistent, a conflict has occurred. The bidirectional communication server can refuse to modify older document version identifiers, or it can merge updates of different document version identifiers (this will not be discussed further here). Therefore, during synchronized document editing, the corresponding document version identifiers can also be updated synchronously, ensuring that the synchronized document indicated by the document version identifier is the edited and updated document. This avoids inconsistencies caused by editing without updating the document version identifier, thus guaranteeing document synchronization consistency.
[0150] For ease of understanding, in a practical application, the bidirectional communication server adds a `fileVersion` variable to the code related to the conflict resolution mechanism to locate the version number (i.e., document version identifier) of the synchronized document. Each time a client sends document difference data, it also needs to send the document version identifier. The bidirectional communication server checks if this document version identifier matches the latest document version identifier broadcast by the server. If they don't match, the server sends a conflict notification to the client. If the version numbers match, the server applies the document difference data, updates the synchronized document locally, updates the matching document version identifier, and broadcasts the updated identifier and document difference data to all clients.
[0151] For the client, in a practical application like a two-way communication server's code for resolving editing conflicts, a `localFileVersion` variable is added to locate the version number (i.e., document version identifier) of the locally synchronized document. Each time document difference data is sent to the two-way communication server, the client also sends the version number of the locally synchronized document. If the client receives a conflict notification from the two-way communication server, it needs to handle the conflict, for example, by providing a prompt object or reloading the document (i.e., the two-way communication server sends a version retrieval request to obtain the latest document version identifier). If the client directly receives both the document difference data and the latest document version identifier, the client will apply the document difference data to update the locally synchronized document and update the document version identifier (i.e., update it to the latest document version identifier). This method prevents the client from editing inconsistent file versions; that is, by matching the information in the synchronized document, editing conflicts can be effectively avoided, ensuring file consistency and integrity.
[0152] It is understandable that since the inconsistency in the synchronized document information can also be due to the document identifier in the synchronized document information being inconsistent with the document identifier broadcast by the two-way communication server, the conflict notification can be used to describe the inconsistency between the document identifier in the synchronized document information and the document identifier broadcast by the two-way communication server. At this point, the two-way communication server determines that the document identifier in the synchronized document information is inconsistent with the document identifier broadcast by the two-way communication server. Therefore, the two-way communication server sends a conflict notification to the first client. The first client receives the conflict notification and, through it, determines that the document identifier in the synchronized document information is inconsistent with the document identifier broadcast by the two-way communication server. This means that there may be issues such as data loss during communication transmission of the document identifier broadcast by the two-way communication server, resulting in a mismatch between the document identifier sent by the first client after reconnection and the document identifier broadcast by the two-way communication server. Therefore, in order for the first client to be able to identify with other clients as synchronizing and editing the same document, the first client needs to send an identifier retrieval request to the two-way communication server. This allows the two-way communication server to resend the document identifier to the first client, and then the first client can update the document identifier. Based on the updated document identifier, a matching process can be performed to synchronize the document difference data to the second client, ensuring the reliability and accuracy of document data synchronization.
[0153] As described above, document editing operations have indicated editing operation types. These operation types provide a clearer and more accurate understanding of the document editing method, allowing other clients to update documents more efficiently based on document differences and operation types. This will be discussed in more detail below:
[0154] In an optional embodiment, the document editing synchronization method further includes: determining the type of editing operation indicated by the document editing operation. Specifically, the document editing operation is an editing operation on the document content of the first synchronized document initiated by the document operation object. The document editing operation can be a document content deletion operation, a document content replacement operation, a document content input operation, etc., meaning the document editing operation has an indicated editing operation type. Therefore, the first client can determine the type of editing operation indicated by the document editing operation.
[0155] For example, if the document editing operation is a document content deletion operation, then the indicated editing operation type is the document content deletion type. For ease of understanding, the following is an example of the code for a document content deletion operation:
[0156] **Document content deletion operation**
[0157] ```javascript
[0158] const deleteChange = {
[0159] type: 'DELETE',
[0160] position: { start: 0, end: 5},
[0161] content: {
[0162] oldText: "12345",
[0163] newText: ""
[0164] }
[0165] };
[0166] Similarly, if a document editing operation is a document content replacement operation, then the indicated editing operation type is the document content replacement type. For ease of understanding, the following is an example of code for a document content replacement operation:
[0167] **Document content replacement operation**
[0168] ```javascript
[0169] const replaceChange = {
[0170] type: 'REPLACE',
[0171] position: { start: 1, end: 4},
[0172] content: {
[0173] oldText: "234",
[0174] newText: "111"
[0175] }
[0176] };
[0177] Similarly, document editing operations are document content input operations. Since document content replacement operations can also insert document content into the document content, we can define document content input operations as document content insertion operations here. For ease of understanding, the following is an example of the code for a document content insertion operation:
[0178] **Document Content Insertion Operation**
[0179] ```javascript
[0180] const insertChange = {
[0181] type: 'INSERT',
[0182] position: { start: 5, end: 5},
[0183] content: {
[0184] oldText: "",
[0185] newText: "6789"
[0186] }
[0187] };
[0188] Based on this, document difference data is synchronized to the second client, including: synchronizing document difference data and editing operation types to the second client; wherein, if the synchronized document information matches, the second client updates the third synchronized document using the document difference data and editing operation types.
[0189] Specifically, when the first client can communicate bidirectionally with the second client through the bidirectional communication server, the first client synchronizes document difference data and editing operation types to the second client. During this synchronization, the bidirectional communication server matches the synchronized document information from the first client with the synchronized document information broadcast from the server to the second client. If the matching result is consistent, the bidirectional communication server broadcasts the document difference data and editing operation types, enabling the second client to update the third synchronized document using these data. In other words, the second client locates the actual update position in the third synchronized document based on the difference content location, context, and editing operation type, and updates the document at that position based on the document difference content. This ensures that offline editing changes to the first synchronized document are synchronized to the second client, guaranteeing document content synchronization between the first and second clients. The method by which the second client updates the third synchronized document is described in detail in subsequent embodiments and is not limited here.
[0190] In practical applications, without disconnecting the bidirectional communication connection, a similar approach can be used to update the first synchronized document in response to a document editing operation on the first synchronized document, resulting in a second synchronized document. The document difference data between the first and second synchronized documents is then determined, and this difference data is synchronized to the second client. This allows the second client to update the third synchronized document based on the document difference data, provided the synchronized document information matches. Further details are omitted here. It is understood that the examples in this application are for understanding the solution but should not be construed as limiting the solution.
[0191] In the above-described document editing synchronization method, since document editing on the first client takes effect locally immediately, even when the bidirectional communication connection is disconnected, the feasibility of document editing on the first client is guaranteed, thus ensuring the reliability of document editing during network outages. Secondly, when the bidirectional communication connection is reconnected, document synchronization is performed using document difference data. This means that instead of replacing and updating the entire document, only the difference data edited when the bidirectional communication connection was disconnected is considered. This ensures more efficient and reliable updates to the edited difference data. In other words, after network reconnection, asynchronous updates ensure more reliable updates of the third synchronized document by the second client, thereby improving the reliability of document editing synchronization.
[0192] As can be seen from the foregoing embodiments, since there is a bidirectional communication connection between the first client and the second client, and the bidirectional communication server provides this bidirectional communication connection for the first client and the second client, how to provide bidirectional communication connections for different clients through the bidirectional communication server is described in detail below: In one embodiment, such as Figure 4 As shown, other methods for synchronizing document editing include:
[0193] Step 402: Send a communication connection request to the monitoring port of the bidirectional communication server so that the monitoring port adds the first client identifier of the first client to the synchronous client set; the synchronous client set includes at least the second client identifier of the second client, and there is a bidirectional communication connection between the clients indicated by the client identifiers belonging to the synchronous client set.
[0194] The synchronous client set includes at least the second client identifier of the second client, and the clients indicated by the client identifiers belonging to the synchronous client set have bidirectional communication connections. That is, if the synchronous client set includes a third client identifier used to identify the third client, then there are bidirectional communication connections between the first client, the second client, and the third client. Based on this, the communication connection request includes the first client identifier of the first client.
[0195] Specifically, the two-way communication server stores a set of synchronized clients and provides two-way communication connections between clients identified by client identifiers in the synchronized client set. When the first client sends a communication connection request to the monitoring port of the two-way communication server, the monitoring port of the two-way communication server responds to the communication connection request, extracts the first client identifier of the first client from the communication connection request, and then adds the first client identifier of the first client to the synchronized client set, so that the two-way communication server will provide two-way communication connection services to the clients identified by client identifiers belonging to the synchronized client set.
[0196] In practical applications, the prerequisite for a bidirectional communication server to provide bidirectional communication connections to clients is the ability to store and forward messages. In this embodiment, JavaScript and Node.js are used to create the bidirectional communication server. The server can receive messages and data from clients and broadcast them to the client identified by the client identifier belonging to the synchronous client set. The server can also receive messages and data from other sources (such as other bidirectional communication servers) and broadcast them to the client identified by the client identifier belonging to the synchronous client set. For ease of understanding, the code for a bidirectional communication server in a practical application can be used to create the server. The server monitors messages through port 8080; that is, port 8080 is the monitoring port. Therefore, whenever a client sends a communication connection request to the bidirectional communication server, port 8080 (the monitoring port) will detect the request and add the client identifier extracted from the request to the synchronous client set (the clients set). Therefore, the bidirectional communication server monitors messages and data sent by each client through port 8080 and broadcasts these messages and data to the client identified by the client identifier belonging to the synchronization client set. Furthermore, the bidirectional communication server adjusts the locally stored synchronization documents based on the update information indicated by the received messages and data to ensure document synchronization between clients and between clients and the bidirectional communication server.
[0197] Furthermore, it is understandable that when a client loses communication with the bidirectional communication server, the server will remove the client identifier corresponding to the disconnected client from the synchronous client set to prevent broadcast data from being sent to clients without a communication connection. Conversely, when the client restores communication with the server, the client will resend a communication connection request to the server's monitoring port. At this point, the server will add the client identifier back to the synchronous client set to ensure that subsequent broadcast data and information can be reliably sent to the reconnected client.
[0198] Based on this, step 208, when the bidirectional communication connection is in a reconnection state, synchronizes the document difference data to the second client, including:
[0199] Step 404: When the bidirectional communication connection is in a reconnection state, send document difference data to the bidirectional communication server so that the bidirectional communication server broadcasts the document difference data to the client indicated by the client identifier in the synchronization client set, so as to synchronize the document difference data to the second client.
[0200] Specifically, since disconnecting the bidirectional communication connection does not affect the document editing operation of the first synchronized document that needs to be synchronized, in order to ensure that document synchronization between different clients can still be guaranteed even when the first client can communicate bidirectionally with the second client through the bidirectional communication server, the first client sends document difference data to the bidirectional communication server. Then, the bidirectional communication server matches the synchronized document information of the first client with the synchronized document information broadcast to the second client by the bidirectional communication server. If the information matching result of the synchronized document information is consistent, the bidirectional communication server broadcasts the document difference data to the client indicated by the client identifier in the synchronized client set, so as to synchronize the document difference data to the second client.
[0201] It is understandable that if the synchronization client set includes a third client identifier, then there is a bidirectional communication connection between the first, second, and third clients. Document difference data broadcast by the bidirectional communication server can also be synchronized to the third client. Furthermore, as described above, the first client can also synchronize document difference data and editing operation types to the second client. That is, the first client sends document difference data and editing operation types to the bidirectional communication server, which then broadcasts the document difference data and editing operation types to the client indicated by the client identifier in the synchronization client set, thereby synchronizing the document difference data and editing operation types to the second client.
[0202] Considering the impact of network latency on the experience of synchronized objects, by optimizing network communication and local caching strategies, a smooth file operation experience can be guaranteed even under poor network conditions. This is described below: In an optional embodiment, the document editing synchronization method further includes: storing the second synchronized document and document difference data in local storage, and displaying the document content of the second synchronized document on the display interface.
[0203] Specifically, the first client stores the second synchronized document and its differences in local storage, and then displays the content of the second synchronized document on the display interface. In other words, local operations on the first client take priority. That is, when an object initiates a document editing operation on the first synchronized document on the first client, the second synchronized document and its differences in local storage will be stored first on the first client, and then the content of the second synchronized document will be displayed on the display interface. This ensures that the first client applies the changes more accurately and efficiently.
[0204] In other words, even without a two-way communication connection, in response to a document editing operation on the first synchronized document, after updating the first synchronized document to obtain the second synchronized document and determining the document difference data between the first synchronized document and the second synchronized document, the first client stores the second synchronized document and the document difference data in local storage and displays the document content of the second synchronized document on the display interface.
[0205] Based on this, when the bidirectional communication connection is in a reconnection state, sending document difference data to the bidirectional communication server includes: retrieving document difference data from local storage and sending the document difference data to the bidirectional communication server when the bidirectional communication connection is in a reconnection state.
[0206] Specifically, when the bidirectional communication connection is in a reconnection state, the first client retrieves the document difference data from local storage and sends the document difference data to the bidirectional communication server.
[0207] It is understandable that if the first client caches the second synchronized document locally, it can continue to synchronize and edit even when the bidirectional communication connection is disconnected. This means that the first client can further edit the second synchronized document until the bidirectional communication connection is reconnected. At this point, the first client will determine the latest stored local synchronized document and send all document difference data of the latest stored local synchronized document to the bidirectional communication server, so that the bidirectional communication server can synchronize all document difference data of the latest stored local synchronized document to other clients.
[0208] It is understood that the corresponding examples in the embodiments of this application are used to understand this solution, but should not be construed as specific limitations on this solution.
[0209] In this embodiment, a bidirectional communication server ensures document synchronization between clients and between clients and the bidirectional communication server. This ensures that network latency and disconnection can be handled, and that when multiple objects are editing, in addition to ensuring local synchronized document editing, the consistency of document content in synchronized documents can be maintained during collaborative editing, thereby improving the reliability and consistency of document synchronization.
[0210] In one embodiment, such as Figure 5 As shown, in response to a document editing operation on the first synchronized document, updating the first synchronized document to obtain the second synchronized document includes:
[0211] Step 502: In response to a document editing operation on the first synchronized document, determine the content of the document editing operation on the first synchronized document.
[0212] Specifically, the first client responds to a document editing operation on the first synchronized document and determines the edited content of the document. That is, after detecting a document editing operation on the first synchronized document, the first client first responds to the operation, then performs content detection to determine the edited content. For ease of understanding, let's take the document content of the first synchronized document as "1234567" as an example. If the document editing operation is a document content input operation, content detection is performed on the input content. If the input content is "89", the edited content of the first synchronized document is determined to be "89". Alternatively, if the document editing operation is a document content deletion operation, content detection is performed on the input content. If the deleted content is "67", the edited content of the first synchronized document is determined to be "67".
[0213] Step 504: If the edited content meets the update strategy, update the first synchronized document based on the edited content to obtain the second synchronized document.
[0214] The update strategy is any one of the following: the length of the edited content reaches a content length threshold, or the input duration of the edited content reaches an input duration threshold, or semantic units are present in the edited content. Specifically, the first client determines whether the edited content meets the update strategy. If it does, the first synchronized document is updated based on the edited content to obtain the second synchronized document. If it does not meet the strategy, the edited content is further identified until the obtained edited content meets the update strategy. Based on the edited content that meets the update strategy, the first synchronized document is updated to obtain the second synchronized document. As can be seen from the foregoing, the update strategy has multiple judgment dimensions, which are described below:
[0215] In one optional embodiment, the document editing synchronization method further includes: determining the content length of the edited content. The aforementioned content scenario refers to the number of characters in the edited content. Specifically, the first client performs character recognition on the edited content and determines the number of recognized characters as the content length of the edited content. For example, if the edited content of the first synchronized document is "67", containing the characters "6" and "7", the content length of the edited content is 2.
[0216] Based on this, the edited content meets the update strategy, including: when the content length reaches the content length threshold, it is determined that the edited content meets the update strategy.
[0217] Specifically, the update strategy at this point is based on the content length of the edited content reaching a content length threshold. This content length threshold is determined based on actual input requirements; it can be 3, 5, etc., without limitation. Specifically, the first client determines whether the content length of the edited content reaches the content length threshold. If yes, it determines that the edited content meets the update strategy. If not, it continues to identify the edited content, further identifying the number of characters included in the edited content, until the content length reaches the content length threshold. For example, if the content length threshold is 3, and the edited content of the first synchronized document is "67", then the content length is 2, meaning the content length has not reached the content length threshold, and further identification of the edited content is required. If the edited content is "567", then the content length is 3, meaning the content length has reached the content length threshold. At this point, it is determined that the edited content meets the update strategy, and the first synchronized document is updated using the aforementioned edited content to obtain the second synchronized document.
[0218] In one optional embodiment, the document editing synchronization method further includes: determining the previous update timestamp of the document update and determining the last timestamp of the input of the edited content; obtaining the input duration composed of the previous update timestamp and the last timestamp. Specifically, the first client determines the previous update timestamp of the document update and determines the last timestamp of the input of the edited content, and then determines the time interval composed of the previous update timestamp and the last timestamp as the input duration.
[0219] Based on this, the edited content meets the update strategy, including: when the input duration reaches the input duration threshold, it is determined that the edited content meets the update strategy.
[0220] Specifically, the update strategy at this point is that the input duration of the edited content reaches the input duration threshold, and the input duration threshold is determined based on the actual input requirements. That is, the content length threshold can be 3 seconds, 5 seconds, or 10 seconds, etc., without limitation here. Specifically, the first client determines whether the input duration of the edited content reaches the input duration threshold. If yes, it determines that the edited content meets the update strategy. If not, it continues to identify the edited content and then determines the last timestamp of the edited content input, until the input duration formed by the previous update timestamp and the last timestamp reaches the input duration threshold.
[0221] In an optional embodiment, the document editing synchronization method further includes: performing unit identification on the edited content and obtaining unit identification results. Specifically, the first client performs unit identification on the edited content and obtains unit identification results. Specifically, the first client performs semantic unit identification on the edited content, and the obtained unit identification results specifically describe whether semantic units exist in the edited content. The aforementioned semantic units are used for semantic analysis, and the object of analysis is an aggregate structure, meaning that semantic units are typically text units such as periods, carriage returns, commas, and pauses that do not describe any text semantics.
[0222] Based on this, the edited content satisfies the update strategy, including: when the unit identification result represents the existence of semantic units, it is determined that the edited content satisfies the update strategy.
[0223] Specifically, the update strategy at this point is based on the presence of semantic units in the edited content. Specifically, the first client determines whether semantic units exist in the edited content based on the unit recognition results. If so, it confirms the presence of semantic units as indicated by the unit recognition results, thus determining that the edited content meets the update strategy. That is, the presence of semantic units such as periods, carriage returns, commas, and pauses typically indicates that the input object has completed the input of a partial paragraph or part of the text, at which point the update strategy can be determined to be satisfied. If not, the process continues to identify semantic units in the edited content until semantic units are found.
[0224] As described above, whether the edited content meets the update strategy can be determined by: whether the content length reaches the content length threshold, whether the input time reaches the input time threshold, and whether semantic units exist in the edited content. In practical applications, the input content can also be compared with the document content for similarity. If the similarity comparison result is less than the similarity threshold, it indicates that the input content has changed significantly, and thus the edited content meets the update strategy. It is understood that the examples in this application are for understanding the solution and should not be construed as specific limitations of the solution.
[0225] In this embodiment, the editing content of the first synchronized document is first determined to ensure real-time identification and acquisition of the editing content. Then, by judging whether the editing content meets the update strategy, the first synchronized document is updated based on the editing content to obtain the second synchronized document if the editing content meets the update strategy. This avoids wasting resources due to partial input and ensures the reliability of the update, thereby ensuring the reliability of document editing synchronization.
[0226] The following describes how a two-way communication server synchronizes document editing based on document discrepancies, illustrated by the following embodiment: In one embodiment, as follows... Figure 6As shown, a method for document editing synchronization is provided, which can be applied to deployments on... Figure 1 Taking the bidirectional communication server 104 as an example, the bidirectional communication server 104 specifically provides a bidirectional communication connection between the first client and the second client. It is understood that this method can also be applied to a system including a terminal 102 and a bidirectional communication server 104, and implemented through the interaction between the terminal 102 and the bidirectional communication server 104. In this embodiment, the method includes the following steps:
[0227] Step 602: Obtain the document difference data sent by the first client, and match the document difference data by synchronizing document information.
[0228] The document difference data includes at least: document difference content, difference content location, and difference context content. The aforementioned document difference content describes the differences between the first synchronized document and the second synchronized document. The aforementioned difference content location describes the position of the document difference content within the document. The aforementioned difference context content describes the preceding and following document content adjacent to the document difference content within the document. Furthermore, the document difference data specifically refers to the document difference data determined by the first client after responding to a document editing operation on the first synchronized document and updating it to obtain the second synchronized document, by comparing the document content of the first synchronized document and the document content of the second synchronized document.
[0229] Specifically, the bidirectional communication server obtains the document difference data sent by the first client. The basis for this is that a communication connection exists between the first client and the bidirectional communication server. That is, the bidirectional communication server obtains the document difference data sent by the first client when a communication connection exists between them. The document difference data is obtained by the first client comparing the content of the first synchronized document with the content of the second synchronized document. Therefore, when the first client determines the document difference data, the bidirectional communication server can maintain a communication connection with the first client or disconnect from it. In other words, the timing of the document difference data determination in this embodiment is not limited, nor is it limited whether a communication connection exists between the first client and the bidirectional communication server when the first client determines the document difference data. Furthermore, as can be seen from the foregoing embodiments, the first client can also determine the type of editing operation indicated by the document editing operation. That is, the first client can also send the document difference data and the editing operation type to the bidirectional communication server, allowing the bidirectional communication server to obtain the document difference data and the editing operation type.
[0230] Furthermore, as can be seen from the foregoing embodiments, during the process of the first client sending document difference data to the bidirectional communication server, the first client also sends back the synchronization document information corresponding to the first synchronized document to the bidirectional communication server. This synchronization document information describes the corresponding information for synchronization between the clients. Therefore, the synchronization document information includes at least: a document identifier, document synchronization content, and a document version identifier. The document identifier is used to uniquely identify the document being synchronized. The document synchronization content is used to characterize the synchronized information in the document, and the document version identifier is used to identify the version number of the document being synchronized. The document version identifier is specifically maintained and updated by the bidirectional communication server.
[0231] Therefore, it can be seen that by matching the synchronized document information of the first client (i.e., the synchronized document information corresponding to the first synchronized document changed by the document difference data) with the synchronized document information broadcast to the second client by the two-way communication server, considering that the synchronized document information includes at least: document identifier, document synchronized content and document version identifier, the synchronized document information of the first client and the synchronized document information broadcast to the second client by the two-way communication server are matched.
[0232] Considering that the document synchronization content of the first client has been modified, it is necessary to match the document identifier and document version identifier of the synchronized document. That is, to determine whether the document identifier corresponding to the first synchronized document is consistent with the document identifier broadcast by the two-way communication server, so as to determine whether the first synchronized document and the synchronized document stored locally on the two-way communication server are the documents to be synchronized. Then, it is necessary to match whether the document version identifier corresponding to the first synchronized document is consistent with the document version identifier broadcast by the two-way communication server. Considering that each document editing operation performed by the client will cause the two-way communication server to update the document version identifier, whether the document version identifier is consistent is to determine whether it is the initial document (without document editing operation) or whether it is the document after multiple identical document editing operations.
[0233] Based on this, the information matching result of synchronized document information can be either consistent or inconsistent. Inconsistent consistency usually occurs when multiple users are editing the same remote file simultaneously. Information matching of synchronized document information can effectively avoid editing conflicts. The processing embodiment here has been described in the foregoing embodiments and will not be repeated here. If the synchronized document information is consistent, step 604 is executed.
[0234] Step 604: If the synchronized document information matches, determine the synchronized document that is in the latest document state and matches the document difference data.
[0235] Specifically, if the synchronized document information matches, it means that the document identifier corresponding to the first synchronized document and the document identifier broadcast by the two-way communication server are the same, and the document version identifier corresponding to the first synchronized document and the document version identifier broadcast by the two-way communication server are also the same. This indicates that the first synchronized document and the synchronized document locally stored on the two-way communication server are synchronized documents, and the consistent document version identifiers indicate that the synchronized document locally stored on the two-way communication server is the updated synchronized document in the latest document state. Therefore, it can be seen that the document identifier of the first synchronized document whose document difference data has been modified is consistent with the synchronized document locally stored on the two-way communication server. At this point, the two-way communication server can determine the synchronized document in the latest document state matched by the document difference data based on the document identifier corresponding to the first synchronized document.
[0236] Step 606: Update the synchronized document through document difference data, obtain the updated synchronized document, and update the document status of the updated synchronized document to the latest document status.
[0237] Specifically, the two-way communication server updates and synchronizes documents through document difference data, obtains the updated synchronized documents, and updates the document status of the updated synchronized documents to the latest document status. Since the two-way communication server has updated the synchronized documents stored locally, as mentioned above, the document version identifier is specifically maintained and updated through the two-way communication server. That is, at this time, the document version identifier corresponding to the updated synchronized documents needs to be updated to the latest document version identifier to ensure the real-time update of the document version identifier.
[0238] In practical applications, synchronized documents are updated through document difference data. For ease of understanding, the code in practical applications that updates synchronized documents through document difference data is described as follows: the two-way communication server receives difference patches sent by the client. After receiving the difference patches, the two-way communication server applies these difference patches (i.e., document difference data in this embodiment) to the synchronized documents stored locally and broadcasts the difference patches to the client indicated by the client identifier included in the synchronized client set.
[0239] Furthermore, the aforementioned code allows the bidirectional communication server to remove the client's identifier from the synchronized client set when the client disconnects from the server, preventing broadcast data from being sent to clients without a communication connection. Conversely, when the client re-establishes a communication connection with the server, the client will resend a connection request to the server's monitoring port. The server will then add the client's identifier back to the synchronized client set, ensuring that subsequent broadcast data and information are reliably delivered to the reconnected client.
[0240] Step 608: Broadcast document difference data to clients in the set of synchronous clients to which the first client belongs.
[0241] Specifically, the two-way communication server broadcasts document difference data to clients in the synchronization client set to which the first client belongs. This allows all clients in the synchronization client set to synchronize documents based on the document editing changes made by the first client. In other words, each client needs to update and modify the locally stored synchronized document based on the document difference data. As described above, since the first client can also send document difference data and editing operation type to the two-way communication server, the server can further broadcast the document difference data and editing operation type to clients in the synchronization client set to which the first client belongs.
[0242] Furthermore, considering that the document version identifier is maintained and updated through a two-way communication server, meaning that the document version identifier corresponding to the updated synchronized document needs to be updated to the latest document version identifier to ensure real-time updates, the two-way communication server also needs to broadcast the latest document version identifier and the document identifier to the clients in the synchronization client set to which the first client belongs. This allows the clients in the synchronization client set to update the locally stored synchronized documents based on document difference data and editing operation types, and update the document version identifier of the locally stored synchronized documents to the latest document version identifier, ensuring the accuracy of subsequent document synchronization information.
[0243] It is understood that the corresponding examples in the embodiments of this application are used to understand this solution, but should not be construed as specific limitations on this solution.
[0244] In the above-mentioned document editing synchronization method, since the document is updated synchronously based on the differences in content when the bidirectional communication connection is in a reconnection state, resource consumption is reduced and message processing is improved by only synchronizing the differences in content. Furthermore, asynchronous updates ensure that the second client's updates to the third synchronized document are more reliable, thereby improving the efficiency and reliability of document editing synchronization.
[0245] The following describes how the second client can synchronize document editing based on document difference data, specifically illustrated through the following embodiment: In one embodiment, as follows... Figure 7 As shown, a method for document editing synchronization is provided, which can be applied to deployments on... Figure 1Taking the second client of terminal 102 as an example, a bidirectional communication connection exists between the second client and the first client deployed on another terminal. It is understood that this method can also be applied to a system including terminal 102 and bidirectional communication server 104, and implemented through the interaction between terminal 102 and bidirectional communication server 104. In this embodiment, the method includes the following steps:
[0246] Step 702: Obtain document difference data. The document difference data is used to describe the data updated in the first synchronized document, and the document updated in the first synchronized document is the second synchronized document.
[0247] The document difference data describes the data updated in the first synchronized document, and the updated document is the second synchronized document. In other words, the document difference content describes the differences between the content of the first synchronized document and the content of the second synchronized document. The document difference data includes at least: document difference content, the location of the difference content, and the difference context content. The location of the difference content describes its position within the document, and the difference context content describes the preceding and following document content adjacent to the difference content. Specifically, the document difference data is determined by comparing the content of the first synchronized document and the content of the second synchronized document after the first client updates the first synchronized document to obtain the second synchronized document in response to a document editing operation.
[0248] Specifically, the second client obtains document difference data. As described in the foregoing embodiments, the bidirectional communication server obtains the document difference data sent by the first client and matches it with the synchronized document information. If the synchronized document information matches, the server determines the synchronized document with the latest document state, updates the synchronized document using the document difference data, obtains the updated synchronized document, and updates the document state of the updated synchronized document to the latest document state. At this point, the server broadcasts the document difference data to clients in the synchronized client set to which the first client belongs. Since the synchronized client set to which the first client belongs includes the second client, the second client obtains the document difference data broadcast by the bidirectional communication server.
[0249] Step 704: Determine the matching third synchronized document based on the document difference data; the third synchronized document is a document stored on the second client and whose content is consistent with the first synchronized document.
[0250] The third synchronized document is a document stored on the second client that has the same content as the first synchronized document. In other words, it's the synchronized document that is synchronized between the first and second clients when a two-way communication connection exists. Specifically, it includes the first synchronized document on the first client and the third synchronized document on the second client. It can be understood that the content of the first and third synchronized documents can be the synchronized content of the documents when synchronizing document information between the first and second clients. Alternatively, it can be the document content synchronized when a two-way communication connection exists; the specific content of the first and third synchronized documents is not limited here.
[0251] Specifically, the second client determines the matching third synchronized document based on the document difference data. Since the bidirectional communication server broadcasts the document difference data only when the synchronized document information matches, this indicates that the document identifier corresponding to the first synchronized document and the document identifier broadcast by the bidirectional communication server are consistent. Furthermore, the document version identifier corresponding to the first synchronized document and the document version identifier broadcast by the bidirectional communication server are also consistent. Therefore, the document identifier of the first synchronized document modified by the document difference data is consistent with the synchronized document stored locally on the bidirectional communication server. Thus, the synchronized document stored locally on the bidirectional communication server is consistent with the synchronized documents stored locally by the clients in the synchronized client set. As mentioned above, the bidirectional communication server also needs to broadcast the latest document version identifier and the document identifier again to the clients in the synchronized client set to which the first client belongs. This allows the clients in the synchronized client set to update their locally stored synchronized documents based on the document difference data and editing operation type, and update the document version identifier of the locally stored synchronized documents to the latest document version identifier. This ensures the accuracy of subsequent document synchronization. Therefore, the second client can determine the synchronized document modified by the document difference data (the first synchronized document) through the document identifier, thereby determining the matching third synchronized document.
[0252] Step 706: Extract the document difference content, the location of the difference content, and the context of the difference content from the document difference data, and locate the actual update location in the third synchronized document based on the location of the difference content and the context of the difference content.
[0253] Specifically, as described above, document difference data includes at least: document difference content, difference content location, and difference context content. Therefore, the first client can extract the document difference content, difference content location, and difference content context from the document difference data. Considering that the difference content location describes the position of the document difference content within the document, and the aforementioned difference context content describes the preceding and following document content adjacent to the document difference content, the first client can locate the actual update position in the third synchronized document based on the difference content location and difference content context.
[0254] For example, based on the aforementioned example, the document content of the first synchronized document is "1234567", the difference content is located at the 4th and 5th characters in the first synchronized document, and the difference context content is the previous document content "123" and the next document content "67". Therefore, by using the difference context content and the difference content location, it can be determined that the replaced content "45" is the document content between the document content "123" and the document content "67", which means that the actual update position is the document position between the document content "123" and the document content "67".
[0255] Step 708: Update the third synchronized document at the actual update location based on the document difference content, and obtain the fourth synchronized document so that the document content of the fourth synchronized document is consistent with that of the second synchronized document.
[0256] Specifically, the second client updates the third synchronized document at the actual update location based on the document difference content, and obtains the fourth synchronized document to ensure that the content of the fourth synchronized document is consistent with that of the second synchronized document. As described above, since the first client can also send document difference data and editing operation type to the bidirectional communication server, allowing the bidirectional communication server to obtain the document difference data and editing operation type, the bidirectional communication server can further broadcast the document difference data and editing operation type to clients in the synchronization client set to which the first client belongs. At this point, the second client can also update the third synchronized document at the actual update location based on the document difference content and editing operation type, and obtain the fourth synchronized document.
[0257] Using the previous example again, since the actual update location is between the document content "123" and the document content "67", and the editing operation type is document content replacement, and the document difference content is specifically "45" replaced with "89", the third synchronized document has the same document content as the first synchronized document. Therefore, the document content of the third synchronized document is "1234567". And since the editing operation type is document content replacement, it means that at this time, the document difference content "89" needs to be replaced with "45" in the document position between the document content "123" and the document content "67", so as to obtain the fourth synchronized document "1238967" and make the document content of the fourth synchronized document consistent with the document content of the second synchronized document.
[0258] In practical applications, in addition to providing text editing capabilities, clients also need to determine whether there is any document difference data to be synchronized. This ensures that the locally stored synchronized document can be updated promptly based on the document difference content. For ease of understanding, in practical applications, the client uses the `pendingChanges` variable to indicate whether there is any document difference data to be synchronized. This document difference data can be determined by local document editing operations or by editing data determined by other clients via broadcast from the bidirectional communication server; this is not limited here. If the client directly edits the document locally, it will first update the locally stored synchronized document and determine the document difference data. Then, it will send the determined document difference data to the bidirectional communication server after a set delay (e.g., 500 milliseconds). This reduces the frequency of network requests, thereby reducing the impact of network latency. Furthermore, when the client establishes a connection with the bidirectional communication server, the server immediately sends the synchronization document information of the currently synchronized document. This allows the client to immediately load the synchronized document with the synchronization information and edit it according to actual needs without waiting for a response from the bidirectional communication server. Therefore, most editing operations are completed locally on the client side, with document synchronization only occurring asynchronously with a bidirectional communication server in the background. Even with high network latency, the participants in the operation will hardly perceive the synchronization delay.
[0259] It is understood that the corresponding examples in the embodiments of this application are used to understand this solution, but should not be construed as specific limitations on this solution.
[0260] In the above-mentioned document editing synchronization method, the update position where there is a difference is located based on the position of the difference content in the document difference data and the context of the difference content, so as to ensure the reliability of the difference positioning, and then update the difference content at the determined position, thereby further ensuring that the correct difference content update and adjustment is performed at a reliable difference position, thus improving the reliability of document editing synchronization.
[0261] Based on the detailed description of the foregoing embodiments, the complete process of the document editing synchronization method in the embodiments of this application will be described below. In one embodiment, such as Figure 8 As shown, a method for document editing synchronization is provided. This method is illustrated in a system including a terminal 102 and a two-way communication server 104. The method is implemented through the interaction between the terminal 102 and the two-way communication server 104. A first client and a second client are deployed on different terminals 102, and the two-way communication server 104 specifically provides a two-way communication connection between the first client and the second client. In this embodiment, the method includes the following steps:
[0262] Step 801: The first client sends a communication connection request to the monitoring port of the bidirectional communication server.
[0263] Step 802: The bidirectional communication server adds the first client identifier of the first client to the set of synchronous clients through the monitoring port.
[0264] Step 803: The bidirectional communication server broadcasts the synchronization document information to the client indicated by the client identifier in the synchronization client set.
[0265] Step 804: When the bidirectional communication connection is disconnected, the first client updates the first synchronized document to obtain the second synchronized document in response to the document editing operation on the first synchronized document.
[0266] Step 805: The first client determines the document difference data between the first synchronized document and the second synchronized document.
[0267] Step 806: When the bidirectional communication connection is in a reconnection state, the first client sends document difference data to the bidirectional communication server.
[0268] Step 807: The bidirectional communication server obtains the document difference data and matches the document difference data by synchronizing document information.
[0269] Step 808: If the synchronized document information matches, the bidirectional communication server determines the synchronized document that matches the document difference data and is in the latest document state.
[0270] Step 809: The bidirectional communication server updates the synchronized document through the document difference data, obtains the updated synchronized document, and updates the document status of the updated synchronized document to the latest document status.
[0271] Step 810: The bidirectional communication server broadcasts document difference data to clients in the set of synchronous clients to which the first client belongs.
[0272] Step 811: The second client obtains the document difference data.
[0273] Step 812: The second client determines the matching third synchronized document based on the document difference data.
[0274] Step 813: The second client extracts the document difference content, the location of the difference content, and the context of the difference content from the document difference data, and locates the actual update location in the third synchronized document based on the location of the difference content and the context of the difference content.
[0275] Step 814: The second client updates the third synchronized document at the actual update location based on the document difference content, and obtains the fourth synchronized document so that the document content of the fourth synchronized document is consistent with that of the second synchronized document.
[0276] It should be understood that the specific implementation methods of steps 801 to 814 are similar to those of the aforementioned embodiments, and will not be repeated here.
[0277] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps.
[0278] Based on the same inventive concept, this application also provides a document editing synchronization device for implementing the document editing synchronization method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations in one or more document editing synchronization device embodiments provided below can be found in the limitations of the document editing synchronization method described above, and will not be repeated here.
[0279] In one embodiment, such as Figure 9 As shown, a document editing synchronization device is provided. The device is deployed on a first client, and there is a bidirectional communication connection between the first client and a second client. The device includes: a document information acquisition module 902, a document update module 904, a difference data determination module 906, and a document synchronization module 908, wherein:
[0280] The document information acquisition module 902 is used to acquire synchronized document information with the second client.
[0281] The document update module 904 is used to update the first synchronized document to obtain the second synchronized document in response to a document editing operation on the first synchronized document when the bidirectional communication connection is disconnected.
[0282] The difference data determination module 906 is used to determine the document difference data between the first synchronized document and the second synchronized document;
[0283] The document synchronization module 908 is used to synchronize document difference data to the second client when the bidirectional communication connection is in a reconnection state, so that the second client can update the third synchronized document through the document difference data when the synchronized document information matches; the third synchronized document is a document stored on the second client and whose content is consistent with the first synchronized document.
[0284] In one embodiment, the document editing synchronization device further includes a communication connection module;
[0285] The communication connection module is used to send a communication connection request to the monitoring port of the bidirectional communication server, so that the monitoring port adds the first client identifier of the first client to the synchronous client set; the synchronous client set includes at least the second client identifier of the second client, and there is a bidirectional communication connection between the clients indicated by the client identifiers belonging to the synchronous client set;
[0286] The document synchronization module is specifically used to send document difference data to the bidirectional communication server when the bidirectional communication connection is in a reconnection state, so that the bidirectional communication server broadcasts the document difference data to the client indicated by the client identifier in the synchronization client set, so as to synchronize the document difference data to the second client.
[0287] In one embodiment, the document editing synchronization device further includes a document content processing module;
[0288] The document content processing module is used to store the second synchronized document and document difference data in local storage, and display the document content of the second synchronized document on the display interface;
[0289] The document synchronization module is specifically used to retrieve document difference data from local storage and send the document difference data to the two-way communication server when the bidirectional communication connection is in a reconnection state.
[0290] In one embodiment, the synchronized document information includes at least: synchronized document content and document version identifier; the synchronized document information matching is consistent with the document version identifier and is consistent with the document version identifier broadcast by the bidirectional communication server;
[0291] The document information acquisition module is used to acquire synchronized document information broadcast by the bidirectional communication server based on the synchronized client set; the synchronized client set includes at least the client identifier of the second client, and there is a bidirectional communication connection between the clients belonging to the synchronized client set.
[0292] In one embodiment, the document editing synchronization device further includes a request processing module;
[0293] The request processing module is used to obtain a conflict notification when the synchronized document information is inconsistent. The conflict notification describes that the document version identifier in the synchronized document information is inconsistent with the document version identifier broadcast by the bidirectional communication server. The module sends a version retrieval request to the bidirectional communication server to retrieve the latest document version identifier from the bidirectional communication server.
[0294] In one embodiment, the document update module is specifically configured to respond to a document editing operation on a first synchronized document and determine the edited content of the first synchronized document; if the edited content satisfies the update strategy, the first synchronized document is updated based on the edited content to obtain a second synchronized document.
[0295] In one embodiment, the document update module is specifically used to determine the content length of the edited content; if the content length reaches a content length threshold, it is determined that the edited content meets the update strategy.
[0296] In one embodiment, the document update module is specifically used to determine the previous update timestamp of the document update and the last timestamp of the input of the edited content; obtain the input duration composed of the previous update timestamp and the last timestamp; and determine that the edited content meets the update strategy if the input duration reaches the input duration threshold.
[0297] In one embodiment, the document update module is specifically used to identify units in the edited content and obtain unit identification results; if the unit identification results indicate the existence of semantic units, it is determined that the edited content meets the update strategy.
[0298] In one embodiment, the document synchronization module is further configured to determine the type of editing operation indicated by the document editing operation; synchronize the document difference data and the editing operation type to the second client; wherein, if the synchronized document information matches, the second client updates the third synchronized document through the document difference data and the editing operation type.
[0299] In another embodiment, such as Figure 10As shown, a document editing synchronization device is provided. The device is deployed on a two-way communication server, which provides a two-way communication connection between a first client and a second client. The device includes: a difference data processing module 1002, a synchronized document determination module 1004, a synchronized document update module 1006, and a difference data sending module 1008, wherein:
[0300] The difference data processing module 1002 is used to obtain the document difference data sent by the first client and match the document difference data by synchronizing document information;
[0301] The synchronized document determination module 1004 is used to determine the synchronized document that is in the latest document state when the synchronized document information matches.
[0302] The synchronized document update module 1006 is used to update synchronized documents through document difference data, obtain updated synchronized documents, and update the document status of the updated synchronized documents to the latest document status.
[0303] The difference data sending module 1008 is used to broadcast document difference data to clients in the set of synchronous clients to which the first client belongs.
[0304] In another embodiment, such as Figure 11 As shown, a document editing synchronization device is provided. The device is deployed on a second client, and there is a bidirectional communication connection between the second client and the first client. It includes: a difference data acquisition module 1102, a synchronized document determination module 1104, a difference positioning module 1106, and a document synchronization module 1108, wherein:
[0305] The difference data acquisition module 1102 is used to acquire document difference data, which describes the data updated on the first synchronized document, and the document updated on the first synchronized document is the second synchronized document.
[0306] The synchronized document determination module 1104 is used to determine the matching third synchronized document based on document difference data; the third synchronized document is a document stored on the second client and whose content is consistent with the first synchronized document;
[0307] The difference location module 1106 is used to extract the document difference content, the difference content location and the difference content context from the document difference data, and locate the actual update location in the third synchronized document based on the difference content location and the difference content context.
[0308] The document synchronization module 1108 is used to update the third synchronized document based on the document difference content at the actual update location, and obtain the fourth synchronized document so that the document content of the fourth synchronized document is consistent with that of the second synchronized document.
[0309] In one embodiment, a computer device is provided, which can be a two-way communication server or a terminal. This embodiment uses the computer device as a terminal as an example, and its internal structure diagram is as follows. Figure 12 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When executed by the processor, the computer program implements a method for synchronized document editing. The display unit of the computer device is used to form a visually visible image. It can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0310] In another embodiment, a computer device is provided, which can be a two-way communication server or a terminal. This embodiment uses a two-way communication server as an example for description, and its internal structure diagram is as follows. Figure 13As shown, the computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage medium. The database stores document difference data and synchronized documents, as well as other data related to the embodiments of this application. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a method for document editing synchronization.
[0311] Those skilled in the art will understand that Figure 12 as well as Figure 13 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0312] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0313] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0314] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0315] It should be noted that the document editing synchronization (including but not limited to object device information, object personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the object or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0316] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based document editing synchronization logic devices, etc., and are not limited to these.
[0317] The technical features in the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0318] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for synchronizing document editing, characterized in that, The method is applied to a first client, and a bidirectional communication connection exists between the first client and a second client. The method includes: Obtain synchronized document information with the second client; In the event that the bidirectional communication connection is disconnected, in response to a document editing operation on the first synchronized document, the first synchronized document is updated to obtain a second synchronized document; Determine the document difference data between the first synchronized document and the second synchronized document; When the bidirectional communication connection is in a reconnection state, the document difference data is synchronized to the second client so that, if the synchronized document information matches, the second client updates the third synchronized document using the document difference data; the third synchronized document is a document stored on the second client and whose content is consistent with the first synchronized document.
2. The method according to claim 1, characterized in that, The method further includes: A communication connection request is sent to the monitoring port of the bidirectional communication server, so that the monitoring port adds the first client identifier of the first client to the synchronization client set; the synchronization client set includes at least the second client identifier of the second client, and there is a bidirectional communication connection between the clients indicated by the client identifiers belonging to the synchronization client set; When the bidirectional communication connection is in a reconnection state, synchronizing the document difference data to the second client includes: When the bidirectional communication connection is in a reconnection state, the document difference data is sent to the bidirectional communication server so that the bidirectional communication server broadcasts the document difference data to the client indicated by the client identifier in the synchronization client set, so as to synchronize the document difference data to the second client.
3. The method according to claim 2, characterized in that, The method further includes: The second synchronized document and the document difference data are stored in local storage, and the document content of the second synchronized document is displayed on the display interface; When the bidirectional communication connection is in a reconnection state, sending the document difference data to the bidirectional communication server includes: If the bidirectional communication connection is in a reconnection state, the document difference data is retrieved from the local storage and sent to the bidirectional communication server.
4. The method according to claim 1, characterized in that, The synchronized document information includes at least: document synchronization content and document version identifier; the synchronized document information matching is that the document version identifier is consistent with the document version identifier broadcast by the two-way communication server; The step of obtaining synchronized document information with the second client includes: The synchronized document information broadcast by the bidirectional communication server based on the synchronized client set is obtained; the synchronized client set includes at least the second client, and there is a bidirectional communication connection between the clients belonging to the synchronized client set.
5. The method according to claim 1, characterized in that, The method further includes: If the synchronized document information does not match, a conflict notification is obtained; the conflict notification describes that the document version identifier in the synchronized document information is inconsistent with the document version identifier broadcast by the bidirectional communication server. A version retrieval request is sent to each of the two-way communication servers to retrieve the latest document version identifier from each of the two-way communication servers.
6. The method according to claim 1, characterized in that, The step of updating the first synchronized document to obtain the second synchronized document in response to a document editing operation on the first synchronized document includes: In response to a document editing operation on a first synchronized document, the document editing operation is determined to be for the edited content of the first synchronized document; If the edited content meets the update strategy, the first synchronized document is updated based on the edited content to obtain the second synchronized document.
7. The method according to claim 6, characterized in that, The method further includes: Determine the length of the content to be edited; The edited content satisfies the update strategy, including: If the content length reaches the content length threshold, it is determined that the edited content meets the update strategy.
8. The method according to claim 6, characterized in that, The method further includes: Determine the last update timestamp of the document and the last timestamp of when the edited content was entered; Obtain the input duration consisting of the previous update timestamp and the last timestamp; The edited content satisfies the update strategy, including: If the input duration reaches the input duration threshold, it is determined that the edited content meets the update strategy.
9. The method according to claim 6, characterized in that, The method further includes: Perform unit identification on the edited content and obtain the unit identification result; The edited content satisfies the update strategy, including: If the unit identification result indicates the existence of semantic units, the edited content is determined to satisfy the update strategy.
10. A method for synchronizing document editing, characterized in that, The method is applied to a bidirectional communication server, which provides a bidirectional communication connection between a first client and a second client. The method includes: Obtain the document difference data sent by the first client, and match the document difference data by synchronizing document information; If the synchronized document information matches, determine the synchronized document that is in the latest document state that matches the document difference data; The synchronized document is updated using the document difference data, the updated synchronized document is obtained, and the document status of the updated synchronized document is updated to the latest document status. The document difference data is broadcast to clients in the set of synchronous clients to which the first client belongs.
11. A method for document editing synchronization, characterized in that, The method is applied to a second client, which has a bidirectional communication connection with the first client. The method includes: Obtain document difference data, which describes the data updated in the first synchronized document, and the document updated in the first synchronized document is the second synchronized document; The matching third synchronized document is determined based on the document difference data; the third synchronized document is a document stored in the second client and whose content is consistent with the first synchronized document; Extract the document difference content, the location of the difference content, and the context of the difference content from the document difference data, and locate the actual update location in the third synchronized document based on the location of the difference content and the context of the difference content. The third synchronized document is updated at the actual update location based on the document difference content to obtain a fourth synchronized document, so that the document content of the fourth synchronized document is consistent with that of the second synchronized document.
12. A document editing synchronization device, characterized in that, The device is deployed on a first client, and there is a bidirectional communication connection between the first client and a second client. The device includes: The document information acquisition module is used to acquire synchronized document information with the second client. The document update module is used to update the first synchronized document to obtain a second synchronized document in response to a document editing operation on the first synchronized document when the bidirectional communication connection is disconnected. The difference data determination module is used to determine the document difference data between the first synchronized document and the second synchronized document; The document synchronization module is used to synchronize the document difference data to the second client when the bidirectional communication connection is in a reconnection state, so that when the synchronized document information matches, the second client updates the third synchronized document through the document difference data; the third synchronized document is a document stored on the second client and whose content is consistent with the first synchronized document.
13. A document editing synchronization device, characterized in that, The device is deployed on a two-way communication server, which provides a two-way communication connection between the first client and the second client. The device includes: The difference data processing module is used to acquire document difference data sent by the first client and match the document difference data by synchronizing document information; The synchronized document determination module is used to determine the synchronized document in the latest document state that matches the document difference data when the synchronized document information is consistent. The synchronized document update module is used to update the synchronized document through the document difference data, obtain the updated synchronized document, and update the document status of the updated synchronized document to the latest document status; The difference data sending module is used to broadcast the document difference data to clients in the set of synchronous clients to which the first client belongs.
14. A document editing synchronization device, characterized in that, The device is deployed on a second client, and there is a bidirectional communication connection between the second client and the first client. The device includes: The difference data acquisition module is used to acquire document difference data, which describes the data updated on the first synchronized document, and the document updated on the first synchronized document is the second synchronized document. The synchronized document determination module is used to determine a matching third synchronized document based on the document difference data; the third synchronized document is a document stored in the second client and whose content is consistent with the first synchronized document; The difference location module is used to extract the document difference content, the difference content location, and the difference content context from the document difference data, and to locate the actual update location in the third synchronized document based on the difference content location and the difference content context. The document synchronization module is used to update the third synchronized document based on the document difference content at the actual update location, and obtain a fourth synchronized document so that the document content of the fourth synchronized document is consistent with that of the second synchronized document.
15. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 11.