CN113746931A - Data synchronization method and device - Google Patents

Data synchronization method and device Download PDF

Info

Publication number
CN113746931A
CN113746931A CN202111062864.2A CN202111062864A CN113746931A CN 113746931 A CN113746931 A CN 113746931A CN 202111062864 A CN202111062864 A CN 202111062864A CN 113746931 A CN113746931 A CN 113746931A
Authority
CN
China
Prior art keywords
instruction
client
server
data
clients
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202111062864.2A
Other languages
Chinese (zh)
Other versions
CN113746931B (en
Inventor
潘海杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Lenovo Beijing Ltd
Original Assignee
Lenovo Beijing Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Lenovo Beijing Ltd filed Critical Lenovo Beijing Ltd
Priority to CN202111062864.2A priority Critical patent/CN113746931B/en
Publication of CN113746931A publication Critical patent/CN113746931A/en
Application granted granted Critical
Publication of CN113746931B publication Critical patent/CN113746931B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

The application discloses a data synchronization method and a data synchronization device, and the method applied to a client comprises the following steps: monitoring data to be synchronized on at least two clients under the condition that the two clients establish communication through a server; if the situation that the operation data to be synchronized exists on at least one of the at least two clients is monitored, generating a first instruction and sending the first instruction to all the clients of the at least two clients through the server, wherein the first instruction at least comprises the operation data; and if the client is monitored to have no operation data to be synchronized, executing a step of monitoring the data to be synchronized on the client.

Description

Data synchronization method and device
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a data synchronization method and apparatus.
Background
In the application scenario of multi-end interaction, instruction synchronization is required. For example, in a game application scenario, a game server needs to perform instruction synchronization with multiple user clients; for another example, in a teaching application scenario, a teacher terminal needs to synchronize commands with a plurality of student terminals.
In the currently adopted frame-locked synchronization scheme, after the server sends the instruction to each client, it is necessary to wait for each client to reply to the message that the instruction execution is completed before performing the synchronization of the next instruction, and therefore, the message reply delay of each client may cause the situation that all clients are stuck. To avoid this kind of stuck, a scheme that the server drives all the clients to play frames is adopted, that is: the server side sends instructions to all the clients according to a certain frequency.
However, this frame broadcasting scheme may result in a high amount of data transmitted between the server and the client.
Disclosure of Invention
In view of the above, the present application provides a data synchronization method and apparatus, as follows:
a data synchronization method is applied to a client and comprises the following steps:
monitoring data to be synchronized on at least two clients under the condition that the two clients establish communication through a server;
if the situation that the operation data to be synchronized exists on at least one of the at least two clients is monitored, generating a first instruction and sending the first instruction to all the clients of the at least two clients through the server, wherein the first instruction at least comprises the operation data;
and if the client is monitored to have no operation data to be synchronized, executing a step of monitoring the data to be synchronized on the client.
The above method, preferably, further comprises:
in a case where a synchronization control condition is satisfied, performing: monitoring data to be synchronized on the client;
wherein the synchronization control condition includes: from the time when the client and the server start to synchronize, the instructions generated on the client are executed completely, and the monitoring execution times are less than the monitoring preset times; the monitoring execution times are historical times for monitoring data to be synchronized on the client from the time when the client and the server start synchronizing; the preset monitoring times are the number of preset interval thresholds included from the time when the client and the server start to synchronize.
Preferably, before monitoring the data to be synchronized on the client, the method further includes:
obtaining a starting time; the starting time is the time when the server and the client start to synchronize;
obtaining an interval count value according to a time difference value between the current time and the starting time;
updating the starting time by using the current time;
monitoring the interval count value;
if the interval count value is larger than or equal to the threshold count value corresponding to the interval threshold value, executing the step of monitoring the data to be synchronized on the client, updating the interval count value according to the threshold count value, and returning to the step of monitoring the interval count value until the interval count value is smaller than the threshold count value;
and after waiting for a preset sleep time, returning to execute the step of obtaining an interval count value according to the time difference between the current time and the starting time.
In the above method, preferably, the first instruction further includes a first instruction identifier, an instruction set is configured on the client, the instruction set is used to store a target instruction sent by the server, and the instruction identifier of the target instruction is used to instruct the instruction set to execute the instructions in the instruction set according to the order between the instruction identifiers.
The above method, preferably, further comprises:
receiving a second instruction, wherein the second instruction at least comprises a second instruction identifier;
adding the second instruction to the set of instructions;
executing instructions in the instruction set starting from the second instruction identification in the instruction set.
The above method, preferably, further comprises:
under the condition that a breakpoint of instruction transmission connection is monitored, acquiring a breakpoint identification corresponding to the breakpoint;
sending a breakpoint retransmission request to the server according to the breakpoint identifier to obtain a breakpoint set sent by the server, where the breakpoint set includes historical instructions corresponding to the breakpoint identifier and historical instructions corresponding to all instruction identifiers sequenced after the breakpoint identifier;
adding historical instructions in the breakpoint set into the instruction set;
in the instruction set, starting from the breakpoint identification, executing the instructions in the instruction set.
In the above method, preferably, the operation data at least includes an object parameter and an operation parameter, and the operation data is used to instruct a target object corresponding to the object parameter to execute a corresponding operation according to the operation parameter.
In the method, preferably, the processed data corresponding to the operation parameter is fixed-point-number-type data.
A data synchronization method is applied to a server side, and the method comprises the following steps:
monitoring instructions from at least two clients in case communication is established with the clients;
if a first instruction from at least one of the at least two clients is obtained, wherein the first instruction comprises operation data, the first instruction is sent to all the at least two clients, so that the clients execute corresponding processing according to the operation data;
and if the instruction from the client is not obtained, returning to the step of monitoring the instruction from the client.
A data synchronization device applied to a client, the device comprising:
the data monitoring unit is used for monitoring the data to be synchronized on the client under the condition that at least two clients establish communication through a server; if the situation that the operation data to be synchronized exists on at least one of the at least two clients is monitored, triggering an instruction processing unit, and if the situation that the operation data to be synchronized does not exist on the client is monitored, continuously monitoring the data to be synchronized on the client;
and the instruction processing unit is used for generating a first instruction and sending the first instruction to all the clients in the at least two clients through the server, and the first instruction at least comprises the operation data.
A data synchronization device is applied to a server side, and the device comprises:
the instruction monitoring unit is used for monitoring instructions from the clients under the condition that communication is established between at least two clients; if a first instruction from at least one of the at least two clients is obtained, the first instruction comprises operation data, and an instruction transmission unit is triggered; if the instruction from the client is not obtained, returning to the step of monitoring the instruction from the client;
and the instruction transmission unit is used for giving the first instruction to all the clients in the at least two clients so that the clients execute corresponding processing according to the operation data.
A client, comprising:
the memory is used for storing the application program and data generated by the running of the application program;
a processor for executing an application to implement: monitoring data to be synchronized on at least two clients under the condition that the two clients establish communication through a server; if the fact that the operation data to be synchronized exist on at least one of the at least two clients is monitored, a first instruction is generated and is sent to all the clients of the at least two clients through the server, the first instruction at least comprises the operation data, and if the fact that the operation data to be synchronized do not exist on the clients is monitored, the data to be synchronized on the clients are continuously monitored.
A server, comprising:
the memory is used for storing the application program and data generated by the running of the application program;
a processor for executing an application to implement: under the condition of establishing communication with at least two clients, instructions from the clients are monitored, if a first instruction from at least one of the at least two clients is obtained, the first instruction contains operation data, the first instruction is sent to all the clients in the at least two clients, so that other clients execute corresponding processing according to the operation data, and if the instructions from the clients are not obtained, the instructions from the clients are continuously monitored.
A storage medium having stored therein computer-executable instructions that, when loaded and executed by a processor, implement a data synchronization method as claimed in any preceding claim.
According to the technical scheme, for any client which establishes communication through the server, the data to be synchronized on the client is monitored, and then under the condition that the operating data to be synchronized exists, the instruction is generated and is synchronously sent to all the clients through the server, and if no operating data is monitored to be synchronized, the monitoring is continued without sending the instruction to other clients, so that the data transmission amount between the server and the clients can be reduced while the operating data is synchronized.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a flowchart of a data synchronization method according to an embodiment of the present application;
FIG. 2 is a diagram illustrating at least two clients establishing communication through a server;
FIG. 3 is a diagram illustrating synchronization between multiple clients via a server;
fig. 4 is another flowchart of a data synchronization method according to an embodiment of the present application;
FIG. 5a and FIG. 5b are exemplary diagrams illustrating the determination of the synchronization control condition in the embodiment of the present application, respectively;
fig. 6 is another flowchart of a data synchronization method according to an embodiment of the present application;
FIG. 7a is a diagram illustrating an exemplary instruction synchronization process according to an embodiment of the present application;
fig. 7b is a partial flowchart of a data synchronization method according to an embodiment of the present application;
FIG. 8 is an exemplary diagram of instruction synchronization between multiple clients via a server;
FIG. 9 is an exemplary diagram of an implementation of rollback on a client in an embodiment of the present application;
fig. 10 is a flowchart of another part of a data synchronization method according to an embodiment of the present application;
FIG. 11 is a diagram illustrating an example of implementing breakpoint resuming on a client in an embodiment of the present application;
fig. 12 is a flowchart of a data synchronization method according to a second embodiment of the present application;
fig. 13 is a schematic structural diagram of a data synchronization apparatus according to a third embodiment of the present application;
fig. 14 is a schematic structural diagram of a data synchronization apparatus according to a fourth embodiment of the present application;
fig. 15 is a schematic structural diagram of a client according to a fifth embodiment of the present application;
fig. 16 is a schematic structural diagram of a server according to a sixth embodiment of the present application;
fig. 17-21 are exemplary diagrams of a game application scenario in which the present application is applied.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, a flowchart of an implementation of a data synchronization method provided in an embodiment of the present application is shown, where the method may be applied to any client that establishes communication with other clients through a server. As shown in fig. 2, at least two clients establish communication through a server, where the client may be an electronic device such as a mobile phone, a pad, a notebook, a computer, and the like, and the server may be a device such as a server. The client and the server perform data synchronization through the established communication, and specifically may perform data synchronization for one or more operated objects, for example, the client and the server synchronize movements of respective roles in a game application scenario, and for example, synchronize teaching contents between respective student terminals and teacher terminals in a teaching application scenario, and so on. The technical scheme in the embodiment is mainly used for reducing the data transmission amount between the server and the client.
Specifically, the method in this embodiment may include the following steps:
step 101: monitoring data to be synchronized on the client under the condition that at least two clients establish communication through a server, executing step 102 if the fact that the operating data to be synchronized exists on at least one of the at least two clients is monitored, and continuing executing step 101 if the fact that the operating data to be synchronized does not exist on the client is monitored, namely continuing monitoring the data to be synchronized on the client.
The scheme in this embodiment is applicable to any one of the clients shown in fig. 2, and therefore, the method in this embodiment is executed on each client. In this embodiment, one of the clients is taken as an example for explanation. The client and the server can establish communication through a wireless network or a wired network.
Specifically, in this embodiment, it may be monitored whether the operated object on the client has a state change, for example, whether the character object of the game is moved, further, whether the content is written in the teaching content, or the like, and in the case that the operated object has a state change, it may be determined that the operation data to be synchronized exists on the client. Or, in this embodiment, it may be monitored whether an input operation exists on an input device on the client, for example, whether a keyboard or a joystick is operated by a user, and in the case that the input operation exists on the input device, it may be determined that the operation data to be synchronized exists on the client. The operation data herein may include parameter data representing a state change of the operated object, for example, the operation data at least includes an object parameter and an operation parameter, and the operation parameter is used to instruct the target object corresponding to the execution object parameter to execute a corresponding operation according to the operation parameter. The operation parameters at least can represent the operation type, the operation mode and other contents of the operation on the target object. The object parameter may be an object identification of the target object, thereby characterizing the target object.
Step 102: and generating a first instruction and giving the first instruction to all the at least two clients through the server.
Wherein, the first instruction at least comprises the operation data.
Specifically, in this embodiment, after any client monitors the operation data to be synchronized, the client transmits the generated first instruction to the server through the communication established between the client and the server, and the server synchronizes all the clients in a unified manner. For example, after a first instruction including operation data is generated on a first client that monitors operation data to be synchronized, the first instruction is sent to a server through communication established between the first client and the server, and then the server sends the first instruction to all clients through communication established between the first client and the server and between the server and each of a second client and the server, where the second client refers to all other clients different from the first client, as shown in fig. 3, thereby implementing synchronization of the operation data between the server and all clients.
It should be noted that the operation parameters included in the operation data in the first instruction correspond to processed data, such as data of a game object moving 3 cm to the left, data of a horizontal line added to the teaching content, and the processed data is converted into data of a fixed point type, for example, the operation data transmitted to all the clients is replaced by the fixed point type instead of the floating point type, thereby avoiding a situation that the instruction execution results are inconsistent due to different data types between the clients, for example, a situation that the control game objects on the respective game clients move at different distances.
According to the scheme, in the data synchronization method provided by the embodiment of the application, for any client which establishes communication through the server, the data to be synchronized on the client is monitored, and then under the condition that the operating data to be synchronized exists, the instruction is generated and is synchronously sent to all the clients through the server, and if no operating data is monitored to be synchronized, the monitoring is continued without sending the instruction to other clients, so that the data transmission amount between the server and the client can be reduced while the operating data is synchronized.
In one implementation, in order to reduce power consumption on the client and avoid a situation of high power consumption caused by frequently performing synchronization monitoring, a condition is set for synchronization monitoring in this embodiment, as specifically shown in fig. 4:
step 100: judging whether the synchronization control condition is satisfied, if so, executing step 101 to monitor the data to be synchronized on the client, if not, continuing to execute step 100, and after the synchronization control condition is satisfied, continuing to execute step 100 to continuously judge whether the synchronization control condition is satisfied.
Wherein the synchronization control condition may include: and from the time when the client and the server start synchronizing, under the condition that the instruction generated on the client is executed completely, the monitoring execution times are less than the monitoring preset times. Therefore, from the time when the client and the server start synchronizing, each client continuously judges whether the synchronization control condition is met, and further determines the time for monitoring the data to be synchronized on the client, so as to avoid the situations of overhigh power consumption and overlarge data amount caused by continuously monitoring the data to be synchronized.
The monitoring execution times here is the historical times of executing the data to be synchronized on the monitoring client from the time when the client and the server start synchronizing, that is, the times of executing step 101; the predetermined number of monitoring times is the number of preset interval thresholds included from the time when the client and the server start synchronizing, specifically, an integer value of the number of included interval thresholds.
It should be noted that the interval threshold may be set according to requirements, such as 40 ms or 50 ms.
That is, the execution opportunity for monitoring whether the client has data to be synchronized is determined based on the interval threshold, specifically:
in general, step 101 is executed once every time the waiting interval is long, that is, whether data to be synchronized exists on the client is monitored once;
however, since there is not operation data to be synchronized for each monitoring, that is, no instruction needs to be generated to other clients for each monitoring, therefore:
after monitoring whether the client has data to be synchronized once, if the client has no operation data to be synchronized this time, then the current client can perform monitoring of the data to be synchronized once again after waiting for the duration corresponding to the interval threshold, and if the client has operation data to be synchronized this time, then the client may execute the instruction sent by the server in addition to generating the instruction to the server, similarly, when the client has operation data to be synchronized this time, it waits for the duration corresponding to the interval threshold, if the instruction on the client is already executed when the duration of the interval threshold arrives, then on the current client, the synchronization control condition is satisfied, at this time, it is monitored again whether the client has data to be synchronized, if the duration of the interval threshold arrives, if the instruction on the client is not executed, continuing to wait until the instruction is executed, and then judging whether the monitoring execution times are less than the monitoring preset times; and if the monitoring execution times are less than the preset monitoring times, continuing to synchronize the client and the server in the above mode.
For example, as shown in fig. 5a, from the time of starting synchronization between the client and the server, in the initial state, both the monitoring execution number and the predetermined monitoring number are 0, that is, synchronization monitoring is not performed, and the duration of synchronization does not exceed the interval threshold, such as 40 milliseconds. As time progresses, object operations are performed on the respective clients, and there may be data to be synchronized, so that the following processes are performed on the respective clients: as time advances, the predetermined number of monitoring times on each client adds 1 to the duration of the waiting interval threshold, and the number of monitoring execution times is still 0, at this time, the step of monitoring whether there is data to be synchronized, that is, "monitoring 1" is executed on each client, taking the first client as an example, if it is monitored that there is no operation to be synchronized on the first client, the first client continues to wait until the number of monitoring predetermined times changes to 2, at this time, the step of monitoring whether there is data to be synchronized, that is, "monitoring 2" is executed on the first client again; if the operation data to be synchronized exists on the first client, a first instruction is generated and sent to the server, if the instruction sent by the server is executed on the first client at this time, when the instruction sent by the server is executed on the first client, the relationship between the monitoring preset times and the monitoring execution times is judged again, if the instruction sent by the server is not executed when the duration of the interval threshold arrives, that is, the execution duration of the instruction exceeds the duration of the interval threshold, for example, 60 milliseconds shown in fig. 5a, after the instruction is executed, the monitoring preset times is greater than the monitoring execution times, at this time, the step of monitoring whether the data to be synchronized exists, that is, "monitoring 3", can be executed on the first client again, if the operand to be synchronized exists on the first client, then waiting continues until the predetermined number of monitoring is greater than the number of monitoring executions and the step of monitoring whether there is data to be synchronized, i.e. "monitor 4", can be executed again on the first client. Of course, if the instruction sent by the server has been executed when the duration of the interval threshold comes after the second monitoring, the server continues to wait, as shown in fig. 5b, until the predetermined number of monitoring times is greater than the number of monitoring execution times, and the first client may perform the step of monitoring whether there is data to be synchronized again. By referring to the logic above, in this way, the above monitoring scheme is executed on each client, so that each client can ensure that the synchronization times within a certain time duration are similar, thereby ensuring at least similar synchronization frequencies.
Specifically, in this embodiment, before the following procedure is performed to control the synchronization frequency, that is, before monitoring the data to be synchronized on the client in step 101, step 100 may be performed in the following manner, as shown in fig. 6:
step 601: the start time is obtained.
In the initial state, the starting time is the time when the server and the client start synchronizing.
Step 602: and obtaining an interval count value according to a time difference value between the current time and the starting time.
The current time refers to the time currently recorded by the clock on the client. Specifically, in this embodiment, the interval count value may be obtained by multiplying the unit count value Ticks by the time length obtained by subtracting the start time from the current time. For example, the unit count value herein refers to a minimum unit value such as 10000 or other values of time lapse, thereby improving the precision in executing the code in the present embodiment, and further achieving a more accurate synchronization effect.
Step 603: the start time is updated using the current time.
For example, the time value of the current time is assigned to the start time, and the current time is recorded by a variable of the start time.
Step 604: and monitoring whether the interval count value is greater than or equal to a threshold count value corresponding to the interval threshold value, if the interval count value is greater than or equal to the threshold count value, executing step 101 to monitor the data to be synchronized on the client, and executing step 605.
Step 605: the interval count value is updated according to the threshold count value, and the process returns to step 604 to monitor the interval count value until the interval count value is smaller than the threshold count value, and step 606 is executed.
The interval count value may be assigned a difference value obtained by subtracting the threshold count value from the interval count value. The threshold count value corresponding to the interval threshold is: the interval threshold is multiplied by the unit count value Ticks, thereby obtaining a threshold count value.
Step 606: waiting for a preset sleep duration, and then returning to step 602 and subsequent steps, in step 602, an interval count value is obtained according to a time difference between the current time and the updated start time.
In a specific implementation, the pseudo code may be executed in a loop as follows:
Figure BDA0003257044240000111
Figure BDA0003257044240000121
in an implementation manner, the first instruction further includes a first instruction identifier, where the first instruction identifier is an instruction identifier set for the first instruction when the client generates the first instruction, and the first instruction identifier is maintained on each client. In addition, each client is provided with an instruction set, and the instruction set on each client is used for storing the target instruction sent by the server. And each target instruction in the instruction set has a respective instruction identifier, and the instruction identifier of the target instruction is used for indicating that the target instructions in the instruction set are executed in the instruction set according to the sequence among the instruction identifiers.
The instruction identification may be a number or code characterizing the execution order of the instructions, for example, the number of the instructions may be represented by a number, and thus, the instructions in the instruction set are executed on each client according to the size relationship of the number between the instruction numbers. It should be noted that the instruction identifier of the target instruction in the instruction set on each client is set after the server receives the instruction synchronized by each client. Specifically, 1 sequence is added to the maintained instruction identifiers at each preset interval threshold on the server, after receiving the instructions sent by each client, the server sets the instruction identifiers for the currently received instructions according to the current instruction identifiers on the server, and then sends the target instructions to each client, so that the received target instructions sent by the server are added to the instruction set on each client.
For example, the server adds 1 to the instruction number maintained by the server every 40 milliseconds, and when the instruction numbers are added to 3, the server receives the instruction with the number 1 sent by the client 1, the instruction with the number 1 sent by the client 2, and the instruction with the number 2, at this time, the server sets the instruction with the number 1 sent by the client 1, the instruction with the number 1 sent by the client 2, and the instruction number of the instruction with the number 2 to 3, and then the server sends the three instructions with the number 3 to all the clients, as shown in fig. 7 a.
In a specific implementation, an order is added to an instruction identifier maintained on a client every time data to be synchronized on the client is monitored, for example, an instruction number is added by 1 every time the client performs a monitoring step of the data to be synchronized, when the client monitors that operation data to be synchronized exists and generates a first instruction, the instruction number added by 1 at present is given to the first instruction to become an instruction identifier of the first instruction, if the client monitors that no operation data to be synchronized exists, the instruction number is still added by 1, that is, an instruction number is maintained on each client, when the client monitors the data to be synchronized every time, the instruction number is added by 1, if a corresponding first instruction is generated, the client is assigned to the first instruction, meanwhile, an instruction number is also maintained on a server, and the instruction number on the server is added by 1 every interval threshold, and the instruction number on the server is used for adding an instruction identifier for the received instruction. Therefore, although the specific time for executing the monitoring step has an error in milliseconds, the monitoring scheme and the processing scheme of the instruction number are executed on each client and each server, so that the number of synchronization times performed in a certain time duration can be ensured to be similar on each client, and after all the instructions synchronized by the clients are synchronized on each client, the instructions can be executed according to the sequence represented by the instruction number re-added by the server, thereby ensuring at least similar synchronization frequency and realizing accurate synchronization of the operation data.
Based on the above implementation, when receiving the second instruction synchronized by the server on each client, the execution of the instruction rollback may be performed in the following manner, as shown in fig. 7 b:
step 701: a second instruction is received.
The second instruction at least includes a second instruction identifier, and certainly also includes operation data to be synchronized on the client side that is sent to the second instruction, and the second instruction identifier is set by the server side according to the current instruction identifier maintained by the server side when the second instruction is received.
Step 702: adding the second instruction to the instruction set.
Specifically, in this embodiment, the second instruction is added to the instruction set of the current client. Therefore, the current instruction set of the client includes target instructions synchronized by the client through the server, and the target instructions in the instruction set all have their own instruction identifications, so that the instruction identifications of the multiple instructions may be the same. For example, as shown in fig. 8, taking a game client and a game server as an example, the client 1 generates an instruction with the number 1 and an instruction with the number 2 and sends the instructions to the server, and the server receives the two instructions and sets the numbers of the two instructions to 3 when the number of the server is 3; the client 2 generates an instruction with the number of 2 and sends the instruction to the server, and the server receives the instruction when the number of the server is 4, and sets the number of the instruction as 4; the client 3 generates an instruction with the number 1 and an instruction with the number 4 and sends the instructions to the server, the server receives the instruction with the number 1 sent by the client 3 and sets the number of the instruction to 2 when the number of the server is 2, the server receives the instruction with the number 4 sent by the client 3 and sets the number of the instruction to 5 when the number of the server is 5, and after synchronization of the server, the instruction sets of the client 1, the client 2 and the client 3 respectively include: one instruction numbered 2, two instructions numbered 3, one instruction numbered 4, and one instruction numbered 5.
Step 703: in the instruction set, starting from the second instruction identification, instructions in the instruction set are executed.
The instruction identifier of the second instruction transmitted by the server may be before the current instruction identifier on the current client due to transmission delay between the client and the server, so that after the second instruction synchronized by the server is received on the current client, the second instruction is added to the instruction set of the current client, and the application running state on the client is rolled back to the state before the time corresponding to the instruction identifier of the second instruction, so that the instructions corresponding to all the instruction identifiers after the second instruction identifier are executed from the newly added second instruction, and the rolled-back execution of the instruction is realized.
For example, as shown in fig. 9, taking the client 1 as an example, the instruction set of the client 1 currently includes: one instruction with the number 2, two instructions with the number 3, one instruction with the number 4 and one instruction with the number 5, based on which, because the transmission rate between the client 2 and the server is slow, the new instruction with the number 4 synchronized by the server is transmitted to the client 1 only when the instruction on the client 1 is the number 5, after the new instruction with the number 4 synchronized by the server is added to the instruction set of the client 1, the scene state of the game application on the client 1 is restored to the state before the instruction with the number 4 on the client 1, for example, the game object is restored to the position before 80 milliseconds from the current position, and then, starting from the number 4, the subsequent instructions in the instruction set are executed in sequence, that is: although the instruction numbered 5 is already executed on the client 1, the instructions numbered 4 are also executed again in sequence: two instructions numbered 4 and 5, thereby implementing instruction rollback, so that each game player can view the complete actions of the other game players on the respective game clients through screen rollback.
In addition, if there is a communication disconnection between each client and the server and an instruction from other clients through synchronization of the server cannot be received, the execution of breakpoint resuming can be performed in the following manner, as shown in fig. 10:
step 1001: and monitoring whether a breakpoint of the instruction transmission connection exists, if so, executing step 1002, and if not, continuing to execute step 1001 to continuously monitor whether the breakpoint exists.
The instruction transmission connection can be understood as the communication connection between the current client and the current server, and the breakpoint refers to a state node which causes that the instruction cannot be transmitted after the communication connection is disconnected.
Specifically, in this embodiment, the current communication state between the client and the server can be monitored, and then, when the communication is disconnected, the breakpoint of the instruction transmission connection is monitored.
Step 1002: and acquiring breakpoint identification corresponding to the breakpoint.
The breakpoint identification refers to a current value of an instruction identification maintained on the client when the breakpoint occurs, and if the breakpoint is monitored when the number of the client 1 is accumulated to 2, the breakpoint identification at this time is 2.
Specifically, the client state can be snapshot-recorded on each client according to a certain frequency, and the obtained recording content can represent the history identifier of the history instruction corresponding to the client. Accordingly, in the present embodiment, the latest one of the history identifiers can be used as the breakpoint identifier. For example, each client performs snapshot recording on game scene state information of the game application on the client according to a time interval of 1024 × 40 ms or 2048 × 40 ms, so that the game scene state information presented by the latest executed instruction is recorded on each client, and accordingly, the maximum number represented by the game scene state information on the client is used as a breakpoint identifier. For example, the client records game scene state information formed after the execution of the instruction with the number of 0 to the number of 1024, and includes information such as the position, ID, and movement rate of each game object, so that when the client monitors a breakpoint, 1024 represented by the recorded content is used as a breakpoint identifier.
In a special case, the client state is not recorded on the client, for example, the game client does not make a snapshot record of the game scene state information, and at this time, the client uses 0 as the breakpoint identifier.
Step 1003: and sending a breakpoint retransmission request to the server according to the breakpoint identification so as to obtain a breakpoint set sent by the server.
The breakpoint set comprises historical instructions corresponding to breakpoint identifications and historical instructions corresponding to all instruction identifications sequenced after the breakpoint identifications. In a specific implementation, the client receives the breakpoint set sent by the server under the condition that communication between the client and the server is restored.
It should be noted that, because a breakpoint exists between the client and the server, there is a case that an instruction on the server cannot be synchronized to the current client, and based on this, after the breakpoint is monitored, a historical instruction after the breakpoint is requested from the server based on the breakpoint identifier in this embodiment, that is, in the case that communication between the client where the breakpoint occurs and the server is restored, a breakpoint retransmission request is sent to the server, where the breakpoint retransmission request at least includes the breakpoint identifier, and thus, after the breakpoint retransmission request is received by the server, the server returns the breakpoint identifier and historical instructions corresponding to all instruction identifiers after the breakpoint identifier to the client, and thus, all historical instructions which cannot be synchronized after the breakpoint can be received by the client.
Specifically, all the generated commands of each client are stored in the server, and for example, as shown in fig. 11, the command set of the server includes: one instruction number 2, two instructions number 3, two instructions number 4, one instruction number 5, three instructions number 6, and two instructions number 7, so if a breakpoint is monitored on client 1 when the numbers are incremented to 4, then the instruction set on client 1 may only contain: one instruction numbered 2, two instructions numbered 3, so that in case of resuming communication with the server at the client 1, the breakpoint identity 4 can be sent to the server, whereby two instructions numbered 4, one instruction numbered 5, three instructions numbered 6 and two instructions numbered 7 are sent to the client 1 at the server, whereby the history instructions are received at the client 1: two instructions numbered 4, one instruction numbered 5, three instructions numbered 6, and two instructions numbered 7.
Step 1004: historical instructions in the breakpoint set are added to the instruction set.
Step 1005: in the instruction set, starting from the breakpoint identification, the instructions in the instruction set are executed.
For example, as shown in fig. 11, a history instruction is received on client 1: after two instructions numbered 4, one instruction numbered 5, three instructions numbered 6 and two instructions numbered 7, the client 1 starts to execute corresponding instructions from the breakpoint identifier 4, thereby realizing breakpoint continuous transmission on the client 1, so that any game player can watch the complete action of other game players after disconnection and connection recovery.
Referring to fig. 12, a flowchart of an implementation of a data synchronization method provided in the second embodiment of the present application is shown, where the method may be applied to a server, and the server implements communication between at least two clients, as shown in fig. 2. The technical scheme in the embodiment is mainly used for reducing the data transmission amount between the server and the client.
Specifically, the method in this embodiment may include the following steps:
step 1201: in the case of establishing communication with at least two clients, monitoring instructions from the clients, if a first instruction from at least one of the at least two clients is obtained, executing step 1202, if no instruction from the client is obtained, returning to executing step 1201, and continuing to monitor instructions from the clients.
The first instruction comprises operation data.
Step 1202: and giving a first instruction to all the at least two clients so that other clients execute corresponding processing according to the operation data.
Specifically, after receiving the instruction sent by each client, the server sets a uniform instruction identifier for the instruction sent by the client according to the instruction identifier maintained by the server.
Further, after receiving the instruction synchronized by the server, each client adds the instruction to the instruction set of the client, and then executes the instruction in the instruction set in the manner described above, so as to implement screen output, such as object control output in a game application, and output of teaching content in a teaching application, and so on.
It should be noted that, in this embodiment, the server may also feed back the corresponding history instruction to the client according to the request after receiving the breakpoint retransmission request of any client, and so on. The specific implementation of the server can refer to the corresponding content in the foregoing, and is not detailed here.
According to the above scheme, in the data synchronization method provided in the second embodiment of the present application, for any client that establishes communication through the server, the server monitors the instruction from the client, so that when there is an instruction, the instruction is synchronized to each client, and the instruction on the client is data to be synchronized through monitoring on the client, and further, when it is monitored that there is operational data to be synchronized, the instruction is generated and sent to each client through the server, and if it is monitored that there is no operational data to be synchronized, the monitoring is continued without sending an instruction to other clients, so that the amount of data transmitted between the server and the client can be reduced while the current operational data is synchronized.
Referring to fig. 13, a schematic structural diagram of a data synchronization apparatus according to a third embodiment of the present application is provided, where the apparatus may be configured on any client that establishes communication with other clients through a server. As shown in fig. 2, at least two clients establish communication through a server. The technical scheme in the embodiment is mainly used for reducing the data transmission amount between the server and the client.
Specifically, the apparatus in this embodiment may include the following units:
a data monitoring unit 1301, configured to monitor data to be synchronized on at least two clients when communication is established between the clients through a server; if it is monitored that the operation data to be synchronized exists on at least one of the at least two clients, triggering the instruction processing unit 1302, and if it is monitored that the operation data to be synchronized does not exist on the client, continuing to monitor the data to be synchronized on the client;
the instruction processing unit 1302 is configured to generate a first instruction and send the first instruction to all the clients of the at least two clients through the server, where the first instruction at least includes the operation data.
According to the scheme, in the data synchronization device provided by the third embodiment of the application, for any client which establishes communication through the server, the data to be synchronized on the client is monitored, and then under the condition that the operation data to be synchronized exists, the generated instruction is sent to all the clients through the server, and if no operation data is monitored to be synchronized, the monitoring is continued without sending the instruction to other clients, so that the transmission data amount between the server and the client can be reduced while the operation data is synchronized.
In one implementation, the data monitoring unit 1301 is further configured to perform the following if a synchronization control condition is satisfied: monitoring data to be synchronized on the client; wherein the synchronization control condition includes: from the time when the client and the server start to synchronize, the instructions generated on the client are executed completely, and the monitoring execution times are less than the monitoring preset times; the monitoring execution times are historical times for monitoring data to be synchronized on the client from the time when the client and the server start synchronizing; the preset monitoring times are the number of preset interval thresholds included from the time when the client and the server start to synchronize.
Based on the above implementation, before the data monitoring unit 1301 monitors the data to be synchronized on the client, the data monitoring unit is further configured to: obtaining a starting time; the starting time is the time when the server and the client start to synchronize; obtaining an interval count value according to a time difference value between the current time and the starting time; updating the starting time by using the current time; monitoring the interval count value; if the interval count value is larger than or equal to the threshold count value corresponding to the interval threshold value, executing the step of monitoring the data to be synchronized on the client, updating the interval count value according to the threshold count value, and returning to the step of monitoring the interval count value until the interval count value is smaller than the threshold count value; and after waiting for a preset sleep time, returning to execute the step of obtaining an interval count value according to the time difference between the current time and the starting time.
In an implementation manner, the first instruction further includes a first instruction identifier, an instruction set is configured on the client, the instruction set is used for storing a target instruction sent by the server, and the instruction identifier of the target instruction is used for instructing, in the instruction set, to execute the instructions in the instruction set in an order between the instruction identifiers.
Based on the above implementation, the instruction processing unit 1302 is further configured to: receiving a second instruction, wherein the second instruction at least comprises a second instruction identifier; adding the second instruction to the set of instructions; executing instructions in the instruction set starting from the second instruction identification in the instruction set.
Based on the above implementation, the instruction processing unit 1302 is further configured to: under the condition that a breakpoint of instruction transmission connection is monitored, acquiring a breakpoint identification corresponding to the breakpoint; sending a breakpoint retransmission request to the server according to the breakpoint identifier to obtain a breakpoint set sent by the server, where the breakpoint set includes historical instructions corresponding to the breakpoint identifier and historical instructions corresponding to all instruction identifiers sequenced after the breakpoint identifier; adding historical instructions in the breakpoint set into the instruction set; in the instruction set, starting from the breakpoint identification, executing the instructions in the instruction set.
In an implementation manner, the operation data at least includes an object parameter and an operation parameter, and the operation data is used to instruct a target object corresponding to the object parameter to execute a corresponding operation according to the operation parameter. The processed data corresponding to the operating parameters are fixed point type data.
It should be noted that, for the specific implementation of each unit in the present embodiment, reference may be made to the corresponding content in the foregoing, and details are not described here.
Referring to fig. 14, a schematic structural diagram of a data synchronization apparatus according to a fourth embodiment of the present disclosure is provided, where the apparatus may be configured at a server, and the server implements communication between at least two clients, as shown in fig. 2. The technical scheme in the embodiment is mainly used for reducing the data transmission amount between the server and the client.
Specifically, the apparatus in this embodiment may include the following units:
an instruction monitoring unit 1401, configured to monitor an instruction from at least two clients when communication is established with the clients, trigger the instruction transmitting unit 1402 if a first instruction from at least one of the at least two clients is obtained, and continue to monitor the instruction from the client if the instruction from the client is not obtained.
The first instruction comprises operation data.
An instruction transmission unit 1402 configured to: and giving a first instruction to all the at least two clients so that the clients execute corresponding processing according to the operation data.
It should be noted that, in this embodiment, the server may also feed back the corresponding history instruction to the client according to the request after receiving the breakpoint retransmission request of any client, and so on. The specific implementation of the server can refer to the corresponding content in the foregoing, and is not detailed here.
According to the above scheme, in the data synchronization device provided in the fourth embodiment of the present application, for any client that establishes communication through the server, the server monitors the instruction from the client, so that when there is an instruction, the instruction is synchronized to all clients, and the instruction on the client is data to be synchronized through monitoring on the client, and further, when it is monitored that there is operation data to be synchronized, an instruction is generated and sent to each client through the server, and if it is monitored that there is no operation data to be synchronized, the monitoring is continued without sending an instruction to other clients, so that the amount of transmission data between the server and the client can be reduced while the operation data is synchronized.
Referring to fig. 15, a schematic structural diagram of a client according to a fifth embodiment of the present invention is provided, where the client may be any client that establishes communication with other clients through a server. As shown in fig. 2, at least two clients establish communication through a server. The technical scheme in the embodiment is mainly used for reducing the data transmission amount between the server and the client.
Specifically, the client in this embodiment may include the following structure:
a memory 1501 for storing applications and data generated by the application operations;
a processor 1502 for executing an application to implement: monitoring data to be synchronized on at least two clients under the condition that the two clients establish communication through a server; if the situation that the operation data to be synchronized exists on at least one of the at least two clients is monitored, generating a first instruction to be sent to all the clients of the at least two clients through the server, wherein the first instruction at least comprises the operation data, and if the situation that the operation data to be synchronized does not exist on the clients is monitored, continuing monitoring the data to be synchronized on the clients.
In addition, the client may also include other components, such as a display screen, an input device, a communication module, and the like. The display screen may be used for output of pictures, the input device may be used for input of input operations, and the communication module may be used for transmission of instructions.
According to the scheme, in any client which establishes communication through the server, the data to be synchronized on the client is monitored, and then the generated instruction is sent to all the clients through the server under the condition that the operation data to be synchronized exists, and if no operation data needs to be synchronized, the client continues to monitor without sending the instruction to other clients, so that the transmission data volume between the server and the client can be reduced while the operation data is synchronized.
Referring to fig. 16, a schematic structural diagram of a server according to a sixth embodiment of the present disclosure is shown, where the server implements communication between at least two clients, as shown in fig. 2. The technical scheme in the embodiment is mainly used for reducing the data transmission amount between the server and the client.
Specifically, the server in this embodiment may include the following structure:
a memory 1601 for storing applications and data generated by the application operations;
a processor 1602 for executing an application to implement: in the case of establishing communication with at least two clients, instructions from the clients are monitored, if a first instruction from at least one of the at least two clients is obtained, the first instruction is given to all the clients in the at least two clients so that other clients perform corresponding processing according to the operation data, and if the instruction from the client is not obtained, the instructions from the clients are continuously monitored.
The first instruction comprises operation data.
It should be noted that, in this embodiment, the service end may further include other components, such as a communication module, for facilitating transmission of the instruction, and in addition, the service end may further feed back a corresponding historical instruction to the client according to the request after receiving a breakpoint retransmission request of any client, and so on. The specific implementation of the server can refer to the corresponding content in the foregoing, and is not detailed here.
According to the scheme, in any client which establishes communication through the server, the server monitors the instructions from the clients, so that the instructions are synchronized to all the clients when the instructions come, the instructions on the clients monitor to-be-synchronized data on the clients, and further, under the condition that the to-be-synchronized operation data are monitored, the instructions are generated and sent to all the clients through the server, and if no operation data need to be synchronized, the monitoring is continued without sending the instructions to other clients, so that the transmission data volume between the server and the clients can be reduced while the operation data are synchronized.
In addition, the present application also provides a storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are loaded and executed by a processor, the data synchronization method as described in any one of the above is implemented.
Taking a game application scene as an example, aiming at the defect that the transmission data volume between a game client and a server is large, based on the technical scheme of the application, a game frame synchronization scheme is provided, and after the time is calibrated between the server and the client, a server notifies all clients and starts to execute logic frames in sequence at the same time interval. Thus, the client determines whether the frame needs to be broadcast by having or not to operate on the frame. And after the frame command is gathered on the server, the frame command is broadcasted to other clients. Moreover, the data transmitted between the client and the server is only an operation instruction, i.e. the operation data in the foregoing text, and is not a state attribute, so that the amount of data transmission that can be done is extremely small. Therefore, each client is not influenced by the delay of other clients, and disconnection reconnection and playback are facilitated.
In specific implementation, the problem of cross-platform aspect needs to be considered in frame synchronization between the client and the server, so that a fixed point number is used in the application instead of float. For a scene simulating the solar system in a game application, all objects in the scene have a unique EntityId. Can be defined by the uint 32.
In the scene, for all objects, different attributes (hereinafter, referred to as Component) can be bound to the EntityId according to actual needs, a System (hereinafter, referred to as System) is used for running the game world (hereinafter, referred to as EntityWorld) outside the EntityId and the Component, all display representations are processed by a Renderer in a display part, and the four parts are matched to form the ECS-R System. The whole ECS-R system is composed of two parts: ECSs can be processed within threads, which has the benefit of fully exploiting multi-core performance. R runs in the main thread and exposes the entire display world through the marked dirty data markers in the ECS system, as shown in FIG. 17, with ECS and R (render) running in separate threads.
Based on the above scenario, the game frame synchronization scheme proposed in the present application specifically includes:
first, frame rate consistency is ensured, and time lapse is corrected by datetime. Reference is made in particular to the pseudo code in the preceding text to demonstrate how to correct the passage of time, which part is still valid when the disconnection is reconnected. Run consumes more time, and the whole cycle can be like a spring to ensure that the number of frames of each client after running for a period of time is consistent.
Where, frameTickCount is 40 × 10000, which means that the logical frame interval is 40 ms, and ticks is 400000. 40 mm is a custom value, and the time interval can be adjusted according to actual requirements.
Run () in turn performs the following actions, which are also core logic portions, in conjunction with the structure of the ECS (EntityId + Component + System) System shown in fig. 18, as shown in fig. 19:
1. as shown in fig. 20 and 21, the upper branch process of the client C performs frame processing, network data transmission, and picture rendering, the upper branch process of the server S performs frame processing and network data transmission, and the frame numbering is performed on the client and the server according to an interval threshold of 40 milliseconds, respectively, and the picture rendering on the client can perform picture refreshing at an interval of 20 milliseconds as required:
logical frame number accumulation: adding 1 to the current frame number in each monitoring;
reading a historical frame: re-reading the logic of the file, namely sequentially executing the command set for acquiring the logic frame, namely, retransmitting the breakpoint;
network frame rollback: executing a command of unifying the logical frame numbers distributed by the server, tracing the local logical frame numbers back to the previous frame of the received frame numbers after receiving the command, and quickly recalculating to the current frame;
the ECS system performs: executing the Entity behavior, namely calculating a result according to the states of all the components;
the ECS system performs: inputting a controller command for reading, namely monitoring input equipment such as a keyboard, a rocker and the like; the component backs up and sends a command manually triggered by the user in the current logical frame to the server.
2. The ECS system performs:
the gravity system comprises a Position component, a displacement component and a particle component, wherein the displacement component records displacement data through transformcomm Position { Position, … }, and the particle component records particle data through particle component { Mass, … };
the mobile system MovementComponent { Direction, Speed, … } comprises a position component and a displacement component;
the star body moving system comprises a revolution component, a self-transmission component and a position component;
the collision system includes a position assembly;
the recovery system includes a vital value component and a countdown component.
In fig. 17, it is desirable that the corresponding components are calculated in each system, and the latest component content is modified, so that each system performs in sequence. Taking the gravity system as an example: the position and particle components are obtained in the system, the direction of the displacement component is calculated through a formula, and then the direction and the speed of the moving component are calculated through the calculation of the moving system, and the position attribute of the position component is modified. Thus, the effect of space universal gravitation can be realized.
It should be noted that the above is only one implementation of game frame synchronization in a game application scene, and the technical scheme in the present application can be used in various internet applications to implement multi-client synchronization. For example, multi-person teaching interaction, which is more traffic-saving than video, and can interact within a scene.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A data synchronization method is applied to a client and comprises the following steps:
monitoring data to be synchronized on at least two clients under the condition that the two clients establish communication through a server;
if the situation that the operation data to be synchronized exists on at least one of the at least two clients is monitored, generating a first instruction and sending the first instruction to all the clients of the at least two clients through the server, wherein the first instruction at least comprises the operation data;
and if the client is monitored to have no operation data to be synchronized, executing a step of monitoring the data to be synchronized on the client.
2. The method of claim 1, further comprising:
in a case where a synchronization control condition is satisfied, performing: monitoring data to be synchronized on the client;
wherein the synchronization control condition includes: from the time when the client and the server start to synchronize, the instructions generated on the client are executed completely, and the monitoring execution times are less than the monitoring preset times; the monitoring execution times are historical times for monitoring data to be synchronized on the client from the time when the client and the server start synchronizing; the preset monitoring times are the number of preset interval thresholds included from the time when the client and the server start to synchronize.
3. The method of claim 2, prior to monitoring data to be synchronized on the client, the method further comprising:
obtaining a starting time; the starting time is the time when the server and the client start to synchronize;
obtaining an interval count value according to a time difference value between the current time and the starting time;
updating the starting time by using the current time;
monitoring the interval count value;
if the interval count value is larger than or equal to the threshold count value corresponding to the interval threshold value, executing the step of monitoring the data to be synchronized on the client, updating the interval count value according to the threshold count value, and returning to the step of monitoring the interval count value until the interval count value is smaller than the threshold count value;
and after waiting for a preset sleep time, returning to execute the step of obtaining an interval count value according to the time difference between the current time and the starting time.
4. The method according to claim 1, 2 or 3, wherein the first instruction further includes a first instruction identifier, and the client is configured with an instruction set, the instruction set is used for storing a target instruction sent by the server, and the instruction identifier of the target instruction is used for instructing to execute the instructions in the instruction set in an order between the instruction identifiers in the instruction set.
5. The method of claim 4, further comprising:
receiving a second instruction, wherein the second instruction at least comprises a second instruction identifier;
adding the second instruction to the set of instructions;
executing instructions in the instruction set starting from the second instruction identification in the instruction set.
6. The method of claim 4, further comprising:
under the condition that a breakpoint of instruction transmission connection is monitored, acquiring a breakpoint identification corresponding to the breakpoint;
sending a breakpoint retransmission request to the server according to the breakpoint identifier to obtain a breakpoint set sent by the server, where the breakpoint set includes historical instructions corresponding to the breakpoint identifier and historical instructions corresponding to all instruction identifiers sequenced after the breakpoint identifier;
adding historical instructions in the breakpoint set into the instruction set;
in the instruction set, starting from the breakpoint identification, executing the instructions in the instruction set.
7. The method according to claim 1 or 2, wherein the operation data at least includes an object parameter and an operation parameter, and the operation data is used to instruct a target object corresponding to the object parameter to execute a corresponding operation according to the operation parameter.
8. The method of claim 7, wherein the processed data corresponding to the operation parameters is fixed-point data.
9. A data synchronization method is applied to a server side, and the method comprises the following steps:
monitoring instructions from at least two clients in case communication is established with the clients;
if a first instruction from at least one of the at least two clients is obtained, wherein the first instruction comprises operation data, the first instruction is sent to all the at least two clients, so that the clients execute corresponding processing according to the operation data;
and if the instruction from the client is not obtained, returning to the step of monitoring the instruction from the client.
10. A data synchronization device applied to a client, the device comprising:
the data monitoring unit is used for monitoring the data to be synchronized on the client under the condition that at least two clients establish communication through a server; if the situation that the operation data to be synchronized exists on at least one of the at least two clients is monitored, triggering an instruction processing unit, and if the situation that the operation data to be synchronized does not exist on the client is monitored, continuously monitoring the data to be synchronized on the client;
and the instruction processing unit is used for generating a first instruction and sending the first instruction to all the clients in the at least two clients through the server, and the first instruction at least comprises the operation data.
CN202111062864.2A 2021-09-10 2021-09-10 Data synchronization method and device Active CN113746931B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111062864.2A CN113746931B (en) 2021-09-10 2021-09-10 Data synchronization method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111062864.2A CN113746931B (en) 2021-09-10 2021-09-10 Data synchronization method and device

Publications (2)

Publication Number Publication Date
CN113746931A true CN113746931A (en) 2021-12-03
CN113746931B CN113746931B (en) 2022-11-22

Family

ID=78738011

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111062864.2A Active CN113746931B (en) 2021-09-10 2021-09-10 Data synchronization method and device

Country Status (1)

Country Link
CN (1) CN113746931B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116016491A (en) * 2022-12-26 2023-04-25 山东华方智联科技股份有限公司 Intelligent building design system and design method

Citations (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030126195A1 (en) * 2000-05-20 2003-07-03 Reynolds Daniel A. Common command interface
US20130184083A1 (en) * 2010-11-04 2013-07-18 Tencent Technology (Shenzhen) Company Limited Method for interactive logic fault tolerance in online game, and system and client for fault tolerance in online game
CN107404514A (en) * 2017-06-08 2017-11-28 腾讯科技(深圳)有限公司 Data processing method and device
CN109040208A (en) * 2018-07-18 2018-12-18 广州多益网络股份有限公司 Method of data synchronization, server, system and medium based on multi-client interaction
CN109300211A (en) * 2018-09-21 2019-02-01 腾讯科技(深圳)有限公司 A kind of access control method, apparatus and system
CN110102053A (en) * 2019-05-13 2019-08-09 腾讯科技(深圳)有限公司 Virtual image display methods, device, terminal and storage medium
CN110166562A (en) * 2019-05-24 2019-08-23 东软集团股份有限公司 Data synchronous method, apparatus, storage medium and electronic equipment
CN110321387A (en) * 2019-07-10 2019-10-11 中国联合网络通信集团有限公司 Method of data synchronization, equipment and terminal device
CN110602250A (en) * 2019-09-29 2019-12-20 网易(杭州)网络有限公司 Data synchronization method and device, server and terminal equipment
CN110639206A (en) * 2019-09-20 2020-01-03 北京代码乾坤科技有限公司 Game data synchronization method, device, storage medium and processor
CN110639207A (en) * 2019-09-20 2020-01-03 北京代码乾坤科技有限公司 Game data synchronization method, device, storage medium and processor
CN110898425A (en) * 2019-11-27 2020-03-24 腾讯科技(深圳)有限公司 Information synchronization method and device, storage medium and electronic device
CN111167116A (en) * 2019-09-29 2020-05-19 腾讯科技(深圳)有限公司 Smooth display method, terminal and computer storage medium
CN112379981A (en) * 2020-11-12 2021-02-19 中国人民解放军海军工程大学 Lock-free synchronization method for distributed real-time simulation task
CN112642143A (en) * 2020-12-30 2021-04-13 明日世界(上海)网络科技有限公司 Method, device, storage medium and electronic equipment for realizing information synchronization
CN112999652A (en) * 2021-04-28 2021-06-22 苏州仙峰网络科技股份有限公司 Efficient network synchronization method, device and system

Patent Citations (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030126195A1 (en) * 2000-05-20 2003-07-03 Reynolds Daniel A. Common command interface
US20130184083A1 (en) * 2010-11-04 2013-07-18 Tencent Technology (Shenzhen) Company Limited Method for interactive logic fault tolerance in online game, and system and client for fault tolerance in online game
CN107404514A (en) * 2017-06-08 2017-11-28 腾讯科技(深圳)有限公司 Data processing method and device
CN109040208A (en) * 2018-07-18 2018-12-18 广州多益网络股份有限公司 Method of data synchronization, server, system and medium based on multi-client interaction
CN109300211A (en) * 2018-09-21 2019-02-01 腾讯科技(深圳)有限公司 A kind of access control method, apparatus and system
CN110102053A (en) * 2019-05-13 2019-08-09 腾讯科技(深圳)有限公司 Virtual image display methods, device, terminal and storage medium
CN110166562A (en) * 2019-05-24 2019-08-23 东软集团股份有限公司 Data synchronous method, apparatus, storage medium and electronic equipment
CN110321387A (en) * 2019-07-10 2019-10-11 中国联合网络通信集团有限公司 Method of data synchronization, equipment and terminal device
CN110639207A (en) * 2019-09-20 2020-01-03 北京代码乾坤科技有限公司 Game data synchronization method, device, storage medium and processor
CN110639206A (en) * 2019-09-20 2020-01-03 北京代码乾坤科技有限公司 Game data synchronization method, device, storage medium and processor
CN110602250A (en) * 2019-09-29 2019-12-20 网易(杭州)网络有限公司 Data synchronization method and device, server and terminal equipment
CN111167116A (en) * 2019-09-29 2020-05-19 腾讯科技(深圳)有限公司 Smooth display method, terminal and computer storage medium
CN110898425A (en) * 2019-11-27 2020-03-24 腾讯科技(深圳)有限公司 Information synchronization method and device, storage medium and electronic device
CN112379981A (en) * 2020-11-12 2021-02-19 中国人民解放军海军工程大学 Lock-free synchronization method for distributed real-time simulation task
CN112642143A (en) * 2020-12-30 2021-04-13 明日世界(上海)网络科技有限公司 Method, device, storage medium and electronic equipment for realizing information synchronization
CN112999652A (en) * 2021-04-28 2021-06-22 苏州仙峰网络科技股份有限公司 Efficient network synchronization method, device and system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
我爬到树上等花开: "关于游戏帧同步和状态同步", 《HTTPS://WWW.JIANSHU.COM/P/1CE7AD39D4ED 》 *
游戏陀螺: "干货!光子高级工程师揭秘帧同步游戏的技术实现细节", 《HTTPS://BAIJIAHAO.BAIDU.COM/S?ID=1710208669164763724&WFR=SPIDER&FOR=PC》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116016491A (en) * 2022-12-26 2023-04-25 山东华方智联科技股份有限公司 Intelligent building design system and design method
CN116016491B (en) * 2022-12-26 2023-09-05 山东华方智联科技股份有限公司 Intelligent building design system and design method

Also Published As

Publication number Publication date
CN113746931B (en) 2022-11-22

Similar Documents

Publication Publication Date Title
CN108057249B (en) Service data processing method and device
CN112597249B (en) Synchronous distribution storage method and system for service data
CN107124416B (en) Multi-avatar position synchronization system, method, device, electronic device and storage medium
CN113746931B (en) Data synchronization method and device
CN112019422A (en) Information sharing method, information processing method, related device and equipment
CN112612851A (en) Multi-center data synchronization method and device
CN109821235B (en) Game video recording method, device and server
CN113032160B (en) Data synchronization management method and related device
CN113868575A (en) Webpage same-screen method and system
CN113050904A (en) Screen sharing method and device
CN112044061A (en) Game picture processing method and device, electronic equipment and storage medium
CN112138372B (en) Data synchronization method in distributed system and related equipment
CN110086861B (en) Collaborative simulation method, system, server and client
CN110769904B (en) Output content processing method, output method, electronic device, and storage medium
CN113230661A (en) Data synchronization method and device, computer readable medium and electronic equipment
CN111467797A (en) Game data processing method and device, computer storage medium and electronic equipment
CN114840285B (en) Processing method and device in game, terminal equipment and storage medium
CN113413592B (en) Cloud game acceleration starting method and device and electronic equipment
CN116614676B (en) Method, system and storage medium for replaying virtual character animation in message synchronization
CN117122913A (en) Frame-following acceleration method, device, equipment and medium based on frame synchronization
CN114885219B (en) Task execution state monitoring method and device, electronic equipment and storage medium
CN110457392B (en) Copy reading and writing method and device
CN114779881B (en) Synchronous detection method, device, equipment and storage medium for redundancy computer
CN113181633B (en) Game data synchronization method, system and device
CN112187868B (en) Information transmission method, readable storage medium, and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant