Data transmission method, system and device, electronic equipment and computer storage medium
By employing state synchronization and message caching mechanisms, the problem of message loss during network interruptions or disconnections is resolved, ensuring the reliability and consistency of message transmission and guaranteeing timely delivery and integrity of messages.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGZHOU SHIYUAN ELECTRONICS CO LTD
- Filing Date
- 2024-12-13
- Publication Date
- 2026-06-16
Smart Images

Figure CN122226784A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, specifically to a data transmission method, system, device, electronic device, and computer storage medium. Background Technology
[0002] With the rapid development of communication technology, the demand for message transmission between devices is increasing, and higher requirements are being placed on the reliability and consistency of messages.
[0003] In existing technologies, when devices transmit messages, messages may be lost or fail to reach the receiving end in a timely manner, resulting in a lack of guarantee for message consistency and integrity. Summary of the Invention
[0004] This application aims to at least address one of the technical problems existing in related technologies. To this end, embodiments of this application provide a data transmission method, system, apparatus, electronic device, and computer storage medium, aiming to improve the reliability and consistency of message transmission.
[0005] In a first aspect, embodiments of this application provide a data transmission method, wherein the data transmission method is applied at a sending end, the sending end having a preset state synchronization mechanism, and the method includes:
[0006] In response to a send request for a message to be sent, the message to be sent is cached, and the receiving end to be received is determined.
[0007] The first device state synchronized by the state synchronization mechanism and the second device state of the receiving end are obtained;
[0008] Based on the first device status and the second device status, a message set is sent to the receiving end; wherein, the message set includes the message to be sent, and historical messages in the cache whose transmission status is not sent;
[0009] Receive an acknowledgment message based on the message set, and update the transmission status of the message set in the cache.
[0010] Secondly, embodiments of this application provide a data transmission method, which is applied to a server, the server having a preset state synchronization mechanism, the method comprising:
[0011] Receive a set of messages sent by the sender, cache the set of messages, and determine the receiving end to receive them;
[0012] Obtain the first device state of the sending end and the second device state of the receiving end synchronized by the state synchronization mechanism;
[0013] Based on the second device status, a new message set is sent to the receiving end; wherein, the new message set includes the message set and historical messages in the cache whose transmission status is not sent;
[0014] Receive an acknowledgment message based on the new message set, and update the transmission status of the new message set in the cache;
[0015] The acknowledgment message is fed back to the sending end based on the first device status, so that the sending end updates the transmission status of the message set.
[0016] Thirdly, embodiments of this application provide a data transmission system, which includes a transmitter and a server, both of which are pre-configured with a state synchronization mechanism.
[0017] The data transmission system includes a transmitter and a server, wherein,
[0018] The sending end is used to respond to a sending request for a message to be sent, to buffer the message to be sent, and to determine the receiving end to receive it.
[0019] The sending end is used to obtain the first device state synchronized by the state synchronization mechanism and the second device state of the receiving end; wherein, the second device state is used to indicate whether the message retransmission mechanism is triggered.
[0020] The sending end is configured to send a message set to the server according to the state of the first device; wherein the message set includes the message to be sent, and historical messages in the cache whose transmission status is not sent;
[0021] The server is configured to receive the message set, cache the message set, and determine the receiving end to receive the message;
[0022] The server is used to obtain the first device state of the sending end and the second device state of the receiving end synchronized by the state synchronization mechanism.
[0023] The server is configured to send a new message set to the receiving end based on the state of the second device; wherein the new message set includes the message set and historical messages in the cache whose transmission status is not sent;
[0024] The server is configured to receive an acknowledgment message based on the new message set, update the transmission status of the new message set in the cache, and send the acknowledgment message to the sending end according to the first device status.
[0025] The sending end is used to update the transmission status of the message set based on the acknowledgment response message.
[0026] Fourthly, embodiments of this application provide a data transmission device, which is disposed at a transmitting end, and the transmitting end has a preset state synchronization mechanism. The device includes:
[0027] The first caching module is used to respond to a sending request for a message to be sent, cache the message to be sent, and determine the receiving end to receive it.
[0028] The first synchronization module is used to obtain the first device state synchronized by the state synchronization mechanism and the second device state of the receiving end sent by the server, wherein the second device state is used to indicate whether the message retransmission mechanism is triggered.
[0029] The first sending module is configured to send a message set to the receiving end according to the first device state and the second device state; wherein, the message set includes the message to be sent, and historical messages in the buffer whose transmission status is not sent;
[0030] The first update module is used to receive an acknowledgment response message based on the message set and update the transmission status of the message set in the cache.
[0031] Fifthly, embodiments of this application provide a data transmission device, which is disposed on a server, the server having a preset state synchronization mechanism, and the device includes:
[0032] The second caching module is used to receive a set of messages sent by the sending end, cache the set of messages, and determine the receiving end to be received;
[0033] The second synchronization module is used to obtain the first device state of the sending end synchronized by the state synchronization mechanism, and the second device state of the receiving end.
[0034] The second sending module is used to send a new message set to the receiving end according to the second device status; wherein, the new message set includes the message set and historical messages in the buffer whose transmission status is not sent;
[0035] The second update module is used to receive an acknowledgment message based on the new message set and update the transmission status of the new message set in the cache.
[0036] The third update module is used to feed back the confirmation response message to the sending end according to the first device status, so that the sending end updates the transmission status of the message set.
[0037] Sixthly, embodiments of this application also provide an electronic device, including a memory storing multiple instructions; a processor loads instructions from the memory to execute any of the data transmission methods provided in embodiments of this application.
[0038] In a seventh aspect, embodiments of this application also provide a computer-readable storage medium storing a plurality of instructions adapted for loading by a processor to execute any of the data transmission methods provided in embodiments of this application.
[0039] Eighthly, embodiments of this application also provide a computer program product, including a computer program or instructions, which, when executed by a processor, implement any of the data transmission methods provided in embodiments of this application.
[0040] In this embodiment, the sending end responds to a sending request for a message to be sent, caches the message to be sent, and determines the receiving end to receive it. By caching the message to be sent, the message will not be lost if the sending device goes offline or the network is interrupted. The sending end obtains the first device state synchronized by the state synchronization mechanism and the second device state of the receiving end. The sending end sends a message set to the receiving end according to the first device state and the second device state. The message set includes the message to be sent and historical messages in the cache with a transmission status of "not sent". In this way, message sending is based on the message status to avoid message omission. The sending end receives an acknowledgment message based on the message set and updates the transmission status of the message set in the cache, realizing real-time updating of the message status. In this embodiment, through device status management, message sending, receiving, and message transmission status acknowledgment responses are ensured when the device is online. At the same time, messages to be transmitted are cached, and their transmission status is set according to the message sending status to ensure that messages to be sent are retrieved from the cache for priority processing. In the technical solution of this application, during the message transmission process, a device status management mechanism (i.e., a status synchronization mechanism) is established to combine message synchronization with device status, thereby improving the reliability and consistency of message transmission. Attached Figure Description
[0041] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0042] Figure 1 This is one of the flowcharts illustrating the data transmission method provided in the embodiments of this application;
[0043] Figure 2This is a second flowchart illustrating the data transmission method provided in the embodiments of this application;
[0044] Figure 3 This is the third flowchart illustrating the data transmission method provided in the embodiments of this application;
[0045] Figure 4 This is the fourth flowchart illustrating the data transmission method provided in the embodiments of this application;
[0046] Figure 5 This is a schematic diagram of the architecture of the data transmission system provided in the embodiments of this application;
[0047] Figure 6 This is a schematic diagram illustrating an application scenario of the data transmission system provided in the embodiments of this application;
[0048] Figure 7 This is a schematic diagram of a data transmission device provided in an embodiment of this application;
[0049] Figure 8 This is another schematic diagram of the data transmission device provided in the embodiments of this application;
[0050] Figure 9 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0051] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. At the same time, in the description of the embodiments of this application, the terms "first," "second," etc., are only used to distinguish descriptions and should not be construed as indicating or implying relative importance. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly specified.
[0052] This application provides a data transmission method, system, apparatus, electronic device, and computer storage medium. Specifically, this application describes the data transmission apparatus from the perspective of a data transmission device, which can be integrated into an electronic device; that is, the data transmission method of this application can be executed by the electronic device. Optionally, the electronic device includes a terminal device. The terminal device can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, game console, smart interactive whiteboard, or personal computer (PC), etc. Optionally, the electronic device includes a server, which can be an independent server, a server network, or a server cluster, including but not limited to computers, network hosts, single network servers, sets of network servers, or cloud servers composed of servers. The cloud server consists of a large number of computers or network servers based on cloud computing.
[0053] It should be noted that the order of description in the following embodiments is not intended to limit the preferred order of embodiments. Although a logical order is shown in the flowcharts, in some cases, the steps shown or described may be performed in a different order than that shown in the figures.
[0054] In the prior art, when the sending device transmits messages, messages may be lost or fail to be delivered to the receiving end in a timely manner due to various reasons (such as network interruption, equipment failure, etc.), resulting in the inability to guarantee the consistency and integrity of the messages.
[0055] To address the problems in the prior art, this application proposes a data transmission method.
[0056] In this embodiment, the sending end and server are pre-configured with a state synchronization mechanism, a historical message synchronization mechanism, and an online message transmission mechanism. During data transmission, according to these mechanisms...
[0057] (1) State synchronization mechanism: a. Establish a state synchronization mechanism based on the device state link to obtain the latest device state of the client device (the client includes the sender and receiver); b. When the device comes back online, it first uses the state link to determine whether a retransmission operation is required; c. If a retransmission is required, appropriate message synchronization and state recovery are performed according to the historical records of the server and the client to ensure the sequential transmission of historical messages.
[0058] (2) Historical message synchronization mechanism: a. The client and server record and synchronize the transmission status of all messages in real time through the historical message synchronization mechanism, including the received confirmation response messages; b. When the device goes offline due to failure or network reasons, the historical message synchronization mechanism will record the message transmission status before the offline, so as to prepare for subsequent recovery and ensure the sequential transmission of historical messages.
[0059] (3) Online message transmission mechanism: a. When the client is online, a reliable message transmission mechanism (such as acknowledgment response mechanism, retransmission mechanism, etc.) is used to ensure that each message can be reliably delivered to the receiving end; b. After the message is successfully sent, the sending end receives an acknowledgment response message from the receiving end; c. If the receiving end does not send an acknowledgment response message within the predetermined time, the sending end will resend the message until it receives an acknowledgment response message, thus ensuring the effective transmission of the message.
[0060] Reference Figure 1 , Figure 1 This is one of the flowcharts illustrating the data transmission method provided in the embodiments of this application. The data transmission method in the embodiments of this application is used at the sending end. In one embodiment, the data transmission method includes steps 101 to 104:
[0061] Step 101: In response to the sending request for the message to be sent, the message to be sent is cached, and the receiving end to be received is determined.
[0062] In this embodiment, the data transmission method is applied at the sending end, and the sending end executes a message caching mechanism:
[0063] a. During message transmission, the sending device caches the messages to be sent according to the message caching mechanism to ensure that the cached messages are not lost when the sending network is interrupted or the device goes offline.
[0064] b. After the system is back online, cached messages will be processed and sent first to ensure message integrity and consistency.
[0065] That is, the sending end responds to the sending request for the message to be sent by caching the message to be sent. In other words, the sending end caches the message to be sent to local storage so as to perform historical synchronization of messages when the client device goes offline or malfunctions. It can be understood that the client in the embodiments of this application includes either the sending end or the receiving end.
[0066] Step 102: Obtain the first device state synchronized by the state synchronization mechanism, and the second device state of the receiving end sent by the server.
[0067] In this embodiment, a state synchronization mechanism is preset. The state synchronization mechanism is used to determine the state based on the state of the device state link and obtain the latest device state of the client device according to the state synchronization mechanism. When the client device comes back online, it determines whether a retransmission operation is required through the state link of the device. If a retransmission is required, appropriate message synchronization and state recovery are performed again according to the historical records of the server and the client to ensure the sequential transmission of historical messages.
[0068] In one embodiment of this application, the server and client devices pre-agree on a state synchronization mechanism. For example, the server monitors the state of the client devices in real time and performs state synchronization. That is, the server obtains the first device state of the sending device and the second device state of the receiving device, synchronizes the first device state to the receiving end, and synchronizes the second device state to the sending end. As another example, in this embodiment, the server and client pre-agree that the sending end periodically sends the first device state to the server when the network is normal, and the receiving end periodically sends the second device state to the server when the network is normal. If the server does not receive the synchronized first device state from the sending end within the agreed time, the server synchronizes the first device state to the receiving end as offline. Similarly, if the server does not receive the synchronized second device state from the receiving end within the agreed time, the server synchronizes the second device state to the sending end as offline. In this embodiment, the sending device synchronizes its own first device state to the receiving end through the server according to the state synchronization mechanism, and receives the synchronized second device state of the receiving end from the server, so as to send messages based on the first and second device states.
[0069] The sending end obtains the first device state synchronized by the state synchronization mechanism and the second device state of the receiving end. In this embodiment of the application, the first device state and the second device state can be the same or different. For example, case 1: the first device state is online and the second device state is offline; case 2: the first device state is online and the second device state is online; case 3: the first device state is offline and the second device state is offline; case 4: the first device state is offline and the second device state is online.
[0070] In this embodiment, the device status is synchronized through a status synchronization mechanism. The first device status of the sending end is the device status of the sending end itself, which can be obtained in real time by the sending end device according to the status synchronization mechanism. The second device status is the device status of the receiving end, which can be synchronized to the sending end by the server in real time, or it can be synchronized to the sending end by the server in the past. For example, the server and the client agree in advance that when the client device status is updated, the second device status will be automatically synchronized to the server. The sending end synchronizes the second device status through the server.
[0071] Step 103: Based on the first device status and the second device status, send the message set to the receiving end.
[0072] The sending device determines the set of messages to be sent. That is, after the sending device determines that the first device status is online, the sending device obtains the transmission status of historical messages in its own cache. Based on the transmission status of historical messages, the sending device determines the set of messages as historical messages with a transmission status of not sent and the messages to be sent corresponding to the sending requests.
[0073] It is understood that in this embodiment, the message set includes messages to be sent and historical messages in the cache that are in an unsent state. If there are no historical messages in the cache that are in an unsent state, the messages to be sent will be sent directly as part of the message set. It is understood that in this embodiment, the number of messages in the message set can be one or more. The message set can include only messages to be sent, or it can include messages to be sent and historical messages in the cache that are in an unsent state. If the message set includes both messages to be sent associated with the sending request and historical messages in the cache that are in an unsent state, the sending end will send the historical messages in the unsent state first.
[0074] Meanwhile, if there are a large number of historical messages that have not been sent, the sending end can be configured to prioritize sending historical messages that have not been sent. In this case, the message set only includes historical messages. The sending end device will terminate the sending operation after sending all historical messages and messages to be sent associated with the sending request.
[0075] Furthermore, if the number of historical messages in the unsent state is empty, when there are many messages to be sent and network transmission is under pressure, the sending device in this embodiment can divide the messages to be sent into two parts: one part is the message set based on the maximum transmission capacity of the network performance, and the other part is the historical messages that are cached and set to the unsent state. In this embodiment, the message sending mechanism sends messages sequentially according to their order to avoid message confusion.
[0076] The sending device sends a message set to the receiving end based on a first device state and a second device state. Specifically, this includes: if the first device state is offline, then upon detecting an update to the first device state, sending the cached message set to the server, so that the server can send the message set to the receiving end based on the second device state; if both the first device state of the sending end and the second device state of the receiving end are online, then sending the message set to the receiving end via the server.
[0077] (1) If the first device is in an offline state, the transmission status of the message to be sent is set to an unsent state. When the status of the first device is detected to be updated, the message set is sent to the server so that the server can send the message set to the receiving end according to the status of the second device.
[0078] (2) If the first device is online, the message set is sent to the server so that the server can send the message set to the receiving end according to the second device status.
[0079] In this embodiment, the sending device sends a message set based on a first device state and a second device state. Specifically, the sending device determines that the first device state is offline. The sending device detects its own first device state, and when it detects an update to the first device state, it sends the cached message set to the server, so that the server can send the message set to the receiving end when the second device state is online. If both the first device state of the sending end and the second device state of the receiving end are online, the sending end sends the message to be sent to the receiving end. In this embodiment, during message transmission, the message to be sent is cached through a message caching mechanism to ensure that cached messages are not lost in the event of network interruption or device disconnection.
[0080] It is understood that in this embodiment, after the sending end sends the message set to the server, the server sends the message set to the receiving end according to the second device status. Specifically, this includes: when the second device status is online, the server queries the historical messages in its local cache, and uses the historical messages in the local cache with a transmission status of "not sent" and the received message set as a new message set to be sent. The server then sends the new message set to the receiving end. That is, after receiving the message set, the server queries the historical messages in its own cache, and sends the historical messages with a transmission status of "not sent" and the currently received message set together to the receiving end. In this embodiment, after receiving the message set sent by the sending end, the server retrieves the historical messages in the "not sent" status from the cache according to the second device status, and sends the message set and the historical messages in the "not sent" status to the receiving end. This avoids the sending end from sending messages repeatedly and effectively prevents message omissions.
[0081] It is understood that in this embodiment, the sending end receives the second device status of the receiving end synchronized by the server, and the sending end device determines whether to trigger the message retransmission mechanism based on the second device status. That is, in the prior art, since the sending end does not know the device status of the receiving end, after the sending end sends a message, if no acknowledgment message is received, the sending end device will repeatedly send the message, wasting network resources. However, in the technical solution of this application, after the sending end device receives the second device status information of the receiving end based on the status synchronization mechanism, the sending end can know whether the receiving end is online. If the receiving end device is not online, after the sending end sends the message set to the server, the sending end sets each message in the message set to the sent status and does not resend. When the sending end device determines that the second device status of the receiving end is online, the sending end further determines whether an acknowledgment message has been received. After the sending end device determines that an acknowledgment message has been received, the sending end updates the status of each message in the cached message set to the received status. In this embodiment, the message transmission link can be made more detailed, and the situation of the sending end resending messages can be effectively avoided.
[0082] After the sending end sends the message set to the receiving end through the server, the receiving end device sends back an acknowledgment response to the sending end according to the message transmission mechanism, so that the sending end receives the acknowledgment response, the transmission status of the message set in the new cache, and sends a new message.
[0083] Step 104: Receive an acknowledgment message based on the message set, and update the transmission status of the message set in the cache.
[0084] The sending end receives an acknowledgment message based on the message set. The sending end updates the transmission status of each message in the message set in the cache and updates the transmission status of the message set to the received status to avoid duplicate transmission.
[0085] Meanwhile, in this embodiment, the messages in the cache are set with a transmission status. When the cache space is limited, operations such as message deletion can be performed according to the size of the remaining space in the cache. For example, the sending end can delete messages with a sending status of "received" to ensure the space in the cache.
[0086] In this embodiment, the sending end caches the messages to be sent in response to the sending request, ensuring that messages are not lost if the client device (the client includes at least one of the sending and receiving ends) goes offline or the network is interrupted. It acquires the first device state synchronized by the state synchronization mechanism and the second device state of the receiving end. Based on the first and second device states, it sets the messages to be sent, along with historical messages in the cache with an unsent transmission state, into a message set to be sent to the receiving end, and receives an acknowledgment message based on the message set, updating the transmission state of the message set in the cache. This embodiment ensures message sending, receiving, and message transmission state acknowledgment responses when the device is online through device state management. Simultaneously, it caches messages to be transmitted and sets their transmission states according to the message sending status, ensuring that messages to be sent from the cache are prioritized for processing. In this technical solution, during message transmission, a device state management mechanism is established, combining message synchronization and device state to improve the reliability and consistency of message transmission.
[0087] In one embodiment of this application, after the sending device sends a message set to the receiving device according to the first device state and the second device state, the method further includes:
[0088] (1) If no confirmation response message based on the message set is received within the preset time period, the status of the second device is updated through the status synchronization mechanism;
[0089] (2) If the second device is in an online state, the message retransmission mechanism is triggered to send the message set a second time;
[0090] (3) If the second device is in an offline state, the message retransmission mechanism will not be triggered.
[0091] In this embodiment, after the sending end sends the message set, it checks a preset time period to determine whether it has received an acknowledgment message based on the message set. The preset time period can be set according to specific scenarios, for example, 1 minute. If no acknowledgment message based on the message set is received within the preset time period, the sending end updates the status of the second device through a status synchronization mechanism. If the sending end device determines that the updated second device status is online, it triggers the message retransmission mechanism to resend the message set to ensure the transmission of the message set. If the second device status is offline, the sending end does not trigger the message retransmission mechanism to avoid multiple retransmissions.
[0092] In this embodiment of the application, if the sending device does not receive an acknowledgment message, the sending end updates the state of the second device through a state synchronization mechanism. The sending end device determines whether to resend the message based on the state of the second device. This ensures the effective transmission of the message and avoids wasting network resources by sending duplicate messages.
[0093] Reference Figure 2 , Figure 2 This is a second flowchart illustrating the data transmission method provided in this application embodiment. After the sending end receives the acknowledgment message based on the message set in this application embodiment, the sending end device is further configured to perform the following steps:
[0094] Step 201: Based on the message identifier in the confirmation response message, determine whether the cache contains a new message to be sent after the message identifier; wherein, the message identifier is set when its corresponding message to be sent is cached, and the message identifier is used to characterize the transmission order of the messages to be sent.
[0095] The sending end receives the acknowledgment message and extracts the message identifier from it. The message identifier is the identification information that identifies the message. The message identifier is set when the corresponding message to be sent is buffered. The message identifier is used to characterize the transmission order of the message to be sent. For example, the message identifier can be a message number, message name, time, etc. In this embodiment, the message is identified based on the message identifier to determine the message received by the receiving end. In this way, the acknowledgment message does not need to carry the received message, but only the message identifier, which can reduce the amount of data transmitted during message synchronization.
[0096] The sending end queries the local cache to determine if the message identifier exists in the local cache. After that, it adds a new message identifier. The sending end sets the message corresponding to the newly added message identifier as a new message to be sent to ensure the sequential transmission of messages and guarantee message consistency.
[0097] If the new message to be sent does not exist in the sender's local storage, the sender monitors it in real time and sends the message when it is received.
[0098] Step 202: If there are new messages to be sent, determine the number of messages in the new messages to be sent.
[0099] The new message to be sent is cached in the local storage of the sending end. The sending end obtains the number of messages to be sent and compares the number of messages with a preset number threshold. The preset number threshold is determined according to the status of the sending end or network performance and other scenarios. For example, the preset number threshold can be 10 messages. If the number of messages does not exceed the preset number threshold, the sending end sends the new message to be sent to the receiving end.
[0100] Step 203: If the number of messages exceeds a preset threshold, a new message set is formed by selecting target messages from the new messages to be sent according to the sliding window mechanism, and the step of sending the message set to the receiving end according to the first device state and the second device state is executed.
[0101] If the number of messages exceeds a preset threshold, the sending device controls the sliding window to move according to a sliding window mechanism, extracting a set of messages to be sent from the new set of messages to be sent. In this embodiment, the sending end sets a sliding window mechanism to control the amount of message transmission. The sliding window mechanism presets the window size, selects a target number of messages to be sent from the cache corresponding to the window size through the sliding window to form a new message set, and triggers a sending request for the new message set. The size of the sliding window is determined according to the network conditions of the sending end for data transmission, and the step of sending the message set to the receiving end according to the first device state and the second device state is executed. For example, if the cache contains 30 messages to be sent, depending on the network speed, sending 10 messages at a time can ensure the message transmission rate without causing information blockage. Therefore, the window size of the sliding window is set to 10, and the sliding window takes messages 1-10 as a batch of messages to be sent. After sending, the sliding window moves to messages 11-20, and so on.
[0102] In this embodiment, a sliding window can be set at the sending end to extract a portion of the messages to be sent as a message set to be sent, and then send the message set to achieve batch message sending and improve message transmission efficiency.
[0103] refer to Figure 3 , Figure 3 This is the third flowchart illustrating the data transmission method provided in this application embodiment. The specific flow of the data transmission method provided in this application embodiment can be summarized in steps 301 to 305, including:
[0104] Step 301: Receive the message set sent by the sending end, cache the message set, and determine the receiving end to be received.
[0105] In this embodiment, the data transmission method is applied to a server. The server performs message and status management. In this implementation, the server and client communicate with each other. The number of clients is not limited. The server can communicate with one or more clients. For example, the server is an instant messaging software server, and the user terminal of the instant messaging software is the client. The server corresponds to multiple clients using instant messaging software. The client includes a sender and a receiver. The sender and receiver can be switched in different scenarios.
[0106] State management refers to the server synchronizing the first device state of the sending device to the receiving device and the second device state of the receiving device to the sending device according to the state synchronization mechanism. In the embodiments of this application, the server performs device state management, which can facilitate the sending end to send messages. For example, the sending device determines whether to retransmit the message based on the second device state, or the receiving device determines whether to send acknowledgment information based on the first device state.
[0107] Specifically, the data transmission method in this application embodiment includes:
[0108] a. The server is responsible for managing and recording the transmission status and history of messages, as well as managing the device status of the sending and receiving ends in the client.
[0109] b. After the server receives the message confirmation response from the client, it will update the message status.
[0110] c. When the receiving end in the client comes back online, the server will assist the sending end in performing message recovery and synchronization operations based on the messages it has recorded.
[0111] In this embodiment of the application, the sending end sends a message set to the server, and the server receives the message set. The number and type of messages in the message set are not limited. For example, the message set may include historical messages that have not been sent in the sending end's cache, as well as messages to be sent associated with the sending end when it triggers a sending request.
[0112] After receiving the message set, the server caches the message set. The server caches the message set to its own local storage or the corresponding cloud storage to manage the messages in the message set. That is, the server stores message transmission records and historical messages so that when the client device goes offline or malfunctions, the message history can be synchronized to ensure that the message transmission process can be restored based on the historical message records when the device comes back online.
[0113] The server determines the receiving end based on the device identifier associated with the message set, and manages the message and device status according to the second device status of the receiving end.
[0114] Step 302: Obtain the first device state of the sending end and the second device state of the receiving end synchronized by the state synchronization mechanism.
[0115] In this embodiment, the server synchronizes the first device state of the sending device to the receiving device, and synchronizes the second device state of the receiving device to the sending device. The synchronization method for the first and second device states is not specifically limited.
[0116] Implementation Method 1: The server determines the status of the first device based on the sending time associated with the message set. For example, if the sending time is less than the current time interval threshold, the first device status is determined to be online. If the sending time is greater than or equal to the current time interval threshold, the server sends a status synchronization request to the sending end to obtain the first device status fed back by the sending end. The server then sends a status synchronization request to the receiving end to obtain the second device status fed back by the receiving end.
[0117] Method 2: The server and client agree in advance to trigger status update requests periodically and send updated device status to the server. That is, the sending end periodically sends its first device status to the server, and / or the receiving end periodically sends its second device status to the server.
[0118] In this embodiment, the server manages the device status of the client to manage the status of each device and its historical records, ensuring that when the device comes back online, the status can be accurately determined and restored to the latest business status.
[0119] Step 303: Based on the second device status, send the new message set to the receiving end.
[0120] In this embodiment of the application, the server sends a new message set to the receiving end according to the state of the second device. The new message set includes the message set sent by the sending end and the historical messages in the server's own cache that are in the transmission state of "not sent". It can be understood that if there are no historical messages in the server's own cache that are in the transmission state of "not sent", then the new message set is the same as the message set sent by the sending end.
[0121] After the server determines that the second device is online, it retrieves the transmission status of each cached historical message in its own cache. The server then sends the set of messages sent by the sender, along with the historical messages in its own cache that are in an unsent state and the set of messages determined to be new. Specifically, this includes:
[0122] (1) If the second device is in an offline state, the transmission status of the messages in the message set is set to an unsent state so as to manage the messages according to the transmission status;
[0123] (2) If the second device is in an online state, the control sends the new message set to the receiving end.
[0124] That is, if the server determines that the second device is offline, it sets the transmission status of the messages in the message set to unsent. At the same time, the server monitors the status of the second device in real time and uses the message set and the historical messages with the transmission status of unsent as a new message set. The server sends the new message set to the online receiving end. If the server determines that the second device is online, the server sends the new message set to the receiving end.
[0125] In this embodiment, the server sends a new message set based on the status of the second device at the receiving end. In this way, when the server sends a message, it can detect the transmission status of historical messages in the cache and send the historical messages that have not been sent along with the message set transmitted by the sending end to the receiving end, thus avoiding message omission.
[0126] Meanwhile, in this embodiment of the application, if there are many historical messages that have not been sent, the server determines the number of historical messages and sends them first to avoid message confusion and effectively ensure the consistency of message transmission.
[0127] In this embodiment of the application, after the server sends the message set to the receiving end, the server updates the transmission status of the cached message set from the unsent state to the sent state, so as to further manage messages according to the transmission status of the messages in the cache.
[0128] Step 304: Receive an acknowledgment message based on the new message set, and update the transmission status of the new message set in the cache.
[0129] The server receives an acknowledgment message based on the new message set, updates the transmission status of the new message set in the cache, and updates the transmission status of each message in the new message set from the sent status to the received status.
[0130] Furthermore, in this embodiment of the application, the server can set a message invalidation mechanism. When the server detects that a historical message in the cache is in a received state, the server can also delete the invalid historical message to reduce the storage space occupied by the cache.
[0131] Step 305: Send the confirmation response message to the sending end according to the first device status, so that the sending end updates the transmission status of the message set.
[0132] In one embodiment of this application, the server sends the confirmation response message to the sending end based on the first device status, including:
[0133] (1) If the first device is in an online state, the confirmation response message is sent to the sending end so that the sending end updates the transmission status of the message set;
[0134] (2) If the first device is offline, the confirmation response message is sent to the sending end when the status of the first device is updated.
[0135] After receiving the acknowledgment message, the server determines the first device status of the sending end according to the device status synchronization mechanism. If the first device status is online, the server sends the acknowledgment message to the sending end so that the sending end updates the transmission status of the message set from the sent status to the received status. If the first device status is offline, the server sends the acknowledgment message to the sending end when it detects an update to the first device status so that the sending end can perform message management.
[0136] In this embodiment, the server sends the confirmation response message to the sending end based on the first device status. In this way, the client device performs message sending, receiving, and message transmission status confirmation response while online. At the same time, the confirmation response mechanism ensures that each message can be reliably delivered to the receiving end.
[0137] In this embodiment, the server receives a set of messages sent by the sender. The server caches the message set to ensure that messages are not lost if the client device (the client includes at least one of the sender and receiver) goes offline or the network is interrupted. The server synchronizes the first device state of the sender and the second device state of the receiver. Based on the second device state, the server sends a new set of messages to the receiver. The server receives an acknowledgment message based on the new set of messages and sends the acknowledgment message to the sender based on the first device state. In this embodiment, the server manages the client device state to ensure that message sending, receiving, and message transmission status acknowledgment responses are performed when the device is online. The server also updates the cached message set to ensure that historical messages in unsent states are retrieved from the cache for priority processing. In this technical solution, a device state management mechanism is established during message transmission, combining message synchronization and device state to improve the reliability and consistency of message transmission.
[0138] Reference Figure 4 , Figure 4 This is a flowchart illustrating the data transmission method provided in this application embodiment four. In an optional embodiment, after the server sets the transmission status of the message to be sent, steps 401 to 403 are further included:
[0139] Step 401: When the status update of the second device is detected, a retransmission mechanism is triggered based on the new message set to transmit the new message set to the receiving end.
[0140] In this embodiment, after the server determines that the second device is offline, the server monitors the status of the second device in real time. When the server detects an update in the status of the second device, it triggers a retransmission mechanism to transmit the new message set to the receiving end based on the transmission status of the new message set. In this embodiment, the server ensures that each message can be reliably delivered to the receiving end based on the message retransmission mechanism.
[0141] Step 402: Receive an acknowledgment message based on the new message set, and update the transmission status of the new message set.
[0142] The server receives an acknowledgment message based on the new message set and updates the transmission status of the new message set to the received status, so that the server can delete historical messages in the received status when the cache space is insufficient.
[0143] Step 403: If no acknowledgment message is received within a preset time period, a message retransmission mechanism is triggered for the new message set in the cache until an acknowledgment message based on the new message set is received.
[0144] The server has a preset time period, which is set according to the specific scenario. For example, the preset time period is 120 seconds. If no acknowledgment message is received within the preset time period, a message retransmission mechanism is triggered for the new message set in the cache until an acknowledgment message based on the message set is received.
[0145] In this embodiment of the application, after the server determines that the second device is offline, the server monitors the update of the second device's status and performs operations to ensure the consistency of the device status within the same time period. The server then sends and processes messages based on the device status to ensure that the device can accurately determine its status and restore it to the latest business status when it comes back online.
[0146] The data transmission system provided in the embodiments of this application is described below. The data transmission system described below can be referred to in correspondence with the data transmission method described above.
[0147] The data transmission system described in this embodiment includes a sending end and a server, wherein...
[0148] The sending end is used to respond to a sending request for a message to be sent, to buffer the message to be sent, and to determine the receiving end to receive it.
[0149] The sending end is used to obtain the first device state synchronized by the state synchronization mechanism and the second device state of the receiving end; wherein, the second device state is used to indicate whether the message retransmission mechanism is triggered.
[0150] The sending end is configured to send a message set to the server according to the state of the first device; wherein the message set includes the message to be sent, and historical messages in the cache whose transmission status is not sent;
[0151] The server is configured to receive the message set, cache the message set, and determine the receiving end to receive the message;
[0152] The server is used to obtain the first device state of the sending end and the second device state of the receiving end synchronized by the state synchronization mechanism.
[0153] The server is configured to send a new message set to the receiving end based on the state of the second device; wherein the new message set includes the message set and historical messages in the cache whose transmission status is not sent;
[0154] The server is configured to receive an acknowledgment message based on the new message set, update the transmission status of the new message set in the cache, and send the acknowledgment message to the sending end according to the first device status.
[0155] The sending end is used to update the transmission status of the message set based on the acknowledgment response message.
[0156] That is, the data transmission system in this application embodiment includes a sender and a server. The sender and the server determine the first device state and the second device state according to the state synchronization mechanism. Based on the first device state and the second device state, they will check the historical messages that they have already cached and give priority to the historical messages that have not been sent. In this way, when the first device state and the second device state are different, the server and the sender device will transmit data according to their own data transmission logic, which reduces the situation of message duplication and effectively ensures the reliability and consistency of messages.
[0157] In this embodiment, the server receives a set of messages sent by the sender. The server caches the message set to ensure that messages are not lost if the client device (the client includes at least one of the sender and receiver) goes offline or the network is interrupted. The server synchronizes the first device status of the sender and the second device status of the receiver of the messages to be sent. Based on the second device status, the server assembles a new message set, including the message set and historical messages in its own cache that are in an unsent state, and sends it to the receiver. The server receives an acknowledgment message based on the new message set and sends the acknowledgment message to the sender based on the first device status. In this embodiment, by managing the client device status, message sending, receiving, and message transmission status acknowledgment responses are ensured when the device is online. The cached messages to be sent are also updated to ensure that messages to be sent are retrieved from the cache and processed with priority. In the message transmission process, this technical solution establishes a device status management mechanism, combining message synchronization and device status, to improve the reliability and consistency of message transmission.
[0158] Reference Figure 5 , Figure 5 This is a schematic diagram of the architecture of the data transmission system provided in the embodiments of this application. The data transmission system in the embodiments of this application is applied to, for example... Figure 5 The data transmission architecture shown comprises three main layers: a device layer, a communication layer, and a storage layer. These layers work together to achieve reliable message transmission between devices. The specific architecture details are as follows:
[0159] The device layer is the front end of message transmission. Corresponding to the sending end, the device layer includes the following main modules:
[0160] (1) Cache management module: a) It is responsible for caching messages in the pending state at the sending end. This mechanism ensures that messages are not lost even if the device goes offline or the network is interrupted; b) When the device comes back online, it retrieves the messages to be sent from the cache and processes them with priority.
[0161] (2) Reliable message communication mechanism module: a. Responsible for sending and receiving messages and confirming message transmission status when the device is online; b. Utilize the confirmation response mechanism and message retransmission mechanism to ensure that each message can be reliably delivered to the receiving end.
[0162] (3) Status synchronization mechanism module: a) It is responsible for synchronizing the status messages of the device to ensure the consistency of the status in different devices or in different time periods of the same device; b) When the device comes back online, it helps the device restore its historical status.
[0163] The communication layer is an intermediate layer that enables communication between the client and the server, and it includes the following main modules:
[0164] (1) Message communication module: a. Responsible for message transmission between devices and servers, including sending and receiving messages; b. Provides reliable message communication channels to ensure smooth message flow between the device layer and the service layer.
[0165] (2) Status notification module: a) It is responsible for notifying the server of the current status of the device and status changes, so that the server can manage the device status; b) It updates the device status messages in real time and assists in status judgment and message recovery operations.
[0166] The storage layer is responsible for the persistent storage of messages and states. It is hosted on the server and includes the following main modules:
[0167] (1) Message storage module: a) It is responsible for storing the transmission records and historical messages of the device, so as to perform historical synchronization of messages when the device is offline or malfunctions; b) It ensures that the message transmission process can be restored according to the historical message records when the device is back online.
[0168] (2) Status Management Module: a. Responsible for managing and maintaining various status messages and their historical records of the device; b. Ensure that the device can accurately determine its status and restore it to the latest business status when it comes back online.
[0169] In this embodiment, the client and server are equipped with a state synchronization mechanism, a historical message synchronization mechanism, an online message transmission mechanism, a message caching mechanism, and server message and state management.
[0170] (1) The state synchronization mechanism is handled by a component in the state access layer, which is responsible for the access and state synchronization of multiple clients. This stage mainly completes the following steps:
[0171] a. When the device is first connected, it will connect to the status access layer and obtain the latest device status, and perform initialization logic based on the device status;
[0172] b. When the latest device status is online, the device will connect to the message access layer;
[0173] c. Continuously subscribe to changes in the dialogue status in the link to ensure that multiple devices have the ability to sense each other's device status.
[0174] d. Maintain the link and re-establish it if the heartbeat is abnormal or the connection is lost.
[0175] (2) The historical message synchronization mechanism refers to the process by which a client device connects with the message access layer and enters a synchronization state when it needs to enter message communication, waiting for historical messages to be synchronized.
[0176] a. The sending device sends the latest message cursor from its local receive message queue to the message access layer. The message access layer then extracts the content following the message cursor based on the user's information and sends the message to the receiving end.
[0177] b. After the receiving end consumes the historical messages locally, it will notify the server to complete the synchronization operation. At this time, both ends enter full-duplex communication state.
[0178] (3) Online message transmission mechanism refers to the fact that online message transmission can only be carried out after historical message synchronization is completed. Reliable message delivery adds synchronization-related attributes to the messages, and the communicating parties cooperate and reach a message consensus based on these messages.
[0179] Furthermore, in this embodiment, the message format is defined using JSON. To meet the requirements of message reliability, the following four basic fields are defined, among which...
[0180] seq: represents the sequence number of the current message;
[0181] ack: Indicates the latest message sequence number received by the receiving device. This acknowledgment number can be passed in other messages, reducing the number of interactions.
[0182] command: Indicates the message type. Command number 2000 represents the action of sending a message, and 2001 represents the action of responding to the sender.
[0183] msgIdx: Represents the cursor corresponding to the message, a unique identifier that distinguishes the message;
[0184] The following is a format for sending a message:
[0185] {
[0186] "seq":0, / / ID of the message sent by the current sender
[0187] "ack":0, / / You can send an ack response to the other end separately, or you can send an ack response when the server sends a 2000 response.
[0188] "command":"2000",
[0189] "msgIdx":"1111111"
[0190] }
[0191] The reliable message acknowledgment mechanism in this embodiment borrows the sliding window and timeout retransmission design principles of the Transmission Control Protocol (TCP). After a message is sent, the window moves only after the peer application layer confirms the message. Figure 6 , Figure 6 This is a schematic diagram illustrating an application scenario of the data transmission system provided in the embodiments of this application;
[0192] (4) Message caching mechanism refers to the encapsulation of data access, which exists between the communication layer and the business layer, including interface module, storage module, eviction module and asynchronous communication module.
[0193] The specific process is as follows: The business layer initiates a data read request through the interface module. The storage module first determines whether the data exists. If the data does not exist, it further obtains the data from the server through the communication module and stores it, while setting a certain expiration time. If the data exists, the eviction module will determine whether the data is still valid. If it is valid, it returns the data; otherwise, it deletes the data and asynchronously obtains the data from the server.
[0194] (5) Server message and status management.
[0195] Once the message is in full-duplex communication, both the receiving end and the server will strictly follow the rules for reliable message delivery in sending and receiving messages. If a message fails to receive a response, the corresponding message retransmission mechanism will be triggered.
[0196] Once a message is confirmed, it will be logged and recorded, and then asynchronously consumed by the message service via a message queue.
[0197] This application embodiment performs multi-device status synchronization; instead of using a fixed interval retry method, it combines message sending and device status to avoid the risk of rate limiting due to a large number of retry requests at fixed intervals; this application embodiment achieves reliable message delivery, based on a message confirmation mechanism, ensuring that messages are not lost, duplicated, or out of order.
[0198] The data transmission apparatus provided in the embodiments of this application is described below. The data transmission apparatus described below and the data transmission method described above can be referred to in correspondence.
[0199] Reference Figure 7 As shown, Figure 7 This is a schematic diagram of a data transmission device provided in an embodiment of this application. The data transmission device, when applied to a transmitting end, may include:
[0200] The first caching module 501 is used to respond to a sending request for a message to be sent, cache the message to be sent, and determine the receiving end to receive it.
[0201] The first synchronization module 502 is used to obtain the first device status synchronized by the status synchronization mechanism and the second device status of the receiving end; wherein, the second device status is used to indicate whether the message retransmission mechanism is triggered.
[0202] The first sending module 503 is configured to send a message set to the receiving end according to the first device state and the second device state; wherein, the message set includes the message to be sent, and historical messages in the buffer whose transmission status is not sent;
[0203] The first update module 504 is used to receive an acknowledgment message based on the message set and update the transmission status of the message set in the cache.
[0204] This application embodiment caches messages to be sent, ensuring that historical messages in an unsent state are retrieved from the cache for priority processing. In the message transmission process, this application's technical solution establishes a device state management mechanism to combine message synchronization and device state, thereby improving the reliability and consistency of message transmission.
[0205] In an optional example, the first transmitting module 503 is also used for:
[0206] If the first device is offline, the transmission status of the message to be sent is set to unsent. When the status of the first device is updated, the message set is sent to the server, so that the server can send the message set to the receiving end according to the status of the second device.
[0207] If the first device is online, the message set is sent to the server, so that the server can send the message set to the receiving end according to the second device status.
[0208] In an optional example, the data transmission device further includes:
[0209] If no acknowledgment message based on the message set is received within the preset time period, the status of the second device is updated through the status synchronization mechanism.
[0210] If the second device is in an online state, the message retransmission mechanism is triggered to resend the message set;
[0211] If the second device is in an offline state, the message retransmission mechanism will not be triggered.
[0212] In an optional example, the data transmission device further includes:
[0213] Based on the message identifier in the confirmation response message, it is determined whether the cache contains a new message to be sent after the message identifier; the message identifier is set when its corresponding message to be sent is cached, and the message identifier is used to characterize the transmission order of the messages to be sent;
[0214] If there are new messages to be sent, then determine the number of messages in the new messages to be sent;
[0215] If the number of messages exceeds a preset threshold, a new message set is formed by selecting target messages from the new messages to be sent according to the sliding window mechanism, and the step of sending the message set to the receiving end according to the first device state and the second device state is executed; the sliding window mechanism is used to control the message transmission volume, and the window size is preset in the sliding window mechanism, and the target number of messages to be sent corresponding to the window size is selected from the cache through the sliding window.
[0216] In this embodiment, the sending end responds to a sending request for a message to be sent, caches the message to be sent, and determines the receiving end to receive it. Because the message to be sent is cached in this embodiment, the message will not be lost if the sending device goes offline or the network is interrupted. The sending end obtains the first device state synchronized by the state synchronization mechanism and the second device state of the receiving end. Based on the first and second device states, the sending end sends a message set to the receiving end. The message set includes the message to be sent and historical messages in the cache with an unsent transmission status. This message sending based on message status avoids message omissions. The sending end receives an acknowledgment message based on the message set and updates the transmission status of the message set in the cache, achieving real-time updating of the message status. In this embodiment, device status management ensures that message sending, receiving, and message transmission status acknowledgment responses are performed when the device is online. Simultaneously, messages to be transmitted are cached, and their transmission status is set according to the message sending status, ensuring that messages to be sent are retrieved from the cache for priority processing. In this technical solution, during message transmission, a device status management mechanism is established, combining message synchronization and device status to improve the reliability and consistency of message transmission.
[0217] Reference Figure 8 As shown, Figure 8 This is another schematic diagram of the data transmission device provided in this application embodiment. The data transmission device is disposed on a server, and the server has a preset state synchronization mechanism. The device includes:
[0218] The second caching module 601 is used to receive a set of messages sent by the sending end, cache the set of messages, and determine the receiving end to be received.
[0219] The second synchronization module 602 is used to obtain the first device status of the sending end synchronized by the state synchronization mechanism, and the second device status of the receiving end.
[0220] The second sending module 603 is used to send a new message set to the receiving end according to the second device status; wherein, the new message set includes the message set and historical messages in the buffer whose transmission status is not sent;
[0221] The second update module 604 is used to receive an acknowledgment message based on the message set and update the transmission status of the new message set in the cache.
[0222] The third update module 605 is used to feed back the confirmation response message to the sending end according to the first device status, so that the sending end updates the transmission status of the message set.
[0223] In an optional example, the second transmitting module 603 is also used for:
[0224] If the second device is in an offline state, then the transmission status of the messages in the message set is set to an unsent state;
[0225] If the second device is online, the new message set is sent to the receiving end.
[0226] In an optional example, the data transmission device is further configured to:
[0227] When the status update of the second device is detected, a message retransmission mechanism is triggered based on the new message set to transmit the new message set to the receiving end;
[0228] Receive an acknowledgment message based on the new message set, and update the transmission status of the new message set;
[0229] If no acknowledgment message is received within a preset time period, a message retransmission mechanism is triggered for the new message set in the cache until an acknowledgment message based on the new message set is received.
[0230] In an optional example, the third update module 605 is also used for:
[0231] If the first device is in an online state, the confirmation response message is sent to the sending end so that the sending end updates the transmission status of the message set;
[0232] If the first device is in an offline state, then when an update to the first device's state is detected, the confirmation response message is sent to the sending end so that the sending end updates the transmission status of the message set.
[0233] In this embodiment, the server caches the set of messages sent by the sender to ensure that messages to be sent are retrieved from the cache and processed first. In the technical solution of this application, during the message transmission process, a device status management mechanism is established to combine message synchronization and device status, thereby improving the reliability and consistency of message transmission.
[0234] The specific embodiments of the data transmission device and the data transmission method provided in this application are basically the same, and will not be described in detail here.
[0235] Optional, such as Figure 9 As shown, Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may include: a processor 701, a communication interface 702, a memory 703, and a communication bus 704, wherein the processor 701, the communication interface 702, and the memory 703 communicate with each other via the communication bus 704. The processor 701 can call a computer program in the memory 703 to execute steps of a data transmission method, such as:
[0236] In response to a send request for a message to be sent, the message to be sent is cached, and the receiving end to be received is determined.
[0237] The first device state synchronized by the state synchronization mechanism and the second device state of the receiving end sent by the server are obtained, wherein the second device state is used to indicate whether the message retransmission mechanism is triggered.
[0238] Based on the first device status and the second device status, a message set is sent to the receiving end; wherein, the message set includes the message to be sent, and historical messages in the cache whose transmission status is not sent;
[0239] Receive an acknowledgment message based on the message set, and update the transmission status of the message set in the cache.
[0240] Furthermore, the logical instructions in the aforementioned memory 703 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0241] On the other hand, embodiments of this application also provide a non-transitory computer-readable storage medium, the non-transitory computer-readable storage medium including a computer program, the computer program being stored on the non-transitory computer-readable storage medium, and when the computer program is executed by a processor, the computer is able to perform the steps of the data transmission method provided in the above embodiments, including:
[0242] In response to a send request for a message to be sent, the message to be sent is cached, and the receiving end to be received is determined.
[0243] The first device state synchronized by the state synchronization mechanism and the second device state of the receiving end sent by the server are obtained, wherein the second device state is used to indicate whether the message retransmission mechanism is triggered.
[0244] Based on the first device status and the second device status, a message set is sent to the receiving end; wherein, the message set includes the message to be sent, and historical messages in the cache whose transmission status is not sent;
[0245] Receive an acknowledgment message based on the message set, and update the transmission status of the message set in the cache.
[0246] In another aspect, embodiments of this application also provide a computer product, which includes a computer program. The computer program can be stored on the computer product, and when the computer program is executed by a processor, the computer can perform the steps of the data transmission method provided in the above embodiments, including:
[0247] In response to a send request for a message to be sent, the message to be sent is cached, and the receiving end to be received is determined.
[0248] The first device state synchronized by the state synchronization mechanism and the second device state of the receiving end sent by the server are obtained, wherein the second device state is used to indicate whether the message retransmission mechanism is triggered.
[0249] Based on the first device status and the second device status, a message set is sent to the receiving end; wherein, the message set includes the message to be sent, and historical messages in the cache whose transmission status is not sent;
[0250] Receive an acknowledgment message based on the message set, and update the transmission status of the message set in the cache.
[0251] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0252] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0253] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A data transmission method, characterized in that, The data transmission method is applied at the sending end, which has a preset state synchronization mechanism. The method includes: In response to a send request for a message to be sent, the message to be sent is cached, and the receiving end to be received is determined. The first device state synchronized by the state synchronization mechanism and the second device state of the receiving end sent by the server are obtained, wherein the second device state is used to indicate whether the message retransmission mechanism is triggered. Based on the first device status and the second device status, a message set is sent to the receiving end; wherein, the message set includes the message to be sent, and historical messages in the cache whose transmission status is not sent; Receive an acknowledgment message based on the message set, and update the transmission status of the message set in the cache.
2. The data transmission method according to claim 1, characterized in that, The step of sending the message set to the receiving end according to the first device state and the second device state includes: If the first device is offline, the transmission status of the message to be sent is set to unsent. When the status of the first device is updated, the message set is sent to the server, so that the server can send the message set to the receiving end according to the status of the second device. If the first device is online, the message set is sent to the server, so that the server can send the message set to the receiving end according to the second device status.
3. The data transmission method according to claim 1, characterized in that, After sending the message set to the receiving end based on the first device state and the second device state, the method further includes: If no acknowledgment message based on the message set is received within the preset time period, the status of the second device is updated through the status synchronization mechanism. If the second device is in an online state, the message retransmission mechanism is triggered to resend the message set; If the second device is in an offline state, the message retransmission mechanism will not be triggered.
4. The data transmission method according to any one of claims 1-3, characterized in that, After receiving the acknowledgment message based on the message set, the method further includes: Based on the message identifier in the confirmation response message, it is determined whether the cache contains a new message to be sent after the message identifier; the message identifier is set when its corresponding message to be sent is cached, and the message identifier is used to characterize the transmission order of the messages to be sent; If there are new messages to be sent, then determine the number of messages in the new messages to be sent; If the number of messages exceeds a preset threshold, a new message set is formed by selecting target messages from the new messages to be sent according to the sliding window mechanism, and the step of sending the message set to the receiving end according to the first device state and the second device state is executed; the sliding window mechanism is used to control the message transmission volume, and the window size is preset in the sliding window mechanism, and the target number of messages to be sent corresponding to the window size is selected from the cache through the sliding window.
5. A data transmission method, characterized in that, The data transmission method is applied to a server, which has a preset state synchronization mechanism. The method includes: Receive a set of messages sent by the sender, cache the set of messages, and determine the receiving end to receive them; Obtain the first device state of the sending end and the second device state of the receiving end synchronized by the state synchronization mechanism; Based on the second device status, a new message set is sent to the receiving end; wherein, the new message set includes the message set and historical messages in the cache whose transmission status is not sent; Receive an acknowledgment message based on the new message set, and update the transmission status of the new message set in the cache; The acknowledgment message is fed back to the sending end based on the first device status, so that the sending end updates the transmission status of the message set.
6. The data transmission method according to claim 5, characterized in that, The step of sending a new set of messages to the receiving end based on the second device status includes: If the second device is in an offline state, then the transmission status of the messages in the message set is set to an unsent state; If the second device is online, the new message set is sent to the receiving end.
7. The data transmission method according to claim 6, characterized in that, After setting the transmission status of messages in the message set to an unsent state, the method further includes: When the status update of the second device is detected, a message retransmission mechanism is triggered based on the new message set to transmit the new message set to the receiving end; Receive an acknowledgment message based on the new message set, and update the transmission status of the new message set; If no acknowledgment message is received within a preset time period, a message retransmission mechanism is triggered for the new message set in the cache until an acknowledgment message based on the new message set is received.
8. The data transmission method according to any one of claims 5-7, characterized in that, The step of feeding back the acknowledgment message to the sending end based on the first device status, so that the sending end updates the transmission status of the message set, includes: If the first device is in an online state, the confirmation response message is sent to the sending end so that the sending end updates the transmission status of the message set; If the first device is in an offline state, then when an update to the first device's state is detected, the confirmation response message is sent to the sending end so that the sending end updates the transmission status of the message set.
9. A data transmission system, characterized in that, The data transmission system includes a transmitter and a server, both of which are equipped with a pre-set state synchronization mechanism. The sending end is used to respond to a sending request for a message to be sent, to buffer the message to be sent, and to determine the receiving end to receive it. The sending end is used to obtain the first device state synchronized by the state synchronization mechanism and the second device state of the receiving end; wherein, the second device state is used to indicate whether the message retransmission mechanism is triggered. The sending end is configured to send a message set to the server according to the state of the first device; wherein the message set includes the message to be sent, and historical messages in the cache whose transmission status is not sent; The server is configured to receive the message set, cache the message set, and determine the receiving end to receive the message; The server is used to obtain the first device state of the sending end and the second device state of the receiving end synchronized by the state synchronization mechanism. The server is configured to send a new message set to the receiving end based on the state of the second device; wherein the new message set includes the message set and historical messages in the cache whose transmission status is not sent; The server is configured to receive an acknowledgment message based on the new message set, update the transmission status of the new message set in the cache, and send the acknowledgment message to the sending end according to the first device status. The sending end is used to update the transmission status of the message set based on the acknowledgment response message.
10. The data transmission system according to claim 9, characterized in that, The data transmission system further includes a receiving end, which is used for: The response status synchronization mechanism synchronizes the status of its second device to the server. The server receives the new message set, generates the confirmation response message, and sends the confirmation response message to the sending end via the server.
11. The data transmission system according to claim 9 or 10, characterized in that, A communication layer is provided between the server and the sending end; The communication layer is used for message transmission and / or device status transmission between the sending end and the server.
12. A data transmission device, characterized in that, The data transmission device is located at the transmitting end, and the transmitting end has a preset state synchronization mechanism. The device includes: The first caching module is used to respond to a sending request for a message to be sent, cache the message to be sent, and determine the receiving end to receive it. The first synchronization module is used to obtain the first device state synchronized by the state synchronization mechanism and the second device state of the receiving end sent by the server, wherein the second device state is used to indicate whether the message retransmission mechanism is triggered. The first sending module is configured to send a message set to the receiving end according to the first device state and the second device state; wherein, the message set includes the message to be sent, and historical messages in the buffer whose transmission status is not sent; The first update module is used to receive an acknowledgment response message based on the message set and update the transmission status of the message set in the cache.
13. A data transmission device, characterized in that, The data transmission device is installed on the server, and the server has a preset state synchronization mechanism. The device includes: The second caching module is used to receive a set of messages sent by the sending end, cache the set of messages, and determine the receiving end to be received; The second synchronization module is used to obtain the first device state of the sending end synchronized by the state synchronization mechanism, and the second device state of the receiving end. The second sending module is used to send a new message set to the receiving end according to the second device status; wherein, the new message set includes the message set and historical messages in the buffer whose transmission status is not sent; The second update module is used to receive an acknowledgment message based on the new message set and update the transmission status of the new message set in the cache. The third update module is used to feed back the confirmation response message to the sending end according to the first device status, so that the sending end updates the transmission status of the message set.
14. An electronic device, characterized in that, The device includes a processor and a memory, the memory storing multiple instructions; the processor loads instructions from the memory to execute the data transfer method as described in any one of claims 1 to 8.
15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a plurality of instructions adapted for loading by a processor to perform the data transmission method as described in any one of claims 1 to 8.