Terminal communication status synchronization method, device, equipment and readable storage medium

By introducing intermediate states and finite state machine control into terminal communication state synchronization, the problem of inconsistent state synchronization in the prior art is solved, and efficient and reliable state synchronization and abnormal recovery are achieved.

CN116089101BActive Publication Date: 2025-09-161DATA TECH SHANGHAI CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310094350.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-31
Publication Date
2025-09-16
Estimated Expiration
2043-01-31

AI Technical Summary

Technical Problem

Existing terminal communication status synchronization methods are difficult to achieve efficient synchronization in complex and changing business scenarios. They are also complex in design and cannot guarantee state consistency. In particular, they are prone to state asynchrony problems when programs are abnormal.

Method used

Introduce intermediate states and use finite state machine principles to control state changes, judge state synchronization requests and responses, ensure the completion of state synchronization events, and perform state persistence recovery in abnormal situations.

Benefits of technology

This effectively ensures that the states of all communication ends are synchronized, guarantees state consistency, reduces the risk of state asynchrony in abnormal situations, and simplifies abnormal recovery processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116089101B_ABST
    Figure CN116089101B_ABST
Patent Text Reader

Abstract

The present application provides a terminal communication status synchronization method, device, equipment and readable storage medium. When a program needs to synchronize its status with other programs, the present application can introduce an intermediate state in the first terminal where the program where the status change occurs is located; and can control the status change of the program based on the intermediate state; based on the status change of the program, it can be judged whether the program has sent a status synchronization request to other programs; if it has been sent, it can be judged whether the program has received the status synchronization response information of other programs; if the program receives the status synchronization response information of other programs, it means that the other programs have received the status change information of the program and completed the status synchronization, and it can be determined that the status synchronization event of the program has been completed. The method provided in the embodiment of the present application can effectively ensure that the status of each communication end can be effectively synchronized, and can ensure the consistency of the status of each communication end.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a method, apparatus, device, and readable storage medium for synchronizing terminal communication status. Background Art

[0002] In actual applications, when a certain state in program A at one end of the communication changes, the new state of program A needs to be synchronized to other programs B, C or D at the other end of the communication. In order to ensure that the new state of program A can be synchronized to other programs, a state synchronization message and a state synchronization response mechanism are generally set up. During the state response process, program A can know that its new state has been successfully synchronized to other programs. However, some boundary conditions may need to be handled in this process. For example, program A may fail to send a state synchronization message or process a state synchronization response due to an abnormality of the program itself; or program B may fail to update the state or send a response due to an abnormality of the program B; and messages or responses may be lost due to an abnormality in the message communication link.

[0003] To handle these edge cases, it's necessary to introduce strategies for state synchronization in these situations. For example, you could configure Program A to cache state synchronization messages after sending them, periodically resending them until a response is received, at which point the message is removed from the cache. This approach is currently a common solution, but it still has some edge cases. For example, suppose an event in Program A causes a state transition from "Status 1" to "Status 2." Program A sends a state synchronization message, which Program A then continues to resend, awaiting a response from Program B. At this point, the state in Program A has already transitioned to "Status 2." Even with a very short resend interval, this can still cause a brief period of state desynchronization, potentially introducing new edge cases. For example, during the state synchronization resend period, another event in Program A causes the state to transition from "Status 2" to "Status 3." This creates two state synchronization messages in the cache, requiring a new mechanism to ensure the orderly delivery of these two messages. However, there's still a chance that the states of Program A and Program B might become desynchronized. This solution still cannot solve the problem for systems with strong requirements for state synchronization. Moreover, when program A encounters an exception and needs to be initialized or restarted, in order to prevent the loss of the unsynchronized state in the cache, an additional cache persistence solution needs to be designed to ensure that the state in the cache is not lost.

[0004] It can be seen that the existing technical solutions cannot be applied to scenarios with high requirements for state synchronization, and the design is complex, which is not conducive to existing application needs. Summary of the Invention

[0005] The present application aims to solve at least one of the above-mentioned technical defects. In view of this, the present application provides a terminal communication status synchronization method, device, equipment and readable storage medium to solve the technical defect in the existing technology that it is difficult to efficiently synchronize the communication status of the terminal.

[0006] A method for synchronizing terminal communication status, comprising:

[0007] Introducing an intermediate state at a first terminal where a first target program undergoing a state change is located;

[0008] controlling a state change of the first target program according to the intermediate state;

[0009] Based on the state change of the first target program, determining whether the first target program has sent a state synchronization request to the second target program;

[0010] If the first target program has sent a state synchronization request to the second target program, determining whether the first target program has received a state synchronization response message from the second target program;

[0011] If the first target program receives the state synchronization response information of the second target program, it is determined that the state synchronization event of the first target program is completed.

[0012] Preferably, the method further comprises:

[0013] If the first target program receives the status synchronization response information from the second target program, the first target program is controlled to suspend sending the status synchronization request to the second target program.

[0014] Preferably, the method further comprises:

[0015] Determining whether the state change of the first target program at the current moment is a completed state transition;

[0016] If the state change of the first target program at the current moment is that the state migration has been completed, an event processing strategy corresponding to the state change of the first target program is created to process the state migration event of the first target program until the state of the first target program is synchronized.

[0017] Preferably, the method further comprises:

[0018] Determining whether the state of the first target program has changed;

[0019] If the state of the first target program changes, the state of the first target program is controlled to be persistent.

[0020] Preferably, the method further comprises:

[0021] Determining whether an abnormality occurs in the state of the first target program;

[0022] If an exception occurs in the first target program, after initializing or restarting the first target program, the state of the first target program is immediately restored to the state before the state of the first target program was persisted, and the state synchronization work with the second target program is continuously performed.

[0023] Preferably, after the first terminal where the first target program is located enters the intermediate state, the state change type of the first target program includes:

[0024] target states, target events, and target actions;

[0025] in,

[0026] The target state includes the current state of the first target program and the state to be migrated after the conditions are met;

[0027] The target event is the condition for state transition;

[0028] The target action is the action that needs to be executed after the transfer condition is met.

[0029] A terminal communication status synchronization device, comprising:

[0030] an intermediate state introducing unit, configured to introduce an intermediate state at a first terminal where a first target program undergoing state change is located;

[0031] a first control unit, configured to control a state change of the first target program according to the intermediate state;

[0032] a first determining unit, configured to determine, based on a state change of the first target program, whether the first target program has sent a state synchronization request to the second target program;

[0033] a second determining unit configured to determine whether the first target program has received a state synchronization response message from the second target program when the execution result of the first determining unit is that the first target program has sent a state synchronization request to the second target program;

[0034] The determining unit is configured to determine that the state synchronization event of the first target program has been completed when the execution result of the second determining unit is that the first target program receives the state synchronization response information of the second target program.

[0035] Preferably, the device further comprises:

[0036] The pausing unit is configured to control the first target program to suspend sending the status synchronization request to the second target program when the execution result of the second judging unit is that the first target program receives the status synchronization response information of the second target program.

[0037] A terminal communication state synchronization device, comprising: one or more processors, and a memory;

[0038] The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the terminal communication status synchronization method as described in any one of the above introductions are implemented.

[0039] A readable storage medium stores computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors implement the steps of the terminal communication status synchronization method as described in any one of the above descriptions.

[0040] It can be seen from the technical solution introduced above that when a program needs to synchronize its status with other programs, the method provided in the embodiment of the present application can introduce an intermediate state in the first terminal where the first target program where the state change occurs is located; and can control the state change of the first target program based on the intermediate state; based on the state change of the first target program, determine whether the first target program has sent a status synchronization request to the second target program; if the first target program has sent a status synchronization request to the second target program, it can be determined whether the first target program has received the status synchronization response information of the second target program; if the first target program receives the status synchronization response information of the second target program, it means that the second target program has received the status change information of the first target program and completed the status synchronization, and it can be determined that the status synchronization event of the first target program has been completed.

[0041] The method provided in the embodiment of the present application can effectively ensure that the status of each communication end can be effectively synchronized and can ensure the consistency of the status of each communication end. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0043] Figure 1 A flowchart of a method for synchronizing terminal communication status provided in an embodiment of the present application;

[0044] Figure 2 This is a schematic diagram of the structure of a terminal communication status synchronization device according to an embodiment of the present application;

[0045] Figure 3 This is a hardware structure block diagram of a terminal communication status synchronization device disclosed in an embodiment of the present application. DETAILED DESCRIPTION

[0046] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0047] When a state in program A at one end of the communication changes, this new state needs to be synchronized to other programs B at the other end of the communication, which may also be multiple programs B, C, and D.

[0048] To ensure that this state can be synchronized to other programs, a state synchronization message and a state synchronization response are usually set. In the response, A can know that the state has been successfully synchronized to B. However, some edge cases need to be handled. Boundary cases can be mainly divided into the following three categories:

[0049] 1. Program A cannot send a status synchronization message or process a status synchronization response due to an exception.

[0050] 2. Program B is abnormal and cannot update the status or send a response;

[0051] 3. Messages or responses are lost due to abnormalities in the message communication link;

[0052] To handle these situations, you may need to introduce some strategies to synchronize states in edge cases. There are two main solutions:

[0053] 1. Set up heartbeat messages between Program A and Program B. These heartbeat messages are sent and responded to at fixed time intervals, and the heartbeats carry the status that needs to be synchronized. In this way, even if the status synchronization message synchronization fails, the status of both ends can be synchronized through the heartbeat. However, this solution is suitable for scenarios with very weak state synchronization requirements. This solution also has some disadvantages. For example, in order not to affect normal data communication, the heartbeat messages between programs are generally not set to be very dense, and the amount of messages will be far less than that of normal communication. When state synchronization fails, Program A and Program B will be in different states until the next heartbeat. During this process, there will be a gap period in which the status is not synchronized, which is likely to cause other exceptions.

[0054] 2. Program A caches the state synchronization message after sending it, periodically resends the cached state synchronization message, and deletes the state synchronization message from the cache after receiving the state synchronization response. This method is relatively common, but it still has some edge cases:

[0055] For example, suppose an event in program A causes a status to change from "Status 1" to "Status 2". Program A sends a status synchronization message, and program A is continuously resending it, waiting for a response from program B. At this time, the status in program A has changed to "Status 2". Even if the resend interval can be set to be very short, this will still cause a short period of status asynchrony, during which new boundary issues may be introduced.

[0056] For example, during the state synchronization retransmission period, another event occurs in program A, causing the state to change from "Status 2" to "Status 3". At this time, there will be two state synchronization messages in the cache. In this case, a new mechanism needs to be introduced to ensure that these two state synchronization messages are sent in order. However, there is still a situation where the states of program A and program B are not synchronized.

[0057] This solution still cannot solve the problem for systems with strong requirements for state synchronization. Moreover, when program A encounters an exception and needs to be initialized or restarted, in order to prevent the loss of the unsynchronized state in the cache, an additional cache persistence solution needs to be designed to ensure that the state in the cache is not lost.

[0058] Given that most of the current terminal communication status synchronization solutions are difficult to adapt to complex and changing business needs, the applicant has studied a terminal communication status synchronization solution, which can effectively ensure that the status of each communication end can be effectively synchronized and can ensure the status consistency of each communication end.

[0059] The methods provided in the embodiments of the present application can be used in a variety of general-purpose or specialized computing device environments or configurations, such as personal computers, server computers, handheld or portable devices, tablet devices, multi-processor devices, and distributed computing environments including any of the above.

[0060] An embodiment of the present application provides a terminal communication status synchronization method, which can be applied to various communication management systems, and can also be applied to various computer terminals or smart terminals. The execution subject can be the processor or server of the computer terminal or smart terminal.

[0061] The following combination Figure 1 , introduces the process of the terminal communication status synchronization method given in the embodiment of the present application, such as Figure 1 As shown, the process can include the following steps:

[0062] Step S101 : introducing an intermediate state into a first terminal where a first target program undergoing a state change is located.

[0063] Specifically, in actual application, when the state of a program changes, the state of the program needs to be synchronized with other programs in a timely manner.

[0064] In order to better synchronize the state change of the program with other programs, an intermediate state can be introduced at the first terminal where the first target program where the state change occurs is located, so that the state synchronization of the first target program can be achieved based on the intermediate state introduced by the first target program.

[0065] After the first terminal where the first target program is located enters the intermediate state, the state change type of the first target program may include:

[0066] target states, target events, and target actions;

[0067] in,

[0068] The target state may include the current state of the first target program and the state to be migrated after the conditions are met;

[0069] The target event may be a condition for state transition;

[0070] The target action may be an action to be executed after the transfer condition is satisfied.

[0071] For example,

[0072] On the status-changing program A side, an intermediate state "SyncStatus 1 to 2" is introduced between "Status 1" and "Status 2". Therefore, the status change of A changes from the original "Event 1" triggering "Status 1" to "Status 2" to triggering "Status 1" to "Sync Status 1 to 2".

[0073] When program A triggers the transition from "Status 1" to "Sync Status 1 to 2", program A can continuously resend status synchronization messages to other programs until program A receives status synchronization responses returned by other programs.

[0074] Program A's "received status synchronization response" becomes an event, which will cause "Sync Status 1to2" to change to "Status 2".

[0075] Step S102 : controlling the state change of the first target program according to the intermediate state.

[0076] Specifically, it can be seen from the above introduction that the method provided in the embodiment of the present application can introduce an intermediate state into the first terminal where the first target program undergoing state change is located.

[0077] An intermediate state is introduced into the first terminal where the first target program is located, and the intermediate state can be used to achieve state synchronization of the first target program.

[0078] Therefore, after introducing the intermediate state, the method provided in the embodiment of the present application can further control the state change of the first target program based on the intermediate state.

[0079] For example, in actual application, the finite state machine principle may be used to control the state change of the first target program.

[0080] A finite state machine is a hardware sequential circuit consisting of a register bank and combinational logic. A finite state machine can transition from one state to another only on the same clock edge. The finite state machine's states are defined by the combination of 1s and 0s in the register bank.

[0081] The next state of a finite state machine depends not only on the input values ​​but also on the current state it is in. This refers to a Mealy-type finite state machine, while a Moore-type finite state machine's next state depends only on the current state.

[0082] There are many ways to describe a state machine. One way is to write the entire state machine into one always module, which describes both the state transition and the input and output of the state. This method is generally called a one-stage FSM description method. Another way is to use two always modules, where one always module uses synchronous timing to describe the state transition, and the other module uses combinational logic to determine the state transition conditions and describe the state transition rules. This method is called a two-stage FSM description method.

[0083] There is another way of writing that is developed based on the two-stage description method. This writing method uses three always modules. One always module uses synchronous timing to describe state transitions, one uses combinational logic to judge state transition conditions and describe state transition rules, and the third always module uses synchronous timing circuits to describe the output of each state. This writing method is called three-stage writing.

[0084] In the finite state machine principle, a state can have three components: state, event, and action.

[0085] 1. State: All possible states, including the current state and the state to be migrated after the conditions are met.

[0086] 2. Event: Also known as a transition condition. When a condition is met, it will trigger an action or perform a state transition.

[0087] 3. Action: The action executed when the condition is met. After the action is completed, the state can be moved to a new state or remain in the original state. Actions are not required. When the condition is met, it is also possible to move directly to the new state without executing any action.

[0088] By using state synchronization intermediate states and finite state machine principles, state changes and state synchronization can be controlled more accurately.

[0089] Step S103 : Based on the state change of the first target program, it is determined whether the first target program has sent a state synchronization request to the second target program.

[0090] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can control the state change of the first target program based on the intermediate state.

[0091] Furthermore, in actual application, when the state of the first target program changes, the first target program may send a state synchronization request to other programs. The method provided in the embodiment of the present application can further determine whether the first target program has sent a state synchronization request to the second target program based on the state change of the first target program, so as to promptly confirm whether the first target program has sent a state synchronization request to other programs.

[0092] For example, the first target program may send a status synchronization request to one or more programs simultaneously.

[0093] If the first target program has sent a status synchronization request to the second target program, it means that other programs may have received the status synchronization request of the first target program.

[0094] Step S104: determining whether the first target program has received status synchronization response information from the second target program.

[0095] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can determine whether the first target program has sent a status synchronization request to the second target program based on the status change of the first target program.

[0096] If the first target program has sent a status synchronization request to the second target program, it means that other programs may have received the status synchronization request of the first target program.

[0097] It can then be further determined whether the first target program has received the state synchronization response information of the second target program, so as to determine whether the state synchronization of the first target program has been completed.

[0098] Step S105 : controlling the first target program to suspend sending the state synchronization request to the second target program, and determining that the state synchronization event of the first target program has been completed.

[0099] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can determine whether the first target program has received the status synchronization response information of the second target program.

[0100] In actual application, after receiving the status synchronization request of the first target program, other programs can complete status synchronization according to the status synchronization request sent by the first target program and send status synchronization response information to the first target program.

[0101] Therefore, if the first target program receives the status synchronization response information of the second target program, it means that the status change of the first target program has been synchronized in the second target program. Then, the first target program can be controlled to pause sending the status synchronization request to the second target program, and determine that the status synchronization event of the first target program has been completed.

[0102] It can be seen from the technical solution introduced above that when a program needs to synchronize its status with other programs, the method provided in the embodiment of the present application can introduce an intermediate state in the first terminal where the first target program where the state change occurs is located; and can control the state change of the first target program based on the intermediate state; based on the state change of the first target program, determine whether the first target program has sent a status synchronization request to the second target program; if the first target program has sent a status synchronization request to the second target program, it can be determined whether the first target program has received the status synchronization response information of the second target program; if the first target program receives the status synchronization response information of the second target program, it means that the second target program has received the status change information of the first target program and completed the status synchronization, and it can be determined that the status synchronization event of the first target program has been completed.

[0103] The method provided in the embodiment of the present application can effectively ensure that the status of each communication end can be effectively synchronized and can ensure the consistency of the status of each communication end.

[0104] In actual application, the method provided by the embodiment of the present application can further determine whether the state change of the first target program has completed the state migration, so that different processing strategies can be set to handle the state migration event of the first target program. The following describes the process, which may include the following steps:

[0105] Step S201: determine whether the current state change of the first target program is a completed state transition.

[0106] Specifically, in actual application, when the status of a program changes, the method provided in the embodiment of the present application can monitor the status change of the program in real time.

[0107] When the state of the first target program changes, the method provided in the embodiment of the present application can determine whether the state change of the first target program is a state in which state migration has been completed at the current moment.

[0108] If the state change of the first target program at the current moment is that the state migration has been completed, it can be said that the state change of the first target program has developed into an event, and step S202 can be executed.

[0109] Step S202 : creating an event processing strategy corresponding to the state change of the first target program to process the state transition event of the first target program until the state of the first target program is synchronized.

[0110] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can monitor the state change of the first target program in real time, and can determine whether the state change of the first target program at the current moment is a completed state migration.

[0111] If the state change of the first target program at the current moment is that the state migration has been completed, it can be said that the state change of the first target program has developed into an event, and an event processing strategy corresponding to the state change of the first target program can be created to handle the state migration event of the first target program until the state of the first target program has been synchronized.

[0112] For example,

[0113] Program A is now in "Status 1" and "Event 1" occurs. "Action 1" is executed, causing "Status 1" to change to "Sync Status 1 to 2";

[0114] In this state, if "Event 2" occurs in the status of program A ("Event 2" will execute "Action 2" to change "Status 2" to "Status 3"), you can set more policies in "Action 2*" executed by "Event 2" in the "Sync Status 1 to 2" state to handle the current event.

[0115] For example,

[0116] When the state change of the first target program has developed into an event, the event can be directly ignored;

[0117] When the state change of the first target program has developed into an event, the execution of the original "Action 2" can also be blocked until the state synchronization is completed and the state has been migrated to "Status 2". Then "Action 2" is executed to ensure a controllable and orderly state transition. If necessary, the state can also be controlled to transfer to another state "Status 3*".

[0118] Using intermediate states, combined with the principles of finite state machines, allows for more delicate control over the behavior triggered by events and the final state transition, helping programs achieve controllability of local states and consistency with the state of the program at the other end of the communication.

[0119] That is, there will not be a situation where program A is in "Status 2" but program B is still in "Status 1".

[0120] It can be seen from the technical solution introduced above that the method provided in the embodiment of the present application can monitor the state changes of the first target program in real time, and can determine whether the state changes of the first target program have completed the state migration, so that different processing strategies can be set to handle the state migration events of the first target program.

[0121] In actual application, the method provided in the embodiment of the present application can also monitor in real time whether the state of the first target program changes, so that different treatments can be performed on the state of the first target program. The following describes the process, which may include the following steps:

[0122] Step S301: determine whether the state of the first target program has changed.

[0123] Specifically, in actual application, the method provided in the embodiment of the present application can monitor the status of the first target program in real time. If the status of the first target program changes, the method provided in the embodiment of the present application can determine whether the status of the first target program has changed, so that a timely response can be made when the status of the first target program changes.

[0124] Step S301: controlling the state of the first target program to be persistent.

[0125] Specifically, as can be seen from the above description, the method provided in the embodiment of the present application can determine whether the state of the first target program has changed. If it is determined that the state of the first target program has changed, the method provided in the embodiment of the present application can control the state of the first target program to be persistent, so that the state of the first target program can be restored in a timely manner when an exception occurs in the first target program. This allows the state of the first target program to be restored in a timely manner when an exception occurs in the first target program.

[0126] As can be seen from the technical solutions introduced above, the method provided by the embodiment of the present application can monitor in real time whether the state of the first target program has changed, so as to determine whether the state of the first target program has changed, and when it is determined that the state of the first target program has changed, the state of the first target program can be controlled to be persistent, so that the state of the first target program can be restored in time when an exception occurs in the first target program. The method provided by the embodiment of the present application can effectively persist the state synchronization process, and the synchronization initiator can restore the state being synchronized from the persistent data.

[0127] In actual application, the method provided in the embodiment of the present application can also promptly restore the state of the first target program when an exception occurs in the first target program, and continue the state synchronization work between the first target program and the second target program. The following describes this process, which may include the following steps:

[0128] Step S401: determine whether the state of the first target program is abnormal.

[0129] Specifically, in actual application, the method provided in the embodiment of the present application can monitor the status of the first target program in real time.

[0130] For example, the method provided in the embodiment of the present application can determine whether the state of the first target program is abnormal. When the state of the first target program is abnormal, it indicates that the first target program may need to be restarted or initialized.

[0131] Step S402 : After initializing or restarting the recovery operation of the first target program, immediately recover the state of the first target program to the state before the state of the first target program was persisted, and continue to synchronize the state with the second target program.

[0132] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can monitor in real time whether the state of the first target program changes or becomes abnormal.

[0133] When it is determined that the state of the first target program is abnormal, it indicates that the first target program may need to be restarted or initialized.

[0134] Therefore, when it is determined that an exception has occurred in the first target program, a recovery operation of initializing or restarting the first target program can be performed. After the recovery operation of initializing or restarting the first target program, the state of the first target program is immediately restored to the state before the state of the first target program was persisted, and the state synchronization work with the second target program is continued.

[0135] For example,

[0136] Whenever the status changes, the status of program A can be persisted immediately. If program A encounters an exception and needs to be initialized or restarted, the previously persisted status "SyncStatus 1 to 2" can be immediately restored after recovery to continue synchronizing with the status of program B, which can reduce the work of persisting other modules in the program.

[0137] As can be seen from the technical solutions described above, the method provided in the embodiments of the present application can monitor the state of the first target program in real time to see if an exception occurs. When an exception occurs in the first target program, the state of the first target program can be promptly restored, and the state synchronization between the first target program and the second target program can be continued. The method provided in the embodiments of the present application can effectively persist the state synchronization process, and the synchronization initiator can restore the state being synchronized from the persistent data.

[0138] The terminal communication state synchronization device provided in an embodiment of the present application is described below. The terminal communication state synchronization device described below and the terminal communication state synchronization method described above can refer to each other.

[0139] See also Figure 2 , Figure 2 This is a schematic diagram of the structure of a terminal communication status synchronization device disclosed in an embodiment of the present application.

[0140] like Figure 2 As shown, the terminal communication status synchronization device may include:

[0141] An intermediate state introducing unit 101 is configured to introduce an intermediate state into a first terminal where a first target program undergoing state change is located;

[0142] A first control unit 102, configured to control a state change of the first target program according to the intermediate state;

[0143] A first determining unit 103 is configured to determine, based on a state change of the first target program, whether the first target program has sent a state synchronization request to the second target program;

[0144] The second determining unit 104 is configured to determine whether the first target program has received a state synchronization response message from the second target program when the execution result of the first determining unit is that the first target program has sent a state synchronization request to the second target program;

[0145] The determining unit 105 is configured to determine that the state synchronization event of the first target program has been completed when the execution result of the second determining unit is that the first target program receives the state synchronization response information of the second target program.

[0146] It can be seen from the technical solution introduced above that when a program needs to synchronize its status with other programs, the device provided by the embodiment of the present application can introduce an intermediate state at the first terminal where the first target program where the state change occurs is located; and can control the state change of the first target program based on the intermediate state; based on the state change of the first target program, determine whether the first target program has sent a status synchronization request to the second target program; if the first target program has sent a status synchronization request to the second target program, it can be determined whether the first target program has received the status synchronization response information of the second target program; if the first target program receives the status synchronization response information of the second target program, it means that the second target program has received the status change information of the first target program and completed the status synchronization, and it can be determined that the status synchronization event of the first target program has been completed.

[0147] The device provided in the embodiment of the present application can effectively ensure that the status of each communication end can be effectively synchronized and can ensure the consistency of the status of each communication end.

[0148] Further optionally, the device may further include:

[0149] The pausing unit is configured to control the first target program to suspend sending the status synchronization request to the second target program when the execution result of the second judging unit is that the first target program receives the status synchronization response information of the second target program.

[0150] The specific processing flow of each unit included in the terminal communication status synchronization device can refer to the relevant introduction of the terminal communication status synchronization method above, which will not be repeated here.

[0151] The terminal communication state synchronization device provided in the embodiment of the present application can be applied to terminal communication state synchronization equipment, such as terminals: mobile phones, computers, etc. Optionally, Figure 3 The hardware structure diagram of the terminal communication status synchronization device is shown. Figure 3 The hardware structure of the terminal communication status synchronization device may include: at least one processor 1, at least one communication interface 2, at least one memory 3 and at least one communication bus 4.

[0152] In an embodiment of the present application, the number of processor 1 , communication interface 2 , memory 3 , and communication bus 4 is at least one, and the processor 1 , communication interface 2 , and memory 3 communicate with each other through the communication bus 4 .

[0153] The processor 1 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application;

[0154] The memory 3 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory;

[0155] The memory stores a program, and the processor can call the program stored in the memory, wherein the program is used to implement various processing flows of the terminal in the terminal communication status synchronization solution.

[0156] An embodiment of the present application further provides a readable storage medium, which may store a program suitable for execution by a processor, wherein the program is used to implement various processing flows of the aforementioned terminal in the terminal communication status synchronization solution.

[0157] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.

[0158] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0159] The above description of the disclosed embodiments is intended to enable those skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. The various embodiments may be combined with one another. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A terminal communication status synchronization method, characterized in that: include: Introducing an intermediate state at a first terminal where a first target program undergoing a state change is located; controlling a state change of the first target program according to the intermediate state; Based on the state change of the first target program, determining whether the first target program has sent a state synchronization request to the second target program; If the first target program has sent a state synchronization request to the second target program, determining whether the first target program has received a state synchronization response message from the second target program; If the first target program receives the state synchronization response information of the second target program, it is determined that the state synchronization event of the first target program has been completed; After the first terminal where the first target program is located enters an intermediate state, the state change types of the first target program include: target state, target event, and target action; The target state includes the current state of the first target program and the state to be transferred after the conditions are met; the target event is the condition for the state to be transferred; the target action is the action to be performed after the transfer condition is met; When the target event occurs, the state of the first target program is converted from the current state to the intermediate state, and then the first target program continuously resends the state synchronization message to other programs until a state synchronization response is received from other programs. The first target program executes the target action and converts from the intermediate state to the state to be migrated.

2. The method according to claim 1, characterized in that The method further includes: If the first target program receives the status synchronization response information from the second target program, the first target program is controlled to suspend sending the status synchronization request to the second target program.

3. The method according to claim 1, characterized in that The method further includes: Determining whether the state change of the first target program at the current moment is a completed state transition; If the state change of the first target program at the current moment is that the state migration has been completed, an event processing strategy corresponding to the state change of the first target program is created to process the state migration event of the first target program until the state of the first target program is synchronized.

4. The method according to claim 1, wherein The method further includes: Determining whether the state of the first target program has changed; If the state of the first target program changes, the state of the first target program is controlled to be persistent.

5. The method according to claim 4, characterized in that The method further includes: Determining whether an abnormality occurs in the state of the first target program; If an exception occurs in the first target program, after initializing or restarting the first target program, the state of the first target program is immediately restored to the state before the state of the first target program was persisted, and the state synchronization work with the second target program is continuously performed.

6. A terminal communication status synchronization device, characterized in that: include: an intermediate state introducing unit, configured to introduce an intermediate state at a first terminal where a first target program undergoing state change is located; a first control unit, configured to control a state change of the first target program according to the intermediate state; a first determining unit, configured to determine, based on a state change of the first target program, whether the first target program has sent a state synchronization request to the second target program; a second determining unit configured to determine whether the first target program has received a state synchronization response message from the second target program when the execution result of the first determining unit is that the first target program has sent a state synchronization request to the second target program; a determining unit, configured to determine that the state synchronization event of the first target program has been completed when the execution result of the second determining unit is that the first target program receives the state synchronization response information of the second target program; After the first terminal where the first target program is located enters an intermediate state, the state change types of the first target program include: target state, target event, and target action; The target state includes the current state of the first target program and the state to be transferred after the conditions are met; the target event is the condition for the state to be transferred; the target action is the action to be performed after the transfer condition is met; When the target event occurs, the state of the first target program is converted from the current state to the intermediate state, and then the first target program continuously resends the state synchronization message to other programs until a state synchronization response is received from other programs. The first target program executes the target action and converts from the intermediate state to the state to be migrated.

7. The device according to claim 6, characterized in that The device also includes: The pausing unit is configured to control the first target program to suspend sending the status synchronization request to the second target program when the execution result of the second judging unit is that the first target program receives the status synchronization response information of the second target program.

8. A terminal communication status synchronization device, characterized in that: include: one or more processors, and memory; The memory stores computer-readable instructions, which, when executed by the one or more processors, implement the steps of the terminal communication status synchronization method according to any one of claims 1 to 5.

9. A readable storage medium, characterized in that: The readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors implement the steps of the terminal communication status synchronization method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Cooperative control method based on finite state automaton

    CN103412791A

  • Applet state synchronization method and device and computer storage medium

    CN110113407A