A bidirectional data transmission system, method and device based on heartbeat mechanism
By introducing a frequency dynamic adjustment mechanism into the heartbeat mechanism, the existing technology problem of increasing network transmission volume during low-frequency small data transmission is solved, low-cost, efficient real-time two-way data transmission is achieved, and continuous continuity between the client and the server is ensured. Connection and data transfer.
Patent Information
- Application Number
- CN202210926563.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-03
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2042-08-03
AI Technical Summary
In a large-scale C/S architecture, it is difficult for existing technology to use a message mechanism to realize real-time two-way data transmission between the client and the server without increasing the network transmission volume, especially when the business data is low-frequency and the amount of data is high. In small cases, traditional methods will increase operation and maintenance and development costs, or affect the real-time nature of data.
By introducing a frequency dynamic adjustment mechanism into the heartbeat mechanism, the client sends status messages to the server at a preset frequency, and the server dynamically adjusts the frequency based on the received messages and historical data records to ensure real-time without increasing network transmission volume. Bidirectional data transfer.
It achieves low-cost development and operation and maintenance, while ensuring the timeliness of policy updates and data transmission, reducing the amount of data transmission, and ensuring continuous connection and data transmission between the client and the server.
Smart Images

Figure CN115334141B
Abstract
Description
Technical Field
[0001] This invention relates to a bidirectional data transmission system, method, and apparatus based on a heartbeat mechanism, belonging to the field of information security technology. Background Technology
[0002] In a large-scale client / server architecture, the client communicates with the server via a heartbeat mechanism to report its status. If the server has content to send to the client, a dedicated data transmission channel is used. Alternatively, a dedicated messaging mechanism, such as a pub-sub subscription mechanism, can be used, allowing the client to actively listen for updates. While a dedicated transmission channel or messaging mechanism is necessary for large volumes of business data, it is less suitable if the business data is very infrequent and small in volume. Establishing an additional messaging channel also increases operational and development costs.
[0003] To meet regulatory requirements for IT systems while reducing development complexity, the best approach is to use a single messaging mechanism to handle both heartbeat detection and low-frequency, small-data transmission. Using two messaging mechanisms would increase management and development costs. Sharing a single mechanism could lead to a large number of clients continuously sending numerous, low-value heartbeat synchronization messages. While reducing the heartbeat frequency could decrease the amount of communication data, this would compromise the real-time performance of the data transmission. Summary of the Invention
[0004] The purpose of this invention is to overcome the shortcomings of existing technologies and provide a bidirectional data transmission system, method, and apparatus based on a heartbeat mechanism, which can achieve real-time bidirectional data transmission between the client and server using only one message mechanism without increasing network traffic. To achieve the above objective, this invention employs the following technical solution:
[0005] In a first aspect, the present invention provides a bidirectional data transmission system based on a heartbeat mechanism, comprising a client and a server;
[0006] The client sends status messages to the server at a set frequency;
[0007] The server updates the status flag of the corresponding client in the client list based on the received status messages;
[0008] The server queries the data list of the corresponding client in the client list and returns a message to the corresponding client.
[0009] The frequency settings include a pre-set default frequency and a frequency that is dynamically adjusted based on the server's returned messages and historical data records.
[0010] In conjunction with the first aspect, the status message is further defined as a message indicating that the current client has entered an update state.
[0011] In conjunction with the first aspect, the server further updates the status flags of the corresponding clients in the client list, including:
[0012] The server updates the status flag of the corresponding client to "online" based on the received status message;
[0013] If the client's status flag is "online" and the time interval since the last received status message exceeds the preset default frequency, update the client's status flag to "offline".
[0014] In conjunction with the first aspect, the server further returns a message to the corresponding client, including:
[0015] If the client's data list in the client list has no business data, return an empty message to the client.
[0016] If the client's data list contains business data and the number of business data entries in the data list is greater than one, then the first business data entry and the data flag are returned to the client; if the number of business data entries in the data list is exactly one, then the business data is returned to the client.
[0017] In conjunction with the first aspect, further determine the frequency of dynamic adjustments, including: when the server returns an empty message.
[0018] Based on the server's historical data records, predict the probability that the server has data to be sent in the next moment. If the probability is less than or equal to a preset first threshold, determine the frequency of the next moment as the default frequency.
[0019] If the probability is greater than a preset first threshold and less than or equal to a second threshold, the frequency at the next moment is determined to be the first frequency, and it is gradually decayed within a first preset duration according to a preset decay coefficient; if the server's returned message is an empty message or does not have a data flag, the frequency continues to gradually decay until the frequency is the default frequency; if the server's returned message has a data flag, the frequency at the next moment is updated to the second frequency.
[0020] If the probability is greater than the preset second threshold, the frequency at the next moment is determined to be the second frequency and continues for the second preset duration. If the server's return message is an empty message or does not have a data flag, the frequency is reduced to the first frequency and gradually reduced until the frequency is the default frequency. If the server's return message has a data flag, the frequency at the next moment is the second frequency.
[0021] The frequencies, from lowest to highest, are: default frequency, first frequency, and second frequency.
[0022] In conjunction with the first aspect, further determining the frequency of dynamic adjustments also includes: when the server returns a non-empty message,
[0023] Determine if the server's returned message contains a data flag:
[0024] If a data flag exists, determine the frequency of the next moment as the second frequency, and maintain the frequency as the second frequency for the first preset duration;
[0025] If there is no data flag, the probability that there is data to be sent in the next moment is predicted based on the server's historical data records. If the probability is less than or equal to the preset first threshold, the frequency of the next moment is determined to be the default frequency.
[0026] If the probability is greater than a preset first threshold and less than or equal to a second threshold, the frequency at the next moment is determined to be the first frequency, and it is gradually decayed within a first preset duration according to a preset decay coefficient; if the server's returned message is an empty message or does not have a data flag, the frequency continues to gradually decay until the frequency is the default frequency; if the server's returned message has a data flag, the frequency at the next moment is updated to the second frequency.
[0027] If the probability is greater than the preset second threshold, the frequency at the next moment is determined to be the second frequency and continues for the second preset duration. If the server's returned message is an empty message or does not have a data flag, the frequency is reduced to the first frequency and gradually reduced until the frequency is the default frequency. If the server's returned message has a data flag, the frequency at the next moment is the second frequency. The frequencies from low to high are: default frequency, first frequency, and second frequency.
[0028] Secondly, the present invention provides a bidirectional data transmission method based on a heartbeat mechanism, executed by a client, comprising:
[0029] Send status messages to the server at the set frequency;
[0030] The frequency for the next moment is dynamically adjusted based on the server's returned messages and historical data records.
[0031] Thirdly, the present invention provides a bidirectional data transmission device based on a heartbeat mechanism, located at a client, comprising:
[0032] Sending module: Used to send status messages to the server at a set frequency;
[0033] Frequency adjustment module: Used to dynamically adjust the frequency for the next moment based on the server's returned messages and historical data records.
[0034] Fourthly, the present invention provides a bidirectional data transmission method based on a heartbeat mechanism, executed by a server, comprising:
[0035] Update the status flag of the corresponding client in the client list based on the received client status message;
[0036] Query the data list of the corresponding client in the client list and return the message to the corresponding client.
[0037] Fifthly, the present invention provides a bidirectional data transmission device based on a heartbeat mechanism, located on a server, comprising:
[0038] Update module: Used to update the status flag of the corresponding client in the client list based on the received client status message;
[0039] The message return module is used to query the data list of the corresponding client in the client list and return a message to the corresponding client.
[0040] Compared with the prior art, the beneficial effects achieved by the bidirectional data transmission system, method, and apparatus based on a heartbeat mechanism provided in this invention include:
[0041] This invention includes a client and a server. The client sends status messages to the server at a set frequency. The server updates the status flag of the corresponding client in the client list based on the received status messages. The server queries the data list of the corresponding client in the client list and returns a message to the corresponding client. This invention allows the client to receive messages from the server and send status messages. Because it uses only one message mechanism, the development and maintenance costs are low, while ensuring timely policy updates and reducing data transmission volume. It achieves a good balance between ensuring a continuous connection between the client and the server and enabling real-time transmission of policies and instructions.
[0042] The client-side frequency settings of this invention include a pre-set fixed frequency and a dynamically adjusted frequency based on server response messages and server historical data records. This invention provides a client-side frequency that can be dynamically adjusted, achieving a relatively real-time bidirectional data transmission effect without increasing network traffic. Attached Figure Description
[0043] Figure 1 This is a flowchart of a bidirectional data transmission method based on a heartbeat mechanism provided in Embodiment 1 of the present invention. Detailed Implementation
[0044] The present invention will be further described below with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and should not be used to limit the scope of protection of the present invention.
[0045] Example 1:
[0046] This invention provides a bidirectional data transmission system based on a heartbeat mechanism, including a client and a server, both running on electronic devices, including PCs, mobile phones, tablets, and devices with or without screens. The server runs continuously, passively receiving messages from the client and not actively sending messages to the client.
[0047] The client runs automatically after the electronic device is powered on, sending status messages to the server at a set frequency. The set frequency includes a pre-set fixed frequency and a dynamically adjusted frequency based on the server's response messages and historical data records. Status messages indicate that the client is currently in an update state. Client states include: online status and heartbeat status.
[0048] The server updates the status flags of the corresponding clients in the client list, including:
[0049] The server updates the status flag of the corresponding client to "online" based on the received status message;
[0050] If the client's status flag is "online" and the time interval since the last received status message exceeds the preset default frequency, update the client's status flag to "offline".
[0051] The server returns a message to the corresponding client, including:
[0052] If the client's data list in the client list has no business data, return an empty message to the client.
[0053] If the client's data list contains business data and the number of business data entries in the data list is greater than one, then the first business data entry and the data flag are returned to the client; if the number of business data entries in the data list is exactly one, then the business data is returned to the client.
[0054] Determine the frequency of dynamic adjustments, including when the server returns an empty message.
[0055] Based on the server's historical data records, predict the probability that the server has data to be sent in the next moment. If the probability is less than or equal to a preset first threshold, determine the frequency of the next moment as the default frequency.
[0056] If the probability is greater than a preset first threshold and less than or equal to a second threshold, the frequency at the next moment is determined to be the first frequency, and it is gradually decayed within a first preset duration according to a preset decay coefficient; if the server's returned message is an empty message or does not have a data flag, the frequency continues to gradually decay until the frequency is the default frequency; if the server's returned message has a data flag, the frequency at the next moment is updated to the second frequency.
[0057] If the probability is greater than the preset second threshold, the frequency at the next moment is determined to be the second frequency and continues for the second preset duration. If the server's return message is an empty message or does not have a data flag, the frequency is reduced to the first frequency and gradually reduced until the frequency is the default frequency. If the server's return message has a data flag, the frequency at the next moment is the second frequency.
[0058] The frequencies, from lowest to highest, are: default frequency, first frequency, and second frequency.
[0059] Determining the frequency of dynamic adjustments also includes: when the server returns a non-empty message.
[0060] Determine if the server's returned message contains a data flag:
[0061] If a data flag exists, determine the frequency of the next moment as the second frequency, and maintain the frequency as the second frequency for the first preset duration;
[0062] If there is no data flag, the probability that there is data to be sent in the next moment is predicted based on the server's historical data records. If the probability is less than or equal to the preset first threshold, the frequency of the next moment is determined to be the default frequency.
[0063] If the probability is greater than a preset first threshold and less than or equal to a second threshold, the frequency at the next moment is determined to be the first frequency, and it is gradually decayed within a first preset duration according to a preset decay coefficient; if the server's returned message is an empty message or does not have a data flag, the frequency continues to gradually decay until the frequency is the default frequency; if the server's returned message has a data flag, the frequency at the next moment is updated to the second frequency.
[0064] If the probability is greater than the preset second threshold, the frequency at the next moment is determined to be the second frequency and continues for the second preset duration. If the server's return message is an empty message or does not have a data flag, the frequency is reduced to the first frequency and gradually reduced until the frequency is the default frequency. If the server's return message has a data flag, the frequency at the next moment is the second frequency.
[0065] The frequencies, from lowest to highest, are: default frequency, first frequency, and second frequency.
[0066] Example 2:
[0067] This invention provides a bidirectional data transmission method based on a heartbeat mechanism, executed by a client, including:
[0068] Send status messages to the server at the set frequency;
[0069] The frequency for the next moment is dynamically adjusted based on the server's returned messages and historical data records.
[0070] Example 3:
[0071] This invention provides a bidirectional data transmission device based on a heartbeat mechanism, located on a client side, comprising:
[0072] Sending module: Used to send status messages to the server at a set frequency;
[0073] Frequency adjustment module: Used to dynamically adjust the frequency for the next moment based on the server's returned messages and historical data records.
[0074] Example 4:
[0075] This invention provides a bidirectional data transmission method based on a heartbeat mechanism, executed by a server, comprising:
[0076] Update the status flag of the corresponding client in the client list based on the received client status message;
[0077] Query the data list of the corresponding client in the client list and return the message to the corresponding client.
[0078] Example 5:
[0079] This invention provides a bidirectional data transmission device based on a heartbeat mechanism, located on a server, comprising:
[0080] Update module: Used to update the status flag of the corresponding client in the client list based on the received client status message;
[0081] The message return module is used to query the data list of the corresponding client in the client list and return a message to the corresponding client.
[0082] Example 6:
[0083] Based on Examples 1 to 5, this example introduces... Figure 1 The specific flow of a bidirectional data transmission method based on a heartbeat mechanism in the illustrated embodiment is as follows:
[0084] Step 1: After the client is powered on, its default online status is "offline," and it actively connects to the pre-configured server. The connection method can be any of HTTP, SOCKET, UDP, or other custom messages. If the client successfully connects to the server, its online status changes to "online"; if the connection fails, it reconnects using the pre-configured connection method until it succeeds.
[0085] Step 2: After the client successfully connects to the server, it changes the heartbeat status to "normal" and sends status messages to the server at the preset default frequency.
[0086] In this embodiment, the default preset frequency is once per minute, meaning the client reports its status to the server once per minute. In this embodiment, the message format is a JSON object, including client information, status message, and current time.
[0087] Step 3: The server maintains a list of clients, storing information for each client.
[0088] The client information includes the current status and the last update time; the client list can store multiple sets of data.
[0089] Based on the received status messages, the server updates the status flag of the corresponding client in the client list. This includes: finding the corresponding client list based on the client number in the status message, updating the client's "last update time," and passively updating the corresponding client's status flag to "online." If the client's status flag is "online," the server checks the status of all "online" clients at a pre-set frequency. If the last update time exceeds a preset time, such as 3 minutes, the server actively updates the client's status flag to "offline," and stops periodically updating its status.
[0090] Step 4: The server returns a message to the corresponding client.
[0091] The server queries the data list of the corresponding client in the client list and returns a message to the corresponding client, including:
[0092] If the client's data list in the client list has no business data, return an empty message to the client.
[0093] If the client's data list contains business data and the number of business data entries in the data list is greater than one, then the first business data entry and the data flag are returned to the client; if the number of business data entries in the data list is exactly one, then the business data is returned to the client.
[0094] Step 5: After receiving the reply message from the server, the client checks the content of the data section, updates the local heartbeat status based on the content, and determines the frequency of dynamic adjustment for the next moment.
[0095] Based on the server's response message, if the server's response message is empty and there is no data flag, the client's heartbeat status is "normal," and the prediction module is invoked.
[0096] Predict the probability that the server has data to send in the next moment based on historical server data records:
[0097] If the probability is less than or equal to a preset first threshold, the frequency at the next moment is determined to be the default frequency. For example, if the first threshold is 10%, the default frequency has been preset to 1 minute / time.
[0098] If the probability is greater than a preset first threshold and less than or equal to a second threshold, the frequency at the next moment is determined as the first frequency, and it is successively decayed within a first preset duration according to a preset decay coefficient. In this embodiment, the second threshold is 50%, the first frequency is 10 seconds / time, and the first preset duration is 2 minutes. If the server's returned message is an empty message or does not have a data flag, the frequency continues to decay successively until the frequency is the default frequency. If the server's returned message has a data flag, the frequency at the next moment is updated to the second frequency. In this embodiment, the second frequency is 1 second / time.
[0099] If the probability is greater than a preset second threshold, the frequency at the next moment is determined to be the second frequency, and it continues for a second preset duration. In this embodiment, the second preset duration is 30 seconds. If the server's returned message is an empty message or does not have a data flag, the frequency is reduced to the first frequency, and the frequency is gradually reduced until the frequency is the default frequency. If the server's returned message has a data flag, the frequency at the next moment is the second frequency.
[0100] If the prediction is accurate, the waiting time to receive the next new data is reduced from 1 minute to 1 second.
[0101] Based on the server's response message, if the server's response message is not empty, the data is extracted and processed accordingly.
[0102] Determine if the server's returned message contains a data flag:
[0103] If a data flag exists, change the client's heartbeat status to "immediately", that is, the delay time is 0, determine the frequency of the next moment as the second frequency, and maintain the frequency as the second frequency for the first preset duration;
[0104] If no data flag is present, the probability of data to be sent at the next moment is predicted based on historical server data. If the probability is less than or equal to a preset first threshold, the frequency at the next moment is determined to be the default frequency. If the probability is greater than the preset first threshold but less than or equal to a second threshold, the frequency at the next moment is determined to be the first frequency, and it decreases sequentially within a first preset duration according to a preset attenuation coefficient. If the server's returned message is an empty message or does not have a data flag, the frequency continues to decrease sequentially until it reaches the default frequency. If the server's returned message has a data flag, the frequency at the next moment is updated to the second frequency. If the probability is greater than the preset second threshold, the frequency at the next moment is determined to be the second frequency, and it remains so for a second preset duration. If the server's returned message is an empty message or does not have a data flag, the frequency decreases to the first frequency, and this decreases sequentially until it reaches the default frequency. If the server's returned message has a data flag, the frequency at the next moment is the second frequency.
[0105] Repeating this process allows for simultaneous monitoring of status and data transmission using only a single messaging mechanism. It offers low development and maintenance costs while ensuring timely policy updates and reducing data transmission volume. It achieves a good balance between maintaining a continuous connection between the client and server and delivering policies and instructions in real time. Because the heartbeat frequency can be dynamically adjusted, data transmission latency is relatively low, enabling relatively real-time bidirectional data transmission without increasing network traffic.
[0106] In this embodiment, the prediction module uses a linear classifier. The inputs are time (24-hour format), whether it's a holiday, day of the week, and customer ID. The output is the probability that the server will send business data in the next second. Data is recorded each time the server sends business data, and the most recent 1000 data points are used for training.
[0107] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0108] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0109] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0110] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0111] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A two-way data transmission system based on a heartbeat mechanism, characterized in that: Includes client and server; The client sends status messages to the server at a set frequency; The server updates the status flag of the corresponding client in the client list according to the received status message; The server queries the data list of the corresponding client in the client list and returns a message to the corresponding client; wherein the server returns the message to the corresponding client, including: If the data list of the client in the client list has no business data, an empty message is returned to the client; If there is business data in the data list of the client in the client list, and the number of business data in the data list is greater than 1, then the first business data and data flag in the data list are returned to the client; if there is only 1 business data in the data list, then the business data is returned to the client; The set frequency includes a preset default frequency and a frequency dynamically adjusted based on a return message from the server and historical data records of the server; Determine the frequency of dynamic adjustment, including: when the server's return message is an empty message, Predicting the probability that the server has data to be sent at the next moment based on the historical data records of the server, if the probability is less than or equal to a preset first threshold, determining the frequency at the next moment as the default frequency; If the probability is greater than the preset first threshold and less than or equal to the second threshold, determine that the frequency at the next moment is the first frequency, and decay it successively according to the preset attenuation coefficient within the first preset time length; if the return message from the server is an empty message or there is no data flag, continue to decay the frequency successively until the frequency is the default frequency; if the return message from the server has a data flag, update the frequency at the next moment to the second frequency; If the probability is greater than the preset second threshold, the frequency at the next moment is determined to be the second frequency and lasts for the second preset time. If the return message from the server is an empty message or there is no data flag, the frequency is attenuated to the first frequency and the frequency is gradually attenuated until the frequency is the default frequency. If the return message from the server has a data flag, the frequency at the next moment is the second frequency. Among them, the frequencies from low to high are: default frequency, first frequency, second frequency; Determine the frequency of dynamic adjustment, and also include: when the server's return message is not an empty message, Determine whether the server's return message contains a data flag: If the data flag is present, determining the frequency at the next moment to be the second frequency, and maintaining the frequency at the second frequency within a first preset time length; If there is no data flag, the probability that the server has data to be sent at the next moment is predicted based on the historical data records of the server, and the probability is less than or equal to the preset first threshold, and the frequency at the next moment is determined to be the default frequency; If the probability is greater than the preset first threshold and less than or equal to the second threshold, determine that the frequency at the next moment is the first frequency, and decay it successively according to the preset attenuation coefficient within the first preset time length; if the return message from the server is an empty message or there is no data flag, continue to decay the frequency successively until the frequency is the default frequency; if the return message from the server has a data flag, update the frequency at the next moment to the second frequency; If the probability is greater than the preset second threshold, the frequency at the next moment is determined to be the second frequency and lasts for the second preset time. If the return message from the server is an empty message or there is no data flag, the frequency is attenuated to the first frequency and the frequency is gradually attenuated until the frequency is the default frequency. If the return message from the server has a data flag, the frequency at the next moment is the second frequency. Among them, the frequencies from low to high are: default frequency, first frequency, second frequency.
2. The two-way data transmission system based on the heartbeat mechanism according to claim 1 is characterized in that: The status message is: a message indicating that the current client has entered an update state.
3. The two-way data transmission system based on the heartbeat mechanism according to claim 1 is characterized in that: The server updates the status flags of the corresponding clients in the client list, including: The server updates the status flag of the corresponding client to "online" according to the received status message; If the client's status flag is "online" and the time interval from the last receipt of a status message exceeds a preset default time interval, the client's status flag is updated to "offline", where the default time interval is: the time interval between two status messages sent at the default frequency.
4. A bidirectional data transmission method based on a heartbeat mechanism, characterized in that: Executed by the client, including: Sending status messages to the server at a set frequency; the set frequency includes a preset default frequency and a frequency dynamically adjusted based on the server's return message and the server's historical data record; Determine the frequency of dynamic adjustment, including: when the server's return message is an empty message, Predicting the probability that the server has data to be sent at the next moment based on the historical data records of the server, if the probability is less than or equal to a preset first threshold, determining the frequency at the next moment as the default frequency; If the probability is greater than the preset first threshold and less than or equal to the second threshold, determine that the frequency at the next moment is the first frequency, and decay it successively according to the preset attenuation coefficient within the first preset time length; if the return message from the server is an empty message or there is no data flag, continue to decay the frequency successively until the frequency is the default frequency; if the return message from the server has a data flag, update the frequency at the next moment to the second frequency; If the probability is greater than the preset second threshold, the frequency at the next moment is determined to be the second frequency and lasts for the second preset time. If the return message from the server is an empty message or there is no data flag, the frequency is attenuated to the first frequency and the frequency is gradually attenuated until the frequency is the default frequency. If the return message from the server has a data flag, the frequency at the next moment is the second frequency. Among them, the frequencies from low to high are: default frequency, first frequency, second frequency; Determine the frequency of dynamic adjustment, and also include: when the server's return message is not an empty message, Determine whether the server's return message contains a data flag: If the data flag is present, determining the frequency at the next moment to be the second frequency, and maintaining the frequency at the second frequency within a first preset time length; If there is no data flag, the probability that the server has data to be sent at the next moment is predicted based on the historical data records of the server, and the probability is less than or equal to the preset first threshold, and the frequency at the next moment is determined to be the default frequency; If the probability is greater than the preset first threshold and less than or equal to the second threshold, determine that the frequency at the next moment is the first frequency, and decay it successively according to the preset attenuation coefficient within the first preset time length; if the return message from the server is an empty message or there is no data flag, continue to decay the frequency successively until the frequency is the default frequency; if the return message from the server has a data flag, update the frequency at the next moment to the second frequency; If the probability is greater than the preset second threshold, the frequency at the next moment is determined to be the second frequency and lasts for the second preset time. If the return message from the server is an empty message or there is no data flag, the frequency is attenuated to the first frequency and the frequency is gradually attenuated until the frequency is the default frequency. If the return message from the server has a data flag, the frequency at the next moment is the second frequency. Among them, the frequencies from low to high are: default frequency, first frequency, second frequency.
5. A bidirectional data transmission device based on a heartbeat mechanism, characterized in that: Located on the client side, including: Sending module: used to send status messages to the server at a set frequency; the set frequency includes a preset default frequency and a frequency dynamically adjusted based on the server's return message and the server's historical data record; Frequency adjustment module: used to determine the frequency for dynamic adjustment, including: when the server's return message is an empty message, Predicting the probability that the server has data to be sent at the next moment based on the historical data records of the server, if the probability is less than or equal to a preset first threshold, determining the frequency at the next moment as the default frequency; If the probability is greater than the preset first threshold and less than or equal to the second threshold, determine that the frequency at the next moment is the first frequency, and decay it successively according to the preset attenuation coefficient within the first preset time length; if the return message from the server is an empty message or there is no data flag, continue to decay the frequency successively until the frequency is the default frequency; if the return message from the server has a data flag, update the frequency at the next moment to the second frequency; If the probability is greater than the preset second threshold, the frequency at the next moment is determined to be the second frequency and lasts for the second preset time. If the return message from the server is an empty message or there is no data flag, the frequency is attenuated to the first frequency and the frequency is gradually attenuated until the frequency is the default frequency. If the return message from the server has a data flag, the frequency at the next moment is the second frequency. Among them, the frequencies from low to high are: default frequency, first frequency, second frequency; Determine the frequency of dynamic adjustment, and also include: when the server's return message is not an empty message, Determine whether the server's return message contains a data flag: If the data flag is present, determining the frequency at the next moment to be the second frequency, and maintaining the frequency at the second frequency within a first preset time length; If there is no data flag, the probability that the server has data to be sent at the next moment is predicted based on the historical data records of the server, and the probability is less than or equal to the preset first threshold, and the frequency at the next moment is determined to be the default frequency; If the probability is greater than the preset first threshold and less than or equal to the second threshold, determine that the frequency at the next moment is the first frequency, and decay it successively according to the preset attenuation coefficient within the first preset time length; if the return message from the server is an empty message or there is no data flag, continue to decay the frequency successively until the frequency is the default frequency; if the return message from the server has a data flag, update the frequency at the next moment to the second frequency; If the probability is greater than the preset second threshold, the frequency at the next moment is determined to be the second frequency and lasts for the second preset time. If the return message from the server is an empty message or there is no data flag, the frequency is attenuated to the first frequency and the frequency is gradually attenuated until the frequency is the default frequency. If the return message from the server has a data flag, the frequency at the next moment is the second frequency. Among them, the frequencies from low to high are: default frequency, first frequency, second frequency.
Citation Information
Patent Citations
Implementation method and device for information pushing
CN103491512A
Data pushing method, server, client and data pushing system
CN105471964A
Communication connection maintaining method, system and related equipment
CN109905259A
Heartbeat frequency adjusting method and device
CN111343045A
