WebRTC-based online document collaborative editing method and system

Through WebRTC and CRDT technology, real-time synchronization and security of online document editing are achieved, solving the real-time and security problems of existing online document editing systems, reducing server load, and improving collaboration efficiency and data security.

CN118690730APending Publication Date: 2024-09-24INSPUR SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410913106.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-09
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

Existing online document editing systems have problems in real-time, security, and server load, and their reliance on centralized servers leads to data delays, security risks, and high bandwidth requirements.

Method used

Adopting an online document collaborative editing method based on WebRTC, using CRDT data structure and end-to-end encryption technology to achieve point-to-point communication and data synchronization between users, reducing dependence on the central server, and using ICE, STUN and TURN frameworks to establish connections and ensure data Transmission security and consistency.

Benefits of technology

It achieves real-time synchronization of online document editing, reduces user experience degradation caused by network delays, improves team collaboration efficiency, reduces server bandwidth pressure, ensures data security, and avoids the risk of single point failure of the central server.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118690730A
    Figure CN118690730A
Patent Text Reader

Abstract

The invention discloses an online document collaborative editing method and system based on WebRTC, and relates to the technical field of document editing.The method comprises the steps that a document structure based on CRDT is created, and a unique identifier is distributed to each user participating in editing; the users participating in editing establish communication connection through WebRTC; after the user A participating in editing performs an editing operation, the editing operation is synchronized to the remaining users participating in editing in real time through WebRTC communication connection in the form of an operation log; after the remaining users participating in editing receive the operation logs, merging the operation logs into a local document state according to a CRDT rule, then updating a version vector of the document, and recording the state change of this time; and the browsers of the remaining users participating in editing update the display content in real time so as to reflect the editing operation of the user A participating in editing. According to the invention, real-time synchronization of online document editing can be realized, reduction of user experience caused by network delay is reduced, and team cooperation efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of document editing, and in particular to a WebRTC-based online document collaborative editing method and system. Background Art

[0002] With the development of Internet technology, remote collaboration has become more and more common. However, existing online document editing systems mostly rely on centralized servers for data synchronization, which has problems such as data delay, security risks, and high server bandwidth requirements. WebRTC (Web Real-Time Communication) technology allows web browsers to communicate directly, while CRDT (Conflict-free Replicated Data Type) is a data structure that supports data replication and conflict-free merging. Summary of the invention

[0003] The present invention aims at solving the problems of real-time, security and server load in the existing online document editing platform, and provides a WebRTC-based online document collaborative editing method and system.

[0004] In a first aspect, the present invention provides an online document collaborative editing method based on WebRTC, and the technical solution adopted to solve the above technical problems is as follows:

[0005] A method for collaboratively editing online documents based on WebRTC, comprising the following steps:

[0006] Create a CRDT-based document structure and assign a unique identifier to each user who participates in the editing process.

[0007] The users participating in the editing establish a communication connection through WebRTC;

[0008] After user A who participates in editing performs an editing operation, the editing operation is synchronized in real time to the remaining users who participate in editing through the WebRTC communication connection in the form of an operation log;

[0009] After receiving the operation log, the remaining users participating in the editing merge it into the local document state according to the CRDT rules, and then update the version vector of the document to record the state change;

[0010] The browsers of the remaining users participating in the editing update the displayed content in real time to reflect the editing operation of the user A participating in the editing.

[0011] Optionally, the editing users establish a communication connection through WebRTC. The specific process is as follows:

[0012] Establish signaling channels, exchange network address information, and use the ICE framework to establish point-to-point connections for NAT traversal, helping to establish connections between devices behind firewalls;

[0013] When NAT traversal is unsuccessful, STUN and TURN servers are used to assist in establishing a connection, where the STUN server helps the client discover its public IP address and port, and the TURN server acts as a relay.

[0014] Optionally, after user A participating in the editing performs an editing operation, the editing operation with the unique identifier of user A is synchronized in real time to the remaining users participating in the editing via the WebRTC communication connection in the form of an operation log.

[0015] Optionally, after the users participating in the editing establish a communication connection through WebRTC, all users participating in the editing can concurrently edit the created CRDT-based document structure, and each user's editing operation is synchronized to the remaining users participating in the editing in real time in the form of an operation log;

[0016] When user A who participates in editing performs editing operations in an offline state, after user A reconnects with the remaining users who participate in editing, the editing operations performed by user A in an offline state are synchronized to the remaining users who participate in editing in the form of operation logs.

[0017] Optionally, end-to-end encryption technology is introduced. When the editing operations performed by user A participating in the editing are synchronized to the remaining users participating in the editing in the form of operation logs through the WebRTC communication connection, the transmitted document data is encrypted so that only the users participating in the current editing can decrypt and access the data content.

[0018] In a second aspect, the present invention provides an online document collaborative editing system based on WebRTC, and the technical solution adopted to solve the above technical problems is as follows:

[0019] An online document collaborative editing system based on WebRTC, whose structure includes:

[0020] Create an assignment module that creates a CRDT-based document structure and assigns a unique identifier to each user who participates in the editing process.

[0021] WebRTC communication module, used to establish communication connection between users participating in editing through WebRTC;

[0022] The synchronization module is used to synchronize the editing operation in the form of an operation log to the remaining users participating in the editing in real time through the WebRTC communication connection after the user A participating in the editing performs an editing operation;

[0023] The merge update module is used to merge the operation logs received by the remaining users participating in the editing into the local document status according to the CRDT rules, and update the version vector of the document to record the status change;

[0024] The update display module is used for the browsers of the remaining users participating in the editing to update the displayed content in real time to reflect the editing operation of the user A participating in the editing.

[0025] Optionally, the process in which the WebRTC communication module establishes a communication connection between users participating in editing via WebRTC is as follows:

[0026] Establish signaling channels, exchange network address information, and use the ICE framework to establish point-to-point connections for NAT traversal, helping to establish connections between devices behind firewalls;

[0027] When NAT traversal is unsuccessful, STUN and TURN servers are used to assist in establishing a connection, where the STUN server helps the client discover its public IP address and port, and the TURN server acts as a relay.

[0028] Optionally, after user A participating in the editing performs an editing operation, the synchronization module involved synchronizes the editing operation with the unique identifier of user A in the form of an operation log in real time to the remaining users participating in the editing through the WebRTC communication connection.

[0029] Further optionally, after the WebRTC communication module involved establishes a communication connection between the users participating in the editing through WebRTC, all the users participating in the editing can concurrently edit the created CRDT-based document structure, and the synchronization module synchronizes the editing operation of each user to the remaining users participating in the editing in real time in the form of an operation log;

[0030] When user A participating in the editing performs editing operations while offline, after user A reconnects with the remaining users participating in the editing through the WebRTC communication module, the synchronization module synchronizes the editing operations performed by user A while offline to the remaining users participating in the editing in the form of operation logs.

[0031] Optionally, the synchronization module involved has a built-in data encryption and decryption method. When the synchronization module synchronizes the editing operations performed by user A participating in the editing to the remaining users participating in the editing in the form of an operation log, the transmitted document data is encrypting the data encryption and decryption method, so that only users participating in the current editing can use the data encryption and decryption method to decrypt and access the data content.

[0032] The WebRTC-based online document collaborative editing method and system of the present invention have the following beneficial effects compared with the prior art:

[0033] 1. The present invention can realize real-time synchronization of online document editing, reduce the decline in user experience caused by network delay, improve team collaboration efficiency, and can be widely used in multiple scenarios such as remote office, online education, team collaboration, etc.;

[0034] 2. The present invention reduces dependence on central servers and server bandwidth pressure through point-to-point communication technology, thereby reducing operating costs; utilizes the conflict-free merging feature of CRDT to avoid the risk of single point failure of the central server, ensuring the consistency of operations between different users without the need for complex conflict resolution logic; introduces end-to-end encryption technology to ensure data security during document transmission and editing and protect user privacy. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Attached Figure 1 is a flow chart of a method according to Embodiment 1 of the present invention;

[0036] Attached Figure 2 is a module connection block diagram of the second embodiment of the present invention;

[0037] Attached Figure 3 It is a schematic diagram of user A and user B concurrently editing a document in an embodiment of the present invention. DETAILED DESCRIPTION

[0038] In order to make the technical solution, the technical problem solved and the technical effect of the present invention more clearly understood, the technical solution of the present invention is clearly and completely described below in conjunction with specific embodiments.

[0039] The English words involved in the embodiments are explained as follows:

[0040] WebRTC (Web Real-Time Communications) is a real-time communication technology that aims to enable browsers to provide simple JavaScript interfaces to achieve real-time communication. It allows network applications or sites to establish peer-to-peer connections between browsers without the help of an intermediary, and to achieve the transmission of video streams, audio streams, or any other data. WebRTC is not just an API, it is also a complete architecture that includes multiple components. This architecture includes Web API, WebRTC Native C++API, transport / session layer, audio engine, and video engine. Through these components, WebRTC can access and manage audio and video devices, collect audio and video data, and transmit data and interact in real time.

[0041] CRDT (Conflict-free Replicated Data Type) is a data structure designed for distributed systems. It ensures data consistency and time order correctness by allowing operations to be performed independently on each node. CRDT stands for Conflict-free Replicated Data Type. Its main purpose is to synchronize and replicate data in distributed systems without global coordination. CRDT uses a specific algorithm to ensure that copies of data can eventually converge to a consistent state even in the case of network partition or high latency. This technology has broad application prospects in real-time collaboration tools, distributed databases, and IoT applications. CRDT can be implemented in two ways: state-based and operation-based. State-based CRDT represents data as a series of complete states, and the entire new state is transmitted each time it is updated; while operation-based CRDT records a series of operations and only transmits these operations. Both have advantages and disadvantages: state-based CRDT is simple to implement but may result in a large amount of data transmission, while operation-based CRDT has a small amount of data transmission but is complex to implement. In practical applications, CRDT can effectively solve the concurrency problem in real-time collaborative editing by multiple people. For example, in an online document editor, when multiple users modify a document at the same time, the traditional synchronization mechanism may cause data inconsistency due to network delays or errors. However, CRDT ensures that all replicas eventually converge to a consistent state through an optimistic replication strategy and automatic conflict resolution mechanism. In addition, CRDT can also be applied to distributed databases and the Internet of Things. Distributed databases need to maintain data consistency among multiple nodes. CRDT avoids the lock waiting problem in traditional distributed transactions through conflict-free operation sequences and improves system performance. In general, CRDT, as a new type of data synchronization algorithm, achieves efficient and reliable data synchronization in distributed systems through its unique conflict-free characteristics and two implementation methods.

[0042] Embodiment 1:

[0043] Combined with Figure 1 This embodiment proposes a method for collaboratively editing online documents based on WebRTC, which includes the following steps:

[0044] (i) Create a CRDT-based document structure and assign a unique identifier to each user who participates in the editing process.

[0045] (II) Taking user A and user B participating in the editing of an online document as an example, user A and user B establish a communication connection through WebRTC. The specific process is as follows:

[0046] Establish signaling channels, exchange network address information, and use the ICE framework to establish point-to-point connections for NAT traversal, helping to establish connections between devices behind firewalls;

[0047] When NAT traversal is unsuccessful, STUN and TURN servers are used to assist in establishing a connection, where the STUN server helps the client discover its public IP address and port, and the TURN server acts as a relay.

[0048] (3) After user A performs an editing operation, the editing operation is synchronized to user B in real time via the WebRTC communication connection in the form of an operation log with user A's unique identifier;

[0049] After receiving the operation log, user B merges it into the local document state according to the CRDT rules, and then updates the version vector of the document to record this state change;

[0050] User B's browser updates the displayed content in real time to reflect user A's editing operations.

[0051] Based on the above description, combined with the attached Figure 3 , assuming that the initial state of the document is A, replica 1 performs two edit operations on the document, namely adding A1 and adding A2, and replica 2 performs one edit operation on the document, namely adding B1 and deleting the initial state A. Based on this, synchronization is performed: replica 1 and replica 2 exchange their action logs in real time through the WebRTC communication connection, and according to the rules of CRDT, replica 1 and replica 2 sequentially apply the operation logs received from each other. Through synchronization and merging operations, the final states of replicas 1 and 2 are unified as follows: A1 is executed first, then B1, and finally A2. It should be added that: although replica 2 deletes the initial state A and adds B1, through the characteristics of CRDT, the distributed system can handle this "deletion" operation and coordinate it with the new operations A1 and A2 on replica 1. This shows that CRDT can not only handle addition operations, but also effectively handle deletion operations, thereby ensuring that all replicas eventually reach a consistent state.

[0052] End-to-end encryption technology is introduced in the online document collaborative editing method described in this embodiment. When the editing operations performed by user A participating in the editing are synchronized to the remaining users participating in the editing in the form of operation logs through the WebRTC communication connection, the transmitted document data is encrypted so that only the users participating in the current editing can decrypt and access the data content.

[0053] It should be added that: after user A and user B establish a communication connection through WebRTC, both user A and user B can concurrently edit the created CRDT-based document structure, and the editing operations of user A and user B are synchronized to the remaining users participating in the editing in real time in the form of operation logs. When user A performs an editing operation while offline, after user A reconnects with user B, the editing operations performed by user A while offline are synchronized to user B in the form of operation logs.

[0054] Embodiment 2:

[0055] Combined with Figure 2 This embodiment proposes an online document collaborative editing system based on WebRTC, and its structure includes:

[0056] Create an assignment module that creates a CRDT-based document structure and assigns a unique identifier to each user who participates in the editing process.

[0057] WebRTC communication module, used to establish communication connection between users participating in editing through WebRTC;

[0058] A synchronization module is used to synchronize, in real time through a WebRTC communication connection, the editing operation with the unique identifier of user A to the remaining users participating in the editing in the form of an operation log after the user A participating in the editing performs an editing operation;

[0059] The merge update module is used to merge the operation logs received by the remaining users participating in the editing into the local document status according to the CRDT rules, and update the version vector of the document to record the status change;

[0060] The update display module is used for the browsers of the remaining users participating in the editing to update the displayed content in real time to reflect the editing operation of the user A participating in the editing.

[0061] In this embodiment, taking user A and user B participating in the editing of an online document as an example, the process in which the WebRTC communication module establishes a communication connection between user A and user B participating in the editing through WebRTC is as follows:

[0062] Establish signaling channels, exchange network address information, and use the ICE framework to establish point-to-point connections for NAT traversal, helping to establish connections between devices behind firewalls;

[0063] When NAT traversal is unsuccessful, STUN and TURN servers are used to assist in establishing a connection, where the STUN server helps the client discover its public IP address and port, and the TURN server acts as a relay.

[0064] After the WebRTC communication module establishes a communication connection between user A and user B participating in the editing through WebRTC, the synchronization module synchronizes the editing operation with the unique identifier of user A to user B in real time through the WebRTC communication connection in the form of an operation log after user A participating in the editing performs an editing operation. It should be added that: both user A and user B can concurrently edit the created CRDT-based document structure, and the synchronization module synchronizes the editing operations of user A and user B with their corresponding unique identifiers to user B and user A in real time in the form of an operation log. When user A performs an editing operation in an offline state, after user A reconnects with user B through the WebRTC communication module, the synchronization module synchronizes the editing operations performed by user A in an offline state with the unique identifier to user B in the form of an operation log.

[0065] In this embodiment, the synchronization module involved has a built-in data encryption and decryption method. When the synchronization module synchronizes the editing operations performed by user A participating in the editing to the remaining users participating in the editing in the form of an operation log, the transmitted document data is encrypting the data encryption and decryption method, so that only users participating in the current editing can use the data encryption and decryption method to decrypt and access the data content.

[0066] In summary, the WebRTC-based online document collaborative editing method and system of the present invention can achieve real-time synchronization of online document editing, reduce the degradation of user experience caused by network delays, and improve team collaboration efficiency.

[0067] The above specific examples are used to explain the principles and implementation methods of the present invention in detail. These examples are only used to help understand the core technical content of the present invention. Based on the above specific embodiments of the present invention, any improvements and modifications made by technicians in this technical field without departing from the principles of the present invention should fall within the scope of patent protection of the present invention.

Claims

1. A method for collaborative online document editing based on WebRTC. It is characterized in that The steps include: Create a CRDT-based document structure and assign a unique identifier to each user who participates in the editing process. The users participating in the editing establish a communication connection through WebRTC; After user A who participates in editing performs an editing operation, the editing operation is synchronized in real time to the remaining users who participate in editing through the WebRTC communication connection in the form of an operation log; After receiving the operation log, the remaining users participating in the editing merge it into the local document state according to the CRDT rules, and then update the version vector of the document to record the state change; The browsers of the remaining users participating in the editing update the displayed content in real time to reflect the editing operation of the user A participating in the editing.

2. According to the WebRTC-based online document collaborative editing method of claim 1, It is characterized in that The users participating in the editing establish a communication connection through WebRTC. The specific process is as follows: Establish signaling channels, exchange network address information, and use the ICE framework to establish point-to-point connections for NAT traversal, helping to establish connections between devices behind firewalls; When NAT traversal is unsuccessful, STUN and TURN servers are used to assist in establishing a connection, where the STUN server helps the client discover its public IP address and port, and the TURN server acts as a relay.

3. According to the WebRTC-based online document collaborative editing method of claim 1, It is characterized in that After user A who participates in editing performs an editing operation, the editing operation with the unique identifier of user A is synchronized in real time to the remaining users who participate in editing through the WebRTC communication connection in the form of an operation log.

4. According to the WebRTC-based online document collaborative editing method of claim 3, It is characterized in that After the users participating in the editing establish a communication connection through WebRTC, all users participating in the editing can concurrently edit the created CRDT-based document structure, and each user's editing operation is synchronized to the remaining users participating in the editing in real time in the form of an operation log; When user A who participates in editing performs editing operations in an offline state, after user A reconnects with the remaining users who participate in editing, the editing operations performed by user A in an offline state are synchronized to the remaining users who participate in editing in the form of operation logs.

5. According to the WebRTC-based online document collaborative editing method of claim 1, It is characterized in that End-to-end encryption technology is introduced. When the editing operations performed by user A participating in the editing are synchronized to the remaining users participating in the editing in the form of operation logs through the WebRTC communication connection, the transmitted document data is encrypted so that only the users participating in the current editing can decrypt and access the data content.

6. An online document collaborative editing system based on WebRTC, It is characterized in that Its structure includes: Create an assignment module that creates a CRDT-based document structure and assigns a unique identifier to each user who participates in the editing process. WebRTC communication module, used to establish communication connection between users participating in editing through WebRTC; The synchronization module is used to synchronize the editing operation in the form of an operation log to the remaining users participating in the editing in real time through the WebRTC communication connection after the user A participating in the editing performs an editing operation; The merge update module is used to merge the operation logs received by the remaining users participating in the editing into the local document status according to the CRDT rules, and update the version vector of the document to record the status change; The update display module is used for the browsers of the remaining users participating in the editing to update the displayed content in real time to reflect the editing operation of the user A participating in the editing.

7. The online document collaborative editing system based on WebRTC according to claim 6, It is characterized in that The process of the WebRTC communication module establishing a communication connection between users participating in editing via WebRTC is as follows: Establish signaling channels, exchange network address information, and use the ICE framework to establish point-to-point connections for NAT traversal, helping to establish connections between devices behind firewalls; When NAT traversal is unsuccessful, STUN and TURN servers are used to assist in establishing a connection, where the STUN server helps the client discover its public IP address and port, and the TURN server acts as a relay.

8. According to claim 6, a WebRTC-based online document collaborative editing system, It is characterized in that After user A who participates in editing performs an editing operation, the synchronization module synchronizes the editing operation with the unique identifier of user A in the form of an operation log in real time to the remaining users who participate in editing through the WebRTC communication connection.

9. The online document collaborative editing system based on WebRTC according to claim 8, It is characterized in that After the WebRTC communication module establishes a communication connection between the users participating in the editing through WebRTC, all the users participating in the editing can concurrently edit the created CRDT-based document structure, and the synchronization module synchronizes the editing operation of each user to the remaining users participating in the editing in real time in the form of an operation log; When user A participating in the editing performs editing operations in an offline state, after user A reconnects with the remaining users participating in the editing through the WebRTC communication module, the synchronization module synchronizes the editing operations performed by user A in an offline state to the remaining users participating in the editing in the form of operation logs.

10. The online document collaborative editing system based on WebRTC according to claim 6, It is characterized in that The synchronization module has a built-in data encryption and decryption method. When the synchronization module synchronizes the editing operations performed by user A participating in the editing to the remaining users participating in the editing in the form of an operation log, the transmitted document data is encrypting the data encryption and decryption method so that only the users participating in the current editing can use the data encryption and decryption method to decrypt and access the data content.