Data synchronization method and system
By broadcasting a synchronization identifier to the server and other terminals after terminal data changes, and using the server as a relay point, the problem of low data synchronization efficiency between terminals is solved, thereby improving the success rate of terminal online and synchronization efficiency.
Patent Information
- Application Number
- PCT/CN2025/074432
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-06-07
- Filing Date
- 2025-01-23
- Publication Date
- 2025-12-11
AI Technical Summary
In existing technologies, data synchronization between terminals is inefficient, resulting in a low success rate for terminal online. In particular, when multiple terminals are networked, N*(N-1) data synchronizations are required, causing latency and success rate issues.
By broadcasting a synchronization identifier to the server and other terminals after terminal data changes, and using the server as a relay point, terminals can obtain the changed data from the server, reducing the number of direct connections between terminals and improving synchronization efficiency.
It improves the efficiency of data synchronization between terminals and the success rate of going online, reduces the number of times terminal connections need to be established, and increases the online rate of devices and services.
Smart Images

Figure CN2025074432_11122025_PF_FP_ABST
Abstract
Description
Method and system for synchronizing data
[0001] The present application claims priority to the Chinese patent application No. 202410743928.2, filed on June 7, 2024, and entitled "Method and system for synchronizing data", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD
[0002] The present application relates to the field of terminals, and in particular to a method and system for synchronizing data. BACKGROUND
[0003] With the continuous development of terminal technology, the number and types of terminals around users are growing. Multiple terminals can be connected to each other to form a super terminal or super system, providing users with more diverse services and experiences. When terminals are connected or cooperated to perform distributed services, data synchronization is required.
[0004] In the prior art, a terminal can establish a connection with another terminal, and send data to be synchronized, such as distributed scheduling information, to the other terminal based on the connection. This point-to-point data synchronization method is very inefficient. When N terminals are connected, N*(N-1) times of data synchronization are required, which further leads to low success rate of terminal online, and greatly reduces user experience. SUMMARY
[0005] Therefore, the present application provides a method and system for synchronizing data, which can improve the efficiency of data synchronization between terminals and the success rate of terminal online.
[0006] To achieve the above purpose, in a first aspect, the present application provides a method for synchronizing data, applied to a system including a first terminal, a second terminal and a server, the first terminal being connected to the server, the method comprising: after the data of the first terminal is changed, the first terminal broadcasting a first synchronization identifier to the second terminal, the first synchronization identifier being used to indicate the first data of the first terminal after the data is changed; the first terminal sending the first data and the first synchronization identifier to the server; when the second terminal is connected to the server, the second terminal receiving the first synchronization identifier from the server; when the second terminal receives the first synchronization identifier sent by the server, the second terminal obtaining the first data from the server based on the first synchronization identifier.
[0007] In the embodiments of the present application, after the data is changed, the first terminal can send the first data and the first synchronization identifier to the server, wherein the first synchronization identifier can indicate the changed first data of the first terminal, and the second terminal can obtain the first synchronization identifier from the first terminal and the server, so as to determine that the first terminal has data change. When the second terminal receives the first synchronization identifier sent by the server, it can be determined that the current connection with the server is good and the server stores the first data, so the second terminal obtains the first data from the server, without the need to specially establish the connection between the first terminal and the second terminal for synchronizing the first data, thereby improving the synchronization efficiency, the device online rate of the first terminal and the service online rate.
[0008] In some embodiments, the data change of the first terminal can include newly generating the first data, or can include updating another third data that already exists, so as to obtain the first data. Alternatively, in other embodiments, the first terminal can also change the data in other ways, so as to obtain the changed first data.
[0009] In some embodiments, the first data can be data required by the first terminal to connect with other terminals to form a network or to cooperatively execute distributed services. For example, the first data can include distributed scheduling information of the first terminal, a DP of the first terminal or distributed hardware data of the first terminal.
[0010] In some embodiments, the method further includes: when the second terminal receives the first synchronization identifier sent by the first terminal and does not receive the first synchronization identifier sent by the server, the second terminal obtains the first data from the first terminal based on the first synchronization identifier in response to a first event, wherein the first event is cooperatively processed by the first terminal and the second terminal.
[0011] When the second terminal only receives the first synchronization identifier sent by the first terminal, the first data can also be obtained from the first terminal when there is a service triggered synchronization, thereby improving the reliability of obtaining the first data and synchronizing.
[0012] In some embodiments, the method further includes: when the second terminal is not connected with the server and the second terminal receives the first synchronization identifier sent by the first terminal, the second terminal obtains the first data from the first terminal based on the first synchronization identifier in response to a first event, wherein the first event is cooperatively processed by the first terminal and the second terminal.
[0013] In some embodiments, the method further comprises: broadcasting, by the second terminal, a second synchronization identifier to the other terminals after the data is changed, the second synchronization identifier being used to indicate second data of the second terminal after the data is changed; and sending, by the first terminal, the second data and the second synchronization identifier to the server after the first terminal receives the second data and the second synchronization identifier.
[0014] In some embodiments, the sending, by the first terminal, the second data and the second synchronization identifier to the server after the first terminal receives the second data and the second synchronization identifier comprises: when the first terminal receives the second synchronization identifier sent by the second terminal, the first terminal acquires the second data from the second terminal based on the second synchronization identifier in response to a second event, the second event being processed by the first terminal and the second terminal cooperatively; and the first terminal sends the second data and the second synchronization identifier to the server.
[0015] In some embodiments, the system further comprises a third terminal, and the method further comprises: receiving, by the third terminal, the second data and the second synchronization identifier from the server when the third terminal is connected to the server.
[0016] In the embodiments of the present application, the first terminal is connected to the server, and the second terminal is not connected to the server. The second terminal can broadcast a second synchronization identifier to other terminals after the data is changed, and the second synchronization identifier can indicate second data of the second terminal after the data is changed. When the first terminal acquires the second data and the second synchronization identifier from the second terminal, the first terminal can send the second data and the second synchronization identifier to the server as a relay device, so that other devices (such as the third terminal) receiving the second synchronization identifier after the first terminal can acquire the second data from the server without establishing a special connection with the second terminal to acquire the second data, thereby improving the synchronization efficiency and the online rate of the second terminal.
[0017] In some embodiments, the first synchronization identifier comprises a first version identifier, and the first version identifier is used to indicate a data version of the first terminal after the data is changed.
[0018] In some embodiments, the second terminal stores a third synchronization identifier, the third synchronization identifier comprises a second version identifier, and the second version identifier is used to indicate a data version of the first terminal stored by the second terminal. The second terminal acquires the first data by: when the data version indicated by the first version identifier is different from the data version indicated by the second version identifier, the second terminal acquires the first data.
[0019] The second terminal compares the data version of the current synchronization (i.e., the data version indicated by the first synchronization identifier) with the data version of the previous synchronization, and performs the subsequent steps of synchronizing with the first terminal in a case where the data version of the current synchronization is different from the data version of the previous synchronization, thereby improving the problem that the data version synchronized by the second terminal is inconsistent with the data version of the first terminal, and improving the reliability of synchronization.
[0020] In some embodiments, the first synchronization identifier comprises a first water level identifier, and the first water level identifier is used to indicate the data type of the data changed by the first terminal.
[0021] In some embodiments, the first water level identifier comprises at least one bit, and each bit corresponds to a data type.
[0022] In some embodiments, the synchronization identifier comprises an m-bit version identifier and an n-bit water level identifier, and n and m are positive integers greater than or equal to 1. The version identifier can be increased by a preset value (such as 1) each time the terminal changes data. The water level identifier comprises n bits, each bit corresponding to a data type, and each bit having a value of 0 or 1, wherein 0 indicates that the data type corresponding to the bit has not changed, and 1 indicates that the data type corresponding to the bit has changed.
[0023] In a second aspect, the embodiments of the present application provide a terminal, which has the functions of implementing the behaviors of the first terminal, the second terminal or the third terminal in the above aspects and possible implementation manners of the above aspects. The functions can be implemented by hardware, or by hardware executing corresponding software. The hardware or software comprises one or more modules or units corresponding to the above functions. For example, a transceiving module or unit, a processing module or unit, an obtaining module or unit, etc., wherein the processing module or unit can be used for data change, judging whether the condition of another terminal for data synchronization is met, judging whether to obtain data (such as first data, a first synchronization identifier, second data or a second synchronization identifier) from a server or another terminal, etc.; the transceiving module or unit can be used for receiving data sent by another terminal or a server, and / or sending data to a server or another terminal.
[0024] In a third aspect, the embodiments of the present application provide a terminal, comprising a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to execute the method performed by the first terminal, the second terminal or the third terminal in any one of the above first aspect when the computer program is invoked.
[0025] In a fourth aspect, an embodiment of the present application provides a chip system, the chip system comprising a processor, the processor being coupled with a memory, and the processor executing a computer program stored in the memory to implement the method performed by the first terminal, the second terminal or the third terminal in any one of the first aspect.
[0026] The chip system can be a single chip or a chip module composed of multiple chips.
[0027] In a fifth aspect, an embodiment of the present application provides a computer readable storage medium, having stored thereon a computer program, the computer program being executed by a processor to implement the method performed by the first terminal, the second terminal or the third terminal in any one of the first aspect.
[0028] In a sixth aspect, an embodiment of the present application provides a computer program product, which, when running on a terminal, causes the terminal to perform the method performed by the first terminal, the second terminal or the third terminal in any one of the first aspect.
[0029] In a seventh aspect, an embodiment of the present application provides a system, the system comprising a first terminal, a second terminal and a server, the first terminal performing the method performed by the first terminal in any one of the first aspect, the second terminal performing the method performed by the second terminal in any one of the first aspect, and the server performing the method performed by the server in any one of the first aspect.
[0030] In some embodiments, the system further comprises a third terminal, the third terminal performing the method performed by the third terminal in any one of the first aspect.
[0031] It can be understood that the beneficial effects of the second aspect to the seventh aspect can be referred to the related description of the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS
[0032] FIG. 1 is a structural schematic diagram of a terminal provided by an embodiment of the present application;
[0033] FIG. 2 is a structural block diagram of a system provided by an embodiment of the present application;
[0034] FIG. 3 is a flow schematic diagram of a method for sending data provided by an embodiment of the present application;
[0035] FIG. 4 is a flow schematic diagram of a method for acquiring data provided by an embodiment of the present application;
[0036] FIG. 5 is a flow schematic diagram of a method for synchronizing data provided by an embodiment of the present application;
[0037] FIG. 6 is a flow schematic diagram of another method for synchronizing data provided by an embodiment of the present application;
[0038] FIG. 7 is a structural block diagram of another system provided by an embodiment of the present application;
[0039] FIG. 8 is a flow diagram of another method for synchronizing data provided by an embodiment of the present application;
[0040] FIG. 9 is a flow diagram of another method for synchronizing data provided by an embodiment of the present application;
[0041] FIG. 10 is a flow diagram of another method for synchronizing data provided by an embodiment of the present application;
[0042] FIG. 11 is a flow diagram of another method for synchronizing data provided by an embodiment of the present application;
[0043] FIG. 12 is a flow diagram of another method for synchronizing data provided by an embodiment of the present application;
[0044] FIG. 13 is a structural block diagram of another system provided by an embodiment of the present application. DETAILED DESCRIPTION
[0045] The method for synchronizing data provided by the embodiments of the present application can be applied to a terminal such as a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc. The embodiments of the present application do not limit the specific type of the terminal.
[0046] FIG. 1 is a structural diagram of a terminal 100 provided by an embodiment of the present application. The terminal 100 can include a processor 110, a memory 120, a communication module 130, etc.
[0047] The processor 110 can include one or more processing units, and the memory 120 is configured to store program codes and data. In the embodiments of the present application, the processor 110 can execute computer execution instructions stored in the memory 120, to control and manage the actions of the terminal 100.
[0048] The communication module 130 can be used for communication between various internal modules of the terminal 100, or communication between the terminal 100 and a network or other external terminals, etc. For example, the communication module 130 can provide a wireless communication solution applied to the terminal 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR) technology, etc. Alternatively, the communication module 130 can provide a wireless communication solution applied to the terminal 100, including 2G / 3G / 4G / 5G, etc.
[0049] Optionally, the terminal 100 can further include a display screen 140, which can display images or videos in a human-computer interaction interface, etc.
[0050] Optionally, the terminal 100 can further include peripheral devices 150, such as a mouse, a keyboard, a speaker, a microphone, etc.
[0051] It should be understood that the structure of the terminal 100 is not limited in the embodiments of the present application except for the various components or modules listed in FIG. 1. In other embodiments of the present application, the terminal 100 can further include more or less components than those shown, or combine certain components, or split certain components, or different component arrangements. The components shown can be implemented in hardware, software or a combination of software and hardware.
[0052] In order to facilitate understanding of the technical solutions in the embodiments of the present application, the application scenarios of the embodiments of the present application will be introduced first.
[0053] With the continuous development of terminal technology, the number and types of terminals around users are growing. Multiple terminals can be connected to each other to form a super terminal or super system, providing users with more diverse services and experiences. In order to realize networking and collaboration between multiple terminals, data synchronization is needed between the multiple terminals.
[0054] For example, the terminal synchronizes device hardware information of the terminal to another terminal, so that the another terminal can determine the hardware type and state included in the terminal based on the device hardware information, and then can control the hardware on the terminal based on the device hardware information. If the terminal does not synchronize the device hardware information to the another terminal, the another terminal cannot determine which hardware is included in the terminal, and cannot control the hardware on the terminal.
[0055] As can be seen from the above, when the efficiency of synchronizing data between terminals is low, it can cause the terminal to fail to timely group with other terminals, i.e., the online success rate of the terminal is low, or cause other terminals to fail to use the services of the terminal, i.e., the online success rate of the service is low.
[0056] From the perspective of a user, when using a terminal to perform a distributed service, the following problems can exist: in the device discovery stage, the terminal cannot discover a peer device; in the device connection stage, the terminal cannot connect to the peer device or the connection is slow; in the distributed service execution stage, disconnection and lag problems occur.
[0057] In some embodiments, the terminal can establish a connection with another terminal respectively, and send data to be synchronized to the another terminal based on the connection. If N terminals are grouped, one terminal needs to establish a connection with other N-1 terminals and perform data synchronization, i.e., a total of N*(N-1) times of data synchronization is needed, which is very inefficient. For example, in a consumer scenario, 4 terminals are grouped, and 12 times of data synchronization is needed, which takes about 60 seconds of latency, and the online success rate is about 15%; in a store scenario, 20 terminals are grouped, and 380 times of data synchronization is needed, which takes about 300 seconds of latency, and the online success rate is about 8%.
[0058] To solve at least part of the above technical problems, the present application provides a method and system for synchronizing data.
[0059] In order to facilitate understanding of the technical solutions in the embodiments of the present application, the following first explains some terms involved in the embodiments of the present application:
[0060] Data synchronization includes that a terminal sends at least part of data in the terminal to another terminal, so that the terminal and the other terminal have the same at least part of data. In some embodiments, the data synchronized by the terminal and the other terminal can be used for networking connection or performing distributed services between the terminal and the other terminal. In some embodiments, the type of data synchronized can include device profile (DP), distributed hardware data or distributed scheduling information. In some embodiments, the DP includes device identification, device type or device storage capacity. In some embodiments, the distributed hardware data includes parameters of devices such as microphones, speakers, cameras, etc. In some embodiments, the distributed scheduling information includes various application information supporting scheduling. In other embodiments, the data can include more or less data types than the foregoing. When the data in the terminal is changed, the changed data needs to be synchronized to the other terminal.
[0061] The synchronization identifier can be used to indicate the data changed in the terminal, i.e. the data to be synchronized. In some embodiments, the synchronization identifier can include version identifier and water level identifier. The version identifier is used to indicate the version of the data in the terminal. When the version of the data in the terminal is changed (i.e. there is at least one type of data change), the version identifier can be incremented in turn, thereby indicating the version of the changed data. The water level identifier is used to indicate the type of data to be synchronized. In some embodiments, the synchronization identifier can also be referred to as water level version number, wherein the version identifier is version number and the water level identifier is water level number.
[0062] In some embodiments, the data structure of the synchronization identifier can be as shown in Table 1 below.
[0063] Table 1
[0064] As can be seen from Table 1 above, the synchronization identifier includes m bits of version identifier and n bits of water level identifier, and n and m are positive integers greater than or equal to 1. Each time the terminal changes the data, the version identifier can be increased by a preset value (such as 1). The water level identifier includes n bits, each bit corresponding to a type of data, and each bit has a value of 0 or 1, wherein 0 indicates that the type of data corresponding to the bit has not changed, and 1 indicates that the type of data corresponding to the bit has changed.
[0065] For example, the length of the synchronization identifier is 15 bits, the first 3 bits are water level identifier, and correspond to DP, distributed scheduling information and distributed hardware data respectively, and the last 12 bits are version identifier, i.e. the value range of the version identifier is 0x000-0xfff. The synchronization identifier 1 generated by the terminal 1 is 010 0000 0000 0111, i.e. the current change is the 7th change, and the changed data type is distributed scheduling information. If the terminal 1 changes the distributed hardware data again, another synchronization identifier 2 generated can be 001 0000 0000 1000, i.e. the current change is the 8th change, and the changed data type is distributed scheduling information. The synchronization identifier 2 is greater than the synchronization identifier 1, and can indicate that the data version corresponding to the synchronization identifier 2 is newer than the data version corresponding to the synchronization identifier 1.
[0066] It can be understood that the data structure of the synchronization identifier is described above only by using the above table 1, but is not limited thereto, and in some other embodiments, the synchronization data can also have other data formats.
[0067] The technical solutions of the present application will be described in detail below with specific examples. The following specific examples can be combined with each other, and the same or similar concepts or processes can not be described in some examples.
[0068] Please refer to FIG. 2, which is a schematic diagram of a system provided by an embodiment of the present application, the system comprising a server 200 and a plurality of terminals (only 3 terminals are shown in the figure). Among them, the terminal and the server can be connected through the network, and the terminal and the terminal can communicate through the broadcast mode or through the network connection.
[0069] The server 200 can receive the data changed by the terminal and the synchronization identifier corresponding to the data, and can also send the data and the synchronization identifier to another terminal, wherein the synchronization identifier can be used to indicate the data changed by the terminal. In some embodiments, the server 200 can be referred to as a consumer cloud.
[0070] The terminal can provide the data changed by the terminal to another terminal when the data is changed, i.e. to synchronize the data to the peer, and can also obtain the data changed by the other terminal, i.e. to accept the data synchronized by the peer.
[0071] Taking the data change of the terminal 1 device as an example.
[0072] The terminal 1 determines the data 1 after the data of the terminal 1 is changed and the synchronization identifier 1 corresponding to the data 1. The terminal 1 broadcasts the synchronization identifier 1 to other terminals, thereby notifying the other terminals that the terminal 1 has the data 1 to be synchronized. The terminal 1 also uploads the data 1 and the synchronization identifier 1 to the server 200, and the server 200 can also send the synchronization identifier 1 to other terminals when the data 1 and the synchronization identifier 1 are obtained, thereby notifying the other terminals that the terminal 1 has the data 1 to be synchronized.
[0073] The terminal 2 determines that the terminal 1 has data change when the synchronization identifier 1 is obtained. Since the terminal 2 is connected with the server 200, the terminal 2 can receive the synchronization identifier 1 sent by the terminal 1 and the synchronization identifier 1 sent by the server 200, and in order not to establish a connection with the terminal 1 specially for synchronizing the data 1, the terminal 2 can download the data 1 from the server 200 based on the synchronization identifier 1.
[0074] The terminal 3 determines that the terminal 1 has data change when the synchronization identifier 1 of the terminal 1 is obtained. Since the terminal 3 is not connected with the server 200, the terminal 3 can receive the synchronization identifier 1 sent by the terminal 1, and obtain the data 1 from the terminal 1 based on the synchronization identifier 1.
[0075] As can be seen from the above, the terminal 1 and the server 200 can send the synchronization identifier 1 to the terminal 2 and the terminal 3. Taking the terminal 2 obtaining the data 1 as an example, when the terminal 2 obtains the synchronization identifier 1 sent by the server 200, the terminal 2 also obtains the data 1 from the server 200; when the terminal 2 only obtains the synchronization identifier 1 sent by the terminal 1, the terminal 2 obtains the data 1 from the terminal 1.
[0076] In some embodiments, when the terminal 3 only receives the synchronization identifier 1 sent by the terminal 1, in order to improve the problem that the terminal 3 establishes a connection with the terminal 1 specially for data synchronization, the terminal 3 can only obtain the data 1 from the terminal 1 in the case of a service trigger (i.e. on-demand synchronization), otherwise, the terminal 3 does not synchronize data with the terminal 1 until the terminal 3 receives the synchronization identifier 1 sent by the server 200, and then obtains the data 1 from the server 200 based on the synchronization identifier 1.
[0077] In some embodiments, the synchronization identifier 1 can be used to indicate the data version of the terminal 1 after the data change, and the terminal 2 or the terminal 3 can determine whether to acquire the data 1 based on the synchronization identifier 1 before acquiring the data 1 based on the synchronization identifier 1. Taking the terminal 2 as an example, the terminal 2 also stores a synchronization identifier 2, which can indicate the data version of the terminal 1 stored by the terminal 2. The terminal 2 compares the data version indicated by the synchronization identifier 1 with the data version indicated by the synchronization identifier 2. If the data version indicated by the synchronization identifier 1 is different from the data version indicated by the synchronization identifier 2, the terminal 2 acquires the data 1 based on the synchronization identifier 1. If the data version indicated by the synchronization identifier 1 is the same as the data version indicated by the synchronization identifier 2, the terminal 2 ignores the synchronization identifier 1.
[0078] In the system, the terminal connected with the server 200 among the plurality of terminals can acquire the data 1 from the server 200 in a similar or identical manner to the terminal 2, and the terminal not connected with the server 200 among the plurality of terminals can acquire the data 1 from the terminal 1 in a similar or identical manner to the terminal 3. When the data synchronization of the terminal 1 is completed, the server 200 and each terminal among the plurality of terminals can include the data 1 and the synchronization identifier 1 of the terminal 1.
[0079] Please refer to FIG. 3, which is a flow chart of a method for sending data provided by an embodiment of the present application. The method can be used for a first terminal to send data to other terminals or a server after a data change. It should be noted that the method is not limited to the specific order described in FIG. 3 and the following description. It should be understood that in some embodiments, the order of some steps in the method can be exchanged according to actual needs, or some steps in the method can be omitted or deleted. The method includes the following steps:
[0080] S301, the first terminal makes a data change.
[0081] After the data change, the first terminal can generate first data and a first synchronization identifier.
[0082] In some embodiments, the first data can be data required by the first terminal to connect with other terminals to form a network or to cooperatively execute a distributed service. For example, the first data can include distributed scheduling information of the first terminal, a DP of the first terminal, or distributed hardware data of the first terminal.
[0083] In some embodiments, the data change of the first terminal can include newly generating the first data, or can include updating another third data already existing to obtain the first data. Alternatively, in some other embodiments, the first terminal can also change data in other ways to obtain the changed first data.
[0084] In some embodiments, the first synchronization identifier corresponds to the first data, and the first synchronization identifier is used to indicate the changed first data of the first terminal.
[0085] In some embodiments, the first synchronization identifier can include a first version identifier and a first watermark identifier, the first version identifier is used to indicate a data version of the changed first data of the first terminal, and the first watermark identifier is used to indicate a data type of the changed first data of the first terminal.
[0086] In some embodiments, the first terminal can obtain a fourth version identifier generated after a previous data change in the history, and increment the fourth version identifier to obtain the first version identifier.
[0087] S302, the first terminal broadcasts the first synchronization identifier to other terminals.
[0088] The first terminal broadcasts the first synchronization identifier to other terminals, so that the other terminals perceive that the first terminal has changed data.
[0089] In some embodiments, the first terminal can broadcast the first synchronization identifier to other terminals immediately after determining the first synchronization identifier.
[0090] In some embodiments, the first terminal can send the first data to other terminals.
[0091] S303, the first terminal determines whether the first terminal is connected to the server. If yes, S304 is executed, otherwise, the process ends.
[0092] S304, the first terminal sends the first data and the first synchronization identifier to the server.
[0093] After the first terminal changes data, the first terminal sends the changed first data and the first identifier to the server, so that the server can provide the first data and the first identifier to other terminals.
[0094] The first terminal can send the first data and the first synchronization identifier to the server based on the connection between the first terminal and the server. When the server obtains the first data and the first synchronization identifier, the server can store the first data and the first synchronization data correspondingly.
[0095] In some embodiments, the first terminal can send a device identifier of the first terminal to the server, and the server can store the first data, the first synchronization identifier and the first terminal device identifier correspondingly.
[0096] In some embodiments, when the first terminal determines that it is not connected to the server, the first terminal can execute S303 again after a preset first time interval to determine whether it is connected to the server, and when it is determined that the first terminal is connected to the server, the first terminal executes S304 to send the first data and the first synchronization identifier to the server.
[0097] In some embodiments, the timing of the first terminal performing S302 to broadcast the first synchronization identifier to other terminals can be independent of the timing of the first terminal performing S303-S304. For example, the first terminal can perform S302 and S304 simultaneously, i.e., broadcast the first synchronization identifier and send the first data and the first synchronization identifier to the server at the same time.
[0098] In some embodiments, S302 can be omitted, or S303-S304 can be omitted. For example, when the first terminal is connected to the server, the first terminal can perform S304 without performing S302, i.e., send the first data and the first synchronization identifier to the server without broadcasting the first synchronization identifier.
[0099] In the embodiments of the present application, the first terminal has data change, and obtains the first data and the first synchronization identifier after the data change. The first terminal broadcasts the first synchronization identifier to other terminals, so that the other terminals perceive that the first terminal has data change. The first terminal sends the first data and the first synchronization identifier to the server, so that the other terminals can obtain the first data from the server, which increases the way for the other terminals to obtain the first data, and makes the way for the other terminals to synchronize with the first terminal more flexible.
[0100] Please refer to FIG. 4, which is a flowchart of a method for obtaining data provided by the embodiments of the present application. The method can be used for the second terminal to obtain the first data of the first terminal after the first terminal has data change, and the second terminal is any terminal except the first terminal. It should be noted that the method is not limited to the specific order described in FIG. 4 and the following description, and it should be understood that in some embodiments, the order of some steps in the method can be exchanged according to actual needs, or some steps in the method can be omitted or deleted. The method includes the following steps:
[0101] S401, the second terminal obtains the first synchronization identifier.
[0102] When the second terminal obtains the first synchronization identifier, it can be determined that the first terminal has data change. In some embodiments, the second terminal can obtain the first synchronization identifier broadcast by the first terminal. In other embodiments, if the second terminal is connected to the server, the second terminal can obtain the first synchronization identifier from the server. Alternatively, in other embodiments, the second terminal can obtain the first synchronization identifier through other ways.
[0103] In some embodiments, the first synchronization identifier includes a first version identifier and / or a first water level identifier, and the second terminal can determine the data version of the first terminal after the data change based on the first version identifier, and determine the data type of the first terminal after the data change based on the first water level identifier.
[0104] S402, the second terminal determines whether there is a service triggered synchronization. If yes, S403 is executed, otherwise, the process ends.
[0105] The second terminal determines whether there is a service triggered synchronization, and performs subsequent steps to synchronize with the first terminal when there is a service triggered synchronization, i.e. on-demand synchronization, which reduces the pressure on the first terminal or server, so that other terminals in need can more quickly obtain the first data and synchronize with the first terminal, improving the synchronization efficiency and online rate in the process of distributed device networking.
[0106] In some embodiments, the second terminal determining that there is a service triggered synchronization can include the second terminal detecting a first event, the first event being cooperatively processed by the first terminal and the second terminal. In some embodiments, the first event is cooperatively processed by the first terminal and the second terminal based on the first data. For example, the first event can include the second terminal requesting to connect with the first terminal, or the second terminal requesting to cooperatively execute a distributed service with the first terminal (e.g. the second terminal requesting to cast to the first terminal).
[0107] In some embodiments, the first terminal can, after a preset second time interval without service triggered synchronization, execute S402 again to determine whether there is a service triggered synchronization, and perform subsequent steps to obtain the first data when it is determined that there is a service triggered synchronization.
[0108] S403, the second terminal determines whether the data version is different from the previous synchronization. If yes, S404 is executed, otherwise, the process ends.
[0109] The second terminal compares the data version of the current synchronization (i.e. the data version indicated by the first synchronization identifier) with the data version of the previous synchronization, and performs subsequent steps to synchronize with the first terminal when it is determined that the data version of the current synchronization is different from the data version of the previous synchronization, which improves the problem that the data version synchronized by the second terminal is inconsistent with the data version of the first terminal that has changed, and improves the reliability of synchronization.
[0110] In some embodiments, the first synchronization identifier includes a first version identifier, and the second terminal can obtain a third synchronization identifier stored by the second terminal, wherein the third synchronization identifier is generated by the first terminal when the second terminal previously synchronizes with the first terminal, and the third synchronization identifier includes a second version identifier, the second version identifier being used to indicate the data version of the first terminal stored by the second terminal. The second terminal compares the second version identifier with the first version identifier. If the data version indicated by the first version identifier is different from the data version indicated by the second version identifier, S404 is executed, otherwise, the process ends.
[0111] S404, the second terminal determines whether the second terminal is connected with the server. If yes, S405 is executed, otherwise, S406 is executed.
[0112] S405, the second terminal receives the first data from the server.
[0113] When the second terminal is connected with the server, the second terminal can obtain the first data from the server, so that it is not necessary to establish a connection with the first terminal specially for obtaining the first data, and the synchronization efficiency, the device online rate of the first terminal and the service online rate are improved.
[0114] In some embodiments, after obtaining the first data, the second terminal can update the third synchronization identifier to the second synchronization identifier.
[0115] S406, the second terminal obtains the first data from the first terminal.
[0116] When the second terminal is not connected with the server, the second terminal can obtain the first data from the first terminal, and the reliability of obtaining the first data is improved.
[0117] In some embodiments, the execution order of any two steps of S402, S403 and S404 can be interchanged.
[0118] For example, the second terminal can first execute S403 to determine whether the data version of this synchronization is different from the data version of the previous synchronization, if yes, S403 is executed to determine whether the synchronization is triggered by a service, otherwise, the process is ended; then, in S403, if it is determined that the synchronization is triggered by a service, S404 is executed to determine whether the first data is obtained from the server or the first terminal.
[0119] For example, the second terminal can first execute S404 to determine whether the first data is obtained from the server or the first terminal, then execute S402 and S403, and when it is determined to synchronize with the first terminal, the first data is obtained from the determined server or the first terminal.
[0120] In some embodiments, at least one of S402 and S403 can be omitted.
[0121] In some embodiments, the step of S404 can be omitted, and correspondingly, if the second terminal only obtains the first synchronization identifier broadcast by the first terminal, the second terminal obtains the first data from the first terminal; if the second terminal only obtains the first synchronization identifier sent by the server, or if the second terminal obtains both the first synchronization identifier broadcast by the first terminal and the first synchronization identifier sent by the server, the second terminal obtains the first data from the server.
[0122] In the embodiments of the present application, when the second terminal acquires the first synchronization identifier, the second terminal can acquire the first data from the server in the case of being connected with the server, so that the connection with the first terminal for acquiring the first data is not necessarily established, the synchronization efficiency, the device online rate of the first terminal and the service online rate are improved; or the second terminal acquires the first data from the first terminal in the case of not being connected with the server, the reliability of acquiring the first data is improved. The second terminal can acquire the first data on demand only in the case of having a service trigger, the pressure of the first terminal or the server is reduced, other terminals in need can acquire the first data and synchronize with the first terminal more quickly, and the synchronization efficiency and the online rate in the process of distributed device networking are improved. The second terminal synchronizes with the first terminal in the case of determining that the data version of this synchronization is different from the data version of the previous synchronization, the problem that the data version synchronized by the second terminal is inconsistent with the data version of the first terminal in which data is changed is improved, and the reliability of synchronization is improved.
[0123] In some embodiments, the second terminal can also synchronize with the first terminal by other methods than those shown in FIG. 4. For example, the server actively sends the first data and the first synchronization identifier to the second terminal when the server acquires the first data and the first synchronization identifier of the first terminal.
[0124] In the above FIG. 3 and FIG. 4, the method of sending data by the first terminal when the data is changed is illustrated, and the method of acquiring data by the second terminal when the data change is perceived is illustrated. The above method of sending data and the method of acquiring data can be combined with each other, so as to realize the data synchronization between terminals. Next, the first terminal, the second terminal and the third terminal will be taken as examples, and the above method of sending data and the method of acquiring data will be combined to illustrate some methods of synchronizing data between terminals. In some embodiments, in order to realize the data synchronization between terminals, the above method of sending data and the method of acquiring data can be combined in other ways than the following several combination ways.
[0125] Please refer to FIG. 5, which is a flowchart of a method of synchronizing data provided by the embodiments of the present application. The method can be used for the case that the first terminal 300 and the second terminal 400 are both connected with the server 200 (i.e. the first terminal 300 and the second terminal 400 are both online), and the first terminal 300 synchronizes data with the second terminal 400 when the data of the first terminal 300 is changed. The second terminal 400 can be any terminal except the first terminal 300. It should be noted that the method is not limited to the specific order described in FIG. 5 and the following description, and it should be understood that in some embodiments, the order of some steps in the method can be exchanged with each other according to actual needs, or some steps can be omitted or deleted. The method includes the following steps:
[0126] S501, the first terminal 300 broadcasts a first synchronization identifier to other terminals after data change, the first synchronization identifier being used to indicate the first data of the first terminal 300 after data change.
[0127] In some embodiments, the first terminal 300 can perform S501 in the same or similar way as S302.
[0128] S502, the first terminal 300 sends the first data and the first synchronization identifier to the server 200.
[0129] In some embodiments, the first terminal 300 can perform S502 in the same or similar way as S304.
[0130] In some embodiments, the first terminal 300 can perform S502 first, and then perform S501, or the first terminal 300 can perform S501 and S502 at the same time.
[0131] S503, the second terminal 400 receives the first synchronization identifier from the server 200.
[0132] In order to facilitate the second terminal 400 to perceive that the first terminal 300 has data change, the second terminal 400 can receive the first synchronization identifier from the server 200.
[0133] In some embodiments, the server 200 can send the first synchronization identifier to the second terminal 400. In some embodiments, when the server 200 obtains the first synchronization identifier and the first data from the first terminal 300, the server 200 can send the first synchronization identifier to the second terminal 400.
[0134] S504, if the second terminal 400 receives the first synchronization identifier sent by the server 200, the second terminal 400 obtains the first data from the server 200 based on the first synchronization identifier.
[0135] When the second terminal 400 acquires the first synchronization identifier sent by the server 200, it can be determined that there is data change in the first terminal 300. Since the second terminal 400 is currently connected with the server 200, in order to avoid acquiring the first data by establishing a connection with the first terminal 300, and to improve the synchronization efficiency between the first terminal 300 and the second terminal 400, the second terminal 400 acquires the first data from the server 200, regardless of whether the second terminal 400 has received the first synchronization identifier sent by the first terminal 300.
[0136] In some embodiments, the second terminal 400 can determine whether the data version of the current synchronization is different from the data version of the previous synchronization in a similar or same manner as S403, and acquire the first data from the server 200 when it is determined that the data version of the current synchronization is different from the data version of the previous synchronization.
[0137] In some embodiments, the second terminal 400 can determine whether there is a service triggered synchronization in a similar or same manner as S402, and acquire the first data from the server 200 when there is a service triggered synchronization. In some embodiments, the second terminal 400 determines that there is a service triggered synchronization by detecting a first event, and the first event is processed by the first terminal and the second terminal cooperatively. The second terminal 400 can acquire the first data from the server 200 based on the first synchronization identifier in response to the first event.
[0138] In some embodiments, the server 200 acquires the first data from the stored data based on the first synchronization identifier. Alternatively, in some other embodiments, the second terminal 400 also sends the device identifier of the first terminal 300 to the server 200, and the server 200 can acquire the first data from the stored data based on the device identifier of the first terminal 300 and the first synchronization identifier.
[0139] In some embodiments, the server 200 can send the first synchronization identifier and / or the first data to the second terminal 400 in a push manner.
[0140] In some embodiments, the second terminal 400 can also acquire the first data in other manners as shown in FIG. 3 or FIG. 4.
[0141] After S501-S504, the first terminal 300, the server 200 and the second terminal 400 all acquire the first data changed by the first terminal 300 and the first synchronization identifier, and the consistency of the data is achieved.
[0142] In the embodiment of the present application, after the data is changed, the first terminal 300 can send the first data and the first synchronization identifier to the server 200, wherein the first synchronization identifier can indicate the first data of the first terminal 300 after the change, and the second terminal 400 can obtain the first synchronization identifier from the first terminal 300 and the server 200, so as to determine that the first terminal 300 has data change. When the second terminal 400 receives the first synchronization identifier sent by the server 200, it can be determined that the current connection with the server 200 is good and the server 200 stores the first data, so the second terminal 400 obtains the first data from the server 200, without the need to specially establish the connection between the first terminal 300 and the second terminal 400 for synchronizing the first data, thereby improving the synchronization efficiency, the device online rate of the first terminal 300 and the service online rate.
[0143] Please refer to FIG. 6, which is a flow chart of another method for synchronizing data provided by the embodiment of the present application. The method can be used for the case that the first terminal 300 and the second terminal 400 are both connected with the server 200 (i.e. the first terminal 300 and the second terminal 400 are both online), and the first terminal 300 synchronizes data to the second terminal 400 when the data of the first terminal 300 is changed. The second terminal 400 can be any terminal except the first terminal 300. It should be noted that the method is not limited to the specific order described in FIG. 6 and the following description, and it should be understood that in some embodiments, the order of some steps in the method can be exchanged according to actual needs, or some steps can be omitted or deleted. The method comprises the following steps:
[0144] S501, after the data is changed, the first terminal 300 broadcasts a first synchronization identifier to other terminals, and the first synchronization identifier is used to indicate the first data of the first terminal 300 after the change.
[0145] S502, the first terminal 300 sends the first data and the first synchronization identifier to the server 200.
[0146] S503, the second terminal 400 receives the first synchronization identifier from the server 200.
[0147] S505, when the second terminal 400 obtains the first synchronization identifier broadcasted by the first terminal 300, but does not obtain the first synchronization identifier sent by the server 200, the second terminal 400 obtains the first data from the first terminal 300 when there is a service triggering synchronization.
[0148] When the second terminal 400 acquires the first synchronization identifier broadcast by the first terminal 300 but does not acquire the first synchronization identifier sent by the server 200, the server 200 can not have acquired the first data and / or the first synchronization identifier from the first terminal 300 at present, and therefore, in order to improve the reliability of acquiring the first data and the online rate and reliability of the distributed service related to the first data, the second terminal 400 can acquire the first data from the first terminal 300.
[0149] In some embodiments, the second terminal 400 determining that there is a service-triggered synchronization can include that the second terminal 400 detects a first event, the first event being processed cooperatively by the first terminal and the second terminal. The second terminal 400 can acquire the first data from the first terminal 300 based on the first synchronization identifier in response to the first event.
[0150] In some embodiments, if the second terminal 400 acquires the first synchronization identifier broadcast by the first terminal 300 but does not acquire the first synchronization identifier sent by the server 200, the second terminal 400 can acquire the first data from the server 200 when there is a service-triggered synchronization, and acquire the first data from the first terminal 300 when the acquisition fails.
[0151] In some embodiments, the second terminal 400 can also acquire the first data in other manners shown in FIG. 3 or FIG. 4.
[0152] After S501-S505, the first terminal 300, the server 200 and the second terminal 400 all acquire the first data and the first synchronization identifier changed by the first terminal 300, and data consistency is achieved.
[0153] In the embodiments of the present application, the first terminal 300 can send the first data and the first synchronization identifier to the server 200 after data change, wherein the first synchronization identifier can indicate the first data changed by the first terminal 300, and the second terminal 400 can acquire the first synchronization identifier from the first terminal 300 and the server 200, so as to determine that the first terminal 300 has data change. When the second terminal 400 only receives the first synchronization identifier sent by the first terminal 300, the second terminal 400 can also acquire the first data from the first terminal 300 when there is a service-triggered synchronization, and the reliability of acquiring the first data and synchronizing is improved.
[0154] The method shown in FIG. 5 and FIG. 6 is described in detail through an example. The length of the synchronization identifier is 15 bits, wherein the first 3 bits are water level identifiers, and correspond to DP, distributed scheduling information and distributed hardware data respectively, and the last 12 bits represent version identifiers.
[0155] Please refer to FIG. 7, the terminal 1, the terminal 2 and the terminal 3 are connected with the server 200, wherein the terminal 1 can be as the first terminal 300, and the terminal 2 and the terminal 3 can be as the second terminal 400.
[0156] At T1 moment, the terminal 1 has data change, thereby generating the data 1 (i.e. the first data) to be synchronized and the synchronization identifier 1 (i.e. the first synchronization identifier), uploading the data 1 and the synchronization identifier 1 to the server 200, and sending the synchronization identifier 1 to the terminal 2 and the terminal 3 through broadcasting. The synchronization identifier 1 is 010 0000 0000 0111, the first 3 bits of the synchronization identifier 1 represent that the data type of the data 1 of this change is distributed scheduling information, and the last 12 bits of the synchronization identifier 1 represent that the data version in the terminal 1 is 7.
[0157] At T2 moment after T1 moment, the server 200 receives the data 1 and the synchronization identifier 1, and sends the synchronization identifier 1 to the terminal 2 and the terminal 3 respectively.
[0158] Between T1 moment and T2 moment, the terminal 2 and the terminal 3 only receive the synchronization identifier 1 sent by the terminal 1, and do not receive the synchronization identifier 1 sent by the server 200, so the terminal 2 and the terminal 3 can ignore the synchronization identifier 1 sent by the terminal 1, or the terminal 2 and the terminal 3 can acquire the data 1 from the terminal 1 on demand when there is a service triggering synchronization.
[0159] After T2 moment, the terminal 2 and the terminal 3 receive the synchronization identifier 1 sent by the terminal 1 and the server 200, and determine that there is data change in the terminal 1, so the terminal 2 and the terminal 3 acquire the data 1 from the server 200, i.e. the distributed scheduling information changed by the terminal 1.
[0160] When the synchronization is completed, the terminal 1, the terminal 2, the terminal 3 and the server 200 store the data 1 and the synchronization identifier 1, and the consistency of the data is achieved.
[0161] In some embodiments, if the terminal 2 still stores the synchronization identifier 2 (i.e. the third synchronization identifier) corresponding to the terminal 1, the synchronization identifier 2 is 001 0000 0000 0110. The terminal 2 compares the last 12 bits of the synchronization identifier 1 and the last 12 bits of the synchronization identifier 2, 0000 0000 0111 is greater than 0000 0000 0110, i.e. the data version represented by the synchronization identifier 1 is different from the data version represented by the synchronization identifier 2, so the terminal 2 acquires the data 1 from the server 200.
[0162] Please refer to FIG. 8, which is a flow chart of another method for synchronizing data according to an embodiment of the present application. The method can be used for synchronizing data from the first terminal 300 to the second terminal 400 when the first terminal 300 has data change, and the first terminal 300 and the second terminal 400 are both offline, i.e., not connected to the server 200. The second terminal 400 can be any terminal except the first terminal 300. It should be noted that the method is not limited to the specific order described in FIG. 8 and the following description, and it should be understood that in some embodiments, the order of some steps in the method can be exchanged according to actual needs, or some steps can be omitted or deleted. The method includes the following steps:
[0163] S801, after the data change, the first terminal 300 broadcasts a first synchronization identifier to other terminals, the first synchronization identifier being used to indicate the first data of the first terminal 300 after the data change.
[0164] In some embodiments, the first terminal 300 can broadcast the first synchronization identifier to other terminals in the same or similar manner as the first terminal 300 broadcasts the first synchronization identifier to other terminals in S302.
[0165] S802, the second terminal 400 obtains the first data from the first terminal 300 when there is a service triggered synchronization.
[0166] In some embodiments, the third terminal can also obtain the first data from the first terminal 300 at any time after receiving the first synchronization identifier broadcasted by the first terminal 300.
[0167] In some embodiments, the second terminal 400 can determine whether there is a service triggered synchronization in the same or similar manner as S402.
[0168] In some embodiments, the second terminal 400 can determine whether the data version of this synchronization is different from the data version of the previous synchronization in the same or similar manner as S403, and obtain the first data from the first terminal 300 when it is determined that the data version of this synchronization is different from the data version of the previous synchronization and there is a service triggered synchronization.
[0169] In some embodiments, the second terminal 400 can obtain the first data from the first terminal 300 in a pull manner.
[0170] In some embodiments, the second terminal 400 can establish a connection with the first terminal 300, the second terminal 400 sends a synchronization request to the first terminal 300 based on the first synchronization identifier, and the first terminal 300 sends the first data to the second terminal 400 in response to the synchronization request.
[0171] In some embodiments, the second terminal 400 can also acquire the first data in other manners as shown in FIG. 3 or FIG. 4. For example, the first terminal 300 can actively send the first data and the first synchronization identifier to the second terminal 400.
[0172] In the embodiments of the present application, the first terminal 300 and the second terminal 400 are not connected with the server 200, and when the first terminal 300 has data update, the first terminal 300 can broadcast the first synchronization identifier to other terminals, and the second terminal 400 can acquire the first data from the first terminal 300 when there is a service triggering synchronization, thereby improving the reliability of acquiring the first data and performing synchronization.
[0173] Please refer to FIG. 9, which is a flow chart of another method for synchronizing data provided by the embodiments of the present application. The method can be used for the case that the first terminal 300 is connected with the server 200 and the second terminal 400 is not connected with the server 200 (i.e. the first terminal 300 is online and the second terminal 400 is offline), and the first terminal 300 synchronizes data to the second terminal 400 when the first terminal 300 has data change. The second terminal 400 can be any terminal except the first terminal 300. It should be noted that the method is not limited to the specific order described in FIG. 9 and the following description, and it should be understood that in some embodiments, the order of some steps in the method can be exchanged according to actual needs, or some steps can be omitted or deleted. The method includes the following steps:
[0174] S901, after the first terminal 300 has data change, the first terminal 300 broadcasts the first synchronization identifier to other terminals, and the first synchronization identifier is used to indicate the first data of the first terminal 300 after the data change.
[0175] In some embodiments, the manner in which the first terminal 300 broadcasts the first synchronization identifier to other terminals in S901 can be the same as or similar to the manner in which the first terminal 300 broadcasts the first synchronization identifier to other terminals in S302.
[0176] S902, the first terminal 300 sends the first data and the first synchronization identifier to the server 200.
[0177] In some embodiments, the manner in which the first terminal 300 sends the first data and the first synchronization identifier to the server 200 in S902 can be the same as or similar to the manner in which the first terminal 300 sends the first data and the first synchronization identifier to the server 200 in S304.
[0178] S903, the second terminal 400 acquires the first data from the first terminal 300 when there is a service triggering synchronization.
[0179] In some embodiments, the second terminal 400 performs S903 in the same or similar manner as the second terminal 400 performs S802 to acquire the first data from the first terminal 300 when there is a service triggered synchronization.
[0180] In some embodiments, the second terminal 400 can also acquire the first data in other manners as shown in FIG. 3 or FIG. 4. For example, the second terminal 400 can acquire the first data from the server 200 in the same or similar manner as the second terminal 400 acquires the first data from the server 200 in S503-S505 when there is no service triggered synchronization, until the connection between the second terminal 400 and the server 200 is restored.
[0181] In the embodiments of the present application, the first terminal 300 is connected to the server 200, and the second terminal 400 is not connected to the server 200. The first terminal 300 can broadcast the first synchronization identifier to other terminals, so that the second terminal 400 can acquire the first data in time when there is a service trigger, and improve the reliability of synchronization. Alternatively, the first terminal 300 can send the first data and the first synchronization identifier to the server 200, so that the second terminal 400 or other terminals can acquire the first data from the server 300.
[0182] Please refer to FIG. 10, which is a flow chart of another method for synchronizing data provided by the embodiments of the present application. The method can be obtained by combining the methods shown in FIG. 5, FIG. 6 and FIG. 9, and can be used for synchronizing data from the first terminal 300 to the second terminal 400 and the third terminal 500 when the first terminal 300 has data changes, and the first terminal 300 and the second terminal 400 are connected to the server 200, and the third terminal 500 is not connected to the server 200 (i.e. the first terminal 300 and the second terminal 400 are online, and the third terminal 500 is offline). It should be noted that the method is not limited to the specific order described in FIG. 10 and the following description. It should be understood that in some embodiments, the order of some steps in the method can be exchanged according to actual needs, or some steps in the method can be omitted or deleted. The method includes the following steps:
[0183] S1001, after the data is changed, the first terminal 300 broadcasts a first synchronization identifier to other terminals, and the first synchronization identifier is used to indicate the first data of the first terminal 300 after the data is changed.
[0184] In some embodiments, the first terminal 300 performs S1001 in the same or similar manner as described in detail in S501.
[0185] S1002, the first terminal 300 sends the first data and the first synchronization identifier to the server 200.
[0186] In some embodiments, the first terminal 300 performs S1002 in the manner described in detail in the foregoing S502.
[0187] S1003, the second terminal 400 receives the first synchronization identifier from the server 200.
[0188] In some embodiments, the second terminal 400 performs S1003 in the manner described in detail in the foregoing S503.
[0189] As can be seen from the foregoing S1001-S1003, the first terminal 300 and the server 200 can both send the first synchronization identifier to the second terminal 400, and the second terminal 400 can acquire the first data from the first terminal 300 or the server 200 based on different situations in which the first synchronization identifier is received, through the following S1004 or S1005; the first terminal 300 can send the first synchronization identifier to the third terminal 500, and the third terminal 500 can acquire the first data from the first terminal 300 through the following S1006.
[0190] S1004, if the second terminal 400 receives the first synchronization identifier sent by the server 200, the second terminal 400 acquires the first data from the server 200 based on the first synchronization identifier.
[0191] In some embodiments, the second terminal 400 performs S1004 in the manner described in detail in the foregoing S504.
[0192] S1005, if the second terminal 400 acquires the first synchronization identifier broadcast by the first terminal 300 but does not acquire the first synchronization identifier sent by the server 200, the second terminal 400 acquires the first data from the first terminal 300 when there is a service-triggered synchronization.
[0193] In some embodiments, the second terminal 400 performs S1005 in the manner described in detail in the foregoing S505.
[0194] S1006, the third terminal 500 acquires the first data from the first terminal 300 when there is a service-triggered synchronization.
[0195] In some embodiments, the third terminal 500 performs S1006 in the same or similar manner as the second terminal 400 performs S802 and S903 to acquire the first data from the first terminal 300 when there is a service-triggered synchronization.
[0196] In the embodiments of the present application, the first terminal 300 and the second terminal 400 are connected with the server 200, and the third terminal 500 is not connected with the server 200. When the data change occurs, the first terminal 300 can send the first synchronization identifier to the second terminal 400 and the third terminal 500 through broadcasting, so that the second terminal 400 and the third terminal 500 can both perceive that the first terminal 300 has data change. The second terminal 400 connected with the server 200 can obtain the first data from the server 200 when receiving the first synchronization identifier sent by the server 200, without having to establish a connection with the first terminal 300 specially for obtaining the first data, thereby improving the synchronization efficiency, the device online rate and the service online rate of the first terminal 300. The third terminal 500 not connected with the server 200 can obtain the first data from the first terminal 300 when there is a service triggering synchronization, thereby improving the reliability of obtaining the first data and performing synchronization.
[0197] The method shown in FIG. 10 is specifically described below through an example. It is assumed that the length of the synchronization identifier is 15 bits, of which the first 3 bits are the water level identifier and correspond to the DP, the distributed scheduling information and the distributed hardware data respectively, and the last 12 bits represent the version identifier.
[0198] Referring again to FIG. 2, the terminal 1 and the terminal 2 are both connected with the server 200, and the terminal 3 is not connected with the server 200, wherein the terminal 1 can be the first terminal 300, the terminal 2 can be the second terminal 400, and the terminal 3 can be the third terminal 500.
[0199] At T1 moment, the terminal 1 generates the data 1 to be synchronized (i.e. the first data) and the synchronization identifier 1 (i.e. the first synchronization identifier), uploads the data 1 and the synchronization identifier 1 to the server 200, and sends the synchronization identifier 1 to the terminal 2 and the terminal 3 through broadcasting. The synchronization identifier 1 is 010 0000 0000 0111, the first 4 bits of the synchronization identifier 1 indicate that the data type of the data 1 changed this time is the distributed scheduling information, and the last 12 bits of the synchronization identifier 1 indicate that the data version in the terminal 1 is 7.
[0200] At T2 moment after T1 moment, the server 200 receives the data 1 and the synchronization identifier 1, and sends the synchronization identifier 1 to the terminal 2. The terminal 2 receives the synchronization identifier 1, the terminal 2 determines that there is data change in the terminal 1, and the terminal 2 is connected with the server 200, so the terminal 2 obtains the data 1 from the server 200, i.e. the distributed scheduling information changed by the terminal 1.
[0201] At T3 moment after T1 moment, the terminal 3 receives the synchronization identifier 1 sent by the terminal 1, the terminal 3 determines that there is data change in the terminal 1, but the terminal 3 is not connected with the server 200, so the terminal 3 obtains the data 1 from the terminal 1, i.e. the distributed scheduling information changed by the terminal 1.
[0202] When the synchronization is completed, the terminal 1, the terminal 2, the terminal 3 and the server 200 store the data 1 and the synchronization identifier 1, and the consistency of the data is achieved.
[0203] Please refer to FIG. 11, which is a flow chart of another method for synchronizing data provided by an embodiment of the present application. The method can be used in a case where the first terminal 300 is connected with the server 200, the second terminal 400 is not connected with the server 200 (i.e. the first terminal 300 is online, and the second terminal 400 is offline), and the second terminal 400 offline has data change. In this case, the first terminal 300 acts as a relay device to synchronize the data changed by the second terminal 400 to the server 200, so that other terminals can obtain the data changed by the second terminal 400 from the server 200. It should be noted that the method is not limited to the specific order described in FIG. 11 and the following description. It should be understood that in some embodiments, the order of some steps in the method can be exchanged according to actual needs, or some steps can be omitted or deleted. The method includes the following steps:
[0204] S1101, after the data is changed, the second terminal 400 broadcasts a second synchronization identifier to other terminals, the second synchronization identifier being used to indicate the second data of the second terminal 400 after the data is changed.
[0205] For example, the second data can include distributed scheduling information of the second terminal 400, a DP of the second terminal 400, or distributed hardware data of the second terminal 400.
[0206] In some embodiments, the second terminal 400 can perform S1101 in the same or similar manner as the first terminal 300 performs S501 to broadcast the first synchronization identifier to other terminals.
[0207] S1102, the first terminal 300 obtains the second data from the second terminal 400 when there is a service triggered synchronization.
[0208] In some embodiments, the first terminal 300 can perform S1102 in the same or similar manner as the second terminal 400 performs S802 or S903 to obtain the first data from the first terminal 300 when there is a service triggered synchronization.
[0209] In some embodiments, the first terminal 300 determines that there is a service trigger synchronization, which can include that the first terminal 300 detects a second event, the second event being processed by the first terminal 300 and the second terminal 400 in cooperation. In some embodiments, the second event is processed by the first terminal 300 and the second terminal 400 based on the second data in cooperation. The first terminal 300 can obtain the second data from the second terminal 400 based on the second synchronization identifier in response to the second event.
[0210] S1103, the first terminal 300 sends the second data and the second synchronization identifier to the server 200.
[0211] When the first terminal 300 obtains the second data and the second synchronization identifier from the second terminal 400, the first terminal 300 can send the second data and the second synchronization identifier to the server 200 as a relay device, so that the server 200 also obtains the second data and the second synchronization identifier. Then, when other terminals obtain the second synchronization identifier, they can obtain the second data from the server 200 without establishing a special connection with the second terminal 400 for obtaining the second data, thereby improving the synchronization efficiency and online rate of the other terminals.
[0212] In some embodiments, the first terminal 300 can also send the device identifier of the second terminal 400 to the server 200, and the server 200 can store the device identifier of the second terminal 400 corresponding to the second data and the second synchronization identifier.
[0213] In some embodiments, the first terminal 300 can also obtain the second data and the second synchronization identifier in other ways and perform S1103 to send the second data and the second synchronization identifier to the server 200.
[0214] In the embodiments of the present application, the first terminal 300 is connected with the server 200, and the second terminal 400 is not connected with the server 200. The second terminal 400 can broadcast the second synchronization identifier to other terminals after the data is changed, and the second synchronization identifier can indicate the second data of the second terminal 400 after the data is changed. When the first terminal 300 obtains the second data and the second synchronization identifier from the second terminal 400, the first terminal 300 can send the second data and the second synchronization identifier to the server 200 as a relay device, so that other devices that receive the second synchronization identifier after the first terminal 300 can obtain the second data from the server 200 without establishing a special connection with the second terminal 400 for obtaining the second data, thereby improving the synchronization efficiency and the online rate of the second terminal 400.
[0215] Please refer to FIG. 12, which is a flow chart of another method for synchronizing data provided by the embodiments of the present application. After S1103 shown in FIG. 11, another third terminal 500 connected with the server 200 (i.e. the first terminal 300 and the third terminal 500 are online, and the second terminal 400 is offline) can obtain the second data changed by the offline second terminal 400 from the server 200 through S1104-S1106. It should be noted that the method is not limited to the specific order described in FIG. 12 and the following, and it should be understood that in some embodiments, the order of some steps in the method can be exchanged according to actual needs, or some steps can be omitted or deleted. The method includes the following steps:
[0216] S1104, the third terminal 500 receives the second synchronization identifier from the server 200.
[0217] In some embodiments, the third terminal 500 receives the second synchronization identifier from the server 200 in the same or similar way as the second terminal 400 receives the first synchronization identifier from the server 200 in S503.
[0218] S1105, if the third terminal 500 receives the second synchronization identifier sent by the server 200, the third terminal 500 obtains the second data from the server 200 based on the second synchronization identifier.
[0219] In some embodiments, the third terminal 500 obtains the second data from the server 200 based on the second synchronization identifier in S1105 can be the same or similar to the way the second terminal 400 obtains the first data from the server 200 based on the first synchronization identifier in S504.
[0220] S1106, if the third terminal 500 obtains the second synchronization identifier broadcasted by the second terminal 400, but does not obtain the second synchronization identifier sent by the server 200, the third terminal 500 obtains the second data from the second terminal 400 when there is a service triggered synchronization.
[0221] In some embodiments, the third terminal 500 obtains the second data from the second terminal 400 when there is a service triggered synchronization in S1106 can be the same or similar to the way the second terminal 400 obtains the first data from the first terminal 300 when there is a service triggered synchronization in S505.
[0222] In the embodiment of the present application, the first terminal 300 is connected with the server 200, and the third terminal 500 is not connected with the server 200. After the first terminal 300 has sent the second data and the second synchronization identifier to the server 200 as a relay device, the third terminal 500 connected with the server 200 can obtain the second data from the server without establishing a connection with the second terminal 400 specially for obtaining the second data, thereby improving synchronization efficiency and the online rate of the third terminal 500.
[0223] The method shown in FIG. 11 and FIG. 13 is specifically described below by an example. The length of the synchronization identifier is 15 bits, of which the first 3 bits are the water level identifier and correspond to the DP, distributed scheduling information and distributed hardware data respectively, and the last 12 bits represent the version identifier.
[0224] Please refer to FIG. 13, the terminal 1 and the terminal 2 are connected with the server 200, and the terminal 3 is not connected with the server 200, wherein the terminal 1 can be the first terminal 300, the terminal 2 can be the third terminal 500, and the terminal 3 can be the second terminal 400.
[0225] At T1, the terminal 3 generates the data 2 to be synchronized (i.e. the second data) and the synchronization identifier 3 (i.e. the second synchronization identifier), and sends the synchronization identifier 3 to the terminal 1 and the terminal 2. The synchronization identifier 3 is 001 0000 0000 1010, the first 3 bits of the synchronization identifier 3 indicate that the data type of the data 2 changed this time is the distributed hardware data, and the last 12 bits of the synchronization identifier 3 indicate that the data version in the terminal 3 is 10.
[0226] At T2 after T1, the terminal 1 receives the synchronization identifier 3, determines that there is data change in the terminal 3, and since the terminal 3 has not sent the data 2 and the synchronization identifier 3 to the server 200, the terminal 1 will not receive the synchronization identifier 3 sent by the server 200, and the terminal 1 obtains the data 2 (i.e. the distributed hardware data changed by the terminal 3) from the terminal 3. After obtaining the data 2 and the synchronization identifier 3, the terminal 1 also sends the data 2 and the synchronization identifier 3 to the server 200.
[0227] At T3 after T2, the server 200 sends the synchronization identifier 3 to the terminal 2. The terminal 2 receives the synchronization identifier 3 sent by the server 200, determines that there is data change in the terminal 3, and the terminal 2 is connected with the server 200, so the terminal 2 obtains the data 2 from the server 200.
[0228] When the synchronization is completed, the terminal 1, the terminal 2, the terminal 3 and the server 200 store the data 2 and the synchronization identifier 3, and the consistency of the data is achieved.
[0229] Based on the same inventive concept, the embodiment of the present application further provides a terminal. The terminal comprises a memory and a processor, the memory is used to store a computer program, and the processor is used to execute the method described in the above method embodiments when the computer program is called.
[0230] The terminal provided by the embodiment can execute the above method embodiments, and the implementation principle and technical effects are similar, which will not be described here.
[0231] Based on the same inventive concept, the embodiment of the present application further provides a chip system. The chip system comprises a processor, the processor is coupled with a memory, and the processor executes a computer program stored in the memory to realize the method described in the above method embodiments.
[0232] The chip system can be a single chip or a chip module composed of multiple chips.
[0233] The embodiment of the present application further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by the processor to realize the method described in the above method embodiments.
[0234] The embodiment of the present application further provides a computer program product, when the computer program product runs on the terminal, the terminal executes to realize the method described in the above method embodiments.
[0235] The integrated units described above, if realized in the form of software function units and sold or used as independent products, can be stored in a computer readable storage medium. Based on such understanding, the present application realizes all or part of the processes in the above embodiment methods, which can be completed by a computer program instructing related hardware. The computer program can be stored in a computer readable storage medium, and the computer program can realize the steps of the above method embodiments when executed by a processor. The computer program includes computer program code, which can be in the form of source code, object code, executable files or some intermediate forms. The computer readable storage medium at least includes any entity or device capable of carrying the computer program code to the terminal, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal and software distribution medium. For example, U disk, mobile hard disk, magnetic disk or optical disk, etc.
[0236] In the above embodiments, the description of each embodiment has its own focus, and the parts not described or recorded in detail in a certain embodiment can be referred to the related description of some embodiments.
[0237] Those skilled in the art can appreciate that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware, or a combination of computer software and electronic hardware. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. A person skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0238] In the embodiments provided in the present application, it should be understood that the disclosed apparatuses / devices and methods can be implemented in other ways. For example, the above-described apparatus / device embodiments are merely illustrative. For example, the division of the modules or units is merely a logical function division, and there can be another division manner in actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, device or unit, and can be electrical, mechanical or in other forms.
[0239] It should be understood that when used in the specification and the appended claims of the present application, the term "comprising" indicates the presence of the described features, integers, steps, operations, elements, and / or components, but does not exclude one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0240] It should also be understood that the term "and / or" as used in the specification and the appended claims of the present application means any combination of one or more of the associated listed items and all possible combinations thereof.
[0241] As used in the specification and the appended claims of the present application, the term "if" can be interpreted as "when" or "upon" or "in response to a determination" or "in response to detecting" depending on the context. Similarly, the phrase "if it is determined" or "if [a described condition or event] is detected" can be interpreted as meaning "upon determining" or "in response to determining" or "upon detecting [a described condition or event]" or "in response to detecting [a described condition or event]" depending on the context.
[0242] In addition, in the description of the specification and the appended claims of the present application, the terms "first", "second", "third", etc. are only used to distinguish the description, and cannot be understood as indicating or implying relative importance.
[0243] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0244] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A method of synchronizing data, characterized by, The method is applied to a system comprising a first terminal, a second terminal and a server, the first terminal is connected with the server, and the method comprises: The first terminal broadcasts a first synchronization identifier to other terminals after data is changed, the first synchronization identifier is used to indicate first data of the first terminal after the data is changed; The first terminal sends the first data and the first synchronization identifier to the server; When the second terminal is connected with the server, the second terminal receives the first synchronization identifier from the server; When the second terminal receives the first synchronization identifier sent by the server, the second terminal acquires the first data from the server based on the first synchronization identifier.
2. The method of claim 1, wherein, The method further comprises: When the second terminal receives the first synchronization identifier sent by the first terminal and does not receive the first synchronization identifier sent by the server, the second terminal acquires the first data from the first terminal based on the first synchronization identifier in response to a first event, and the first event is processed by the first terminal and the second terminal cooperatively.
3. The method according to claim 1 or 2, characterized in that, The method further comprises: When the second terminal is not connected with the server and the second terminal receives the first synchronization identifier sent by the first terminal, the second terminal acquires the first data from the first terminal based on the first synchronization identifier in response to a first event, and the first event is processed by the first terminal and the second terminal cooperatively.
4. The method of claim 3, wherein, The method further comprises: The second terminal broadcasts a second synchronization identifier to other terminals after data is changed, the second synchronization identifier is used to indicate second data of the second terminal after the data is changed; The first terminal sends the second data and the second synchronization identifier to the server after the first terminal receives the second data and the second synchronization identifier.
5. The method of claim 4, wherein, The first terminal sends the second data and the second synchronization identifier to the server after the first terminal receives the second data and the second synchronization identifier, comprising: When the first terminal receives the second synchronization identifier sent by the second terminal, the first terminal acquires the second data from the second terminal based on the second synchronization identifier in response to a second event, and the second event is processed by the first terminal and the second terminal cooperatively; The first terminal sends the second data and the second synchronization identifier to the server.
6. The method according to claim 3 or 4, characterized in that, The system further comprises a third terminal, and the method further comprises: When the third terminal is connected with the server, the second data and the second synchronization identifier are received from the server.
7. The method according to any of claims 1 to 6, characterized in that The first synchronization identifier comprises a first version identifier, and the first version identifier is used to indicate a data version of the first terminal after the data is changed.
8. The method of claim 7, wherein, The second terminal stores a third synchronization identifier, the third synchronization identifier comprises a second version identifier, and the second version identifier is used to indicate a data version of the first terminal stored by the second terminal, and the second terminal acquires the first data, comprising: When the first version identifier indicates a different data version than the second version identifier indicates, the second terminal acquires the first data.
9. The method according to any of claims 1 to 8, characterized in that, The first synchronization identifier comprises a first water level identifier, the first water level identifier being used to indicate a data type of the first terminal data change.
10. The method of claim 9, wherein, The first water level identifier comprises at least one bit, each bit corresponding to a data type.
11. A system for synchronizing data, comprising a first terminal, a second terminal and a server, characterized in that The first terminal performs the method as claimed in any one of claims 1-10, the second terminal performs the method as claimed in any one of claims 1-10, and the server performs the method as claimed in any one of claims 1-10.
12. A terminal, characterized by comprising: Comprising: a memory and a processor, the memory being used to store a computer program; the processor being used to execute the method as claimed in any one of claims 1-10 when the computer program is invoked.
13. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program, when executed by a processor, implements the method as claimed in any one of claims 1-10.
14. A chip system, characterized by Comprising: a memory and a processor, the memory being used to store a computer program; the processor being used to execute the method as claimed in any one of claims 1-10 when the computer program is invoked.
15. A computer program product, characterised in that, The computer program product, when running on a terminal, causes the terminal to execute the method as claimed in any one of claims 1-10.
Citation Information
Patent Citations
Data synchronization method, terminal, server and system based on near field communication
CN114221969A
Data synchronization method and device, electronic equipment and storage medium
CN114297306A
Information synchronous change method and device, electronic equipment and storage medium
CN116303755A
Data synchronization method and device, electronic equipment and computer readable storage medium
CN117675844A
Method and apparatus for synchronizing messages between multiple terminals
US20090106455A1