Real-time data transmission method, device, electronic equipment and system
Through the WebSocket connection mechanism, the server load and memory leakage problems caused by HTTP short polling are solved, multi-terminal real-time data synchronization and stable transmission are achieved, and the system operation stability and data consistency are improved.
Patent Information
- Application Number
- CN202510710274.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-28
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2045-05-28
AI Technical Summary
In the existing technology, the frequent HTTP short polling mechanism leads to increased backend server load and memory leaks, which can easily cause the server response speed to decrease or crash, and cannot meet the efficiency and stability requirements of real-time data transmission.
Using the WebSocket connection mechanism, the back-end desktop component receives the subscription list heartbeat information of the front-end desktop component, determines the subscription status, and pushes the target data to the subscribed front-end component, realizing real-time data push between multiple terminals and reducing unnecessary data transmission frequency and network resource consumption.
It improves the efficiency and stability of real-time data transmission, reduces the possibility of system crashes, maintains multi-terminal data consistency, and optimizes network resource utilization and system performance.
Smart Images

Figure CN120602465A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data transmission technology, and in particular to a real-time data transmission method, device, electronic equipment and system. Background Art
[0002] At present, more and more system business scenarios (such as real-time chat, real-time message push, real-time monitoring, etc.) require real-time data transmission technology to achieve data synchronization between the client and the server.
[0003] In the prior art, to meet the real-time data update requirements in various business scenarios, an HTTP (Hypertext Transfer Protocol) short polling mechanism is usually adopted. Specifically, the front-end periodically sends a request to the back-end to inquire whether there is new data. After receiving and processing the request, the back-end returns the latest data to the front-end, so that the front-end updates the page content based on the latest data received. The above process is then repeated based on the time interval set by the timer. However, frequent polling requests significantly increase the load on the back-end server, especially when there are a large number of users, which can easily cause the server response speed to decrease or even crash. In addition, due to the continuous polling operation, each polling creates a new execution context, which causes the program's memory usage to increase rapidly, resulting in memory leaks and easily causing the program to crash.
[0004] Therefore, it is particularly important to propose a technical solution that can improve the efficiency and stability of real-time data transmission to improve the stability of system operation. Summary of the Invention
[0005] The present invention provides a real-time data transmission method, device, electronic equipment and system, which can improve the efficiency and stability of real-time data transmission, thereby facilitating the improvement of system operation stability.
[0006] In order to solve the above technical problems, the first aspect of the present invention discloses a real-time data transmission method, which is applied to an electronic device, wherein an application is installed in the electronic device, the electronic device is communicatively connected to a network attached storage device, and the electronic device can access the network attached storage device through the application. The application includes a backend desktop component, a backend application component associated with the backend desktop component, at least one frontend desktop component, and a frontend application component corresponding to each frontend desktop component. The method comprises:
[0007] After the backend desktop component establishes a WebSocket connection with at least one of the frontend desktop components, the backend desktop component receives a first heartbeat message sent by any of the frontend desktop components, and determines the frontend desktop component that sent the first heartbeat message as the associated frontend desktop component; the first heartbeat message carries a subscription list; the subscription list is used to register a data push service for at least one data topic;
[0008] The backend desktop component receives target data sent by the backend application component; the target data includes the latest data with data changes in the backend application component and / or data update information for the latest data;
[0009] The backend desktop component determines the subscription status corresponding to each of the associated frontend desktop components according to all the subscription lists; the subscription status includes a subscribed state or an unsubscribed state;
[0010] The back-end desktop component determines the associated front-end desktop component whose subscription status is the subscribed status as the target front-end desktop component, and pushes the target data to each target front-end desktop component, so that each target front-end desktop component pushes the target data to the target front-end application component corresponding to the target front-end desktop component.
[0011] As an optional implementation, in the first aspect of the present invention, the application further includes at least one suite of network disk tools, synchronization and backup, and task manager.
[0012] As an optional implementation, in the first aspect of the present invention, after the backend desktop component determines the subscription status corresponding to each of the associated frontend desktop components based on all the subscription lists, the method further includes:
[0013] The back-end desktop component determines the associated front-end desktop component whose subscription state is the unsubscribed state as a disconnected front-end desktop component, and the back-end desktop component does not push the target data to any of the disconnected front-end desktop components;
[0014] The backend desktop component generates a stop push message and sends the stop push message to the backend application component; the stop push message is used to instruct the backend application component to stop providing the data push service to any of the disconnected front-end desktop components.
[0015] As an optional implementation, in the first aspect of the present invention, the backend desktop component determines the subscription status corresponding to each associated frontend desktop component based on all the subscription lists, including:
[0016] The back-end desktop component counts the disconnection duration of each associated front-end desktop component; the disconnection duration is the duration during which the back-end desktop component does not receive the heartbeat information sent by the associated front-end desktop component;
[0017] The back-end desktop component determines whether the disconnection duration of each of the associated front-end desktop components is less than or equal to a preset duration threshold;
[0018] When it is determined that the disconnection duration of any of the associated front-end desktop components is less than or equal to the preset duration threshold, the back-end desktop component determines the subscription state corresponding to the associated front-end desktop component as the subscribed state;
[0019] When it is determined that the disconnection duration of any of the associated front-end desktop components is greater than the preset duration threshold, the back-end desktop component determines the subscription state corresponding to the associated front-end desktop component as the unsubscribed state.
[0020] As an optional implementation manner, in the first aspect of the present invention, after the back-end desktop component receives the first heartbeat information sent by any of the front-end desktop components, the method further includes:
[0021] For each of the associated front-end desktop components, the back-end desktop component returns subscription confirmation information about the subscription list to the associated front-end desktop component, so that the associated front-end desktop component sends the subscription confirmation information to the first front-end application component corresponding to the associated front-end desktop component; the subscription confirmation information is used to instruct the first front-end application component to send subscription notification information about the subscription list to the back-end application component.
[0022] As an optional embodiment, in the first aspect of the present invention, the method further comprises:
[0023] After the back-end desktop component receives the second heartbeat information sent by any of the associated front-end desktop components, the back-end desktop component clears the subscription request that matches the second heartbeat information; the second heartbeat information carries subscription cancellation information; the subscription cancellation information is used to cancel the data push service of the associated front-end desktop component for at least one of the data topics;
[0024] For each deregistered front-end desktop component, the back-end desktop component returns deregistration confirmation information about the subscription deregistration information to the deregistered front-end desktop component, so that the deregistered front-end desktop component sends the deregistration confirmation information to the second front-end application component corresponding to the deregistered front-end desktop component; wherein, the deregistered front-end desktop component is the front-end desktop component that sends the second heartbeat information to the back-end desktop component; the deregistration confirmation information is used to instruct the second front-end application component to send deregistration notification information about the subscription deregistration information to the back-end application component.
[0025] As an optional implementation manner, in the first aspect of the present invention, the target data includes a plurality of data packets;
[0026] Wherein, in the process where the backend desktop component pushes the target data to each of the target frontend desktop components so that each of the target frontend desktop components pushes the target data to the target frontend application component corresponding to the target frontend desktop component, the method further includes:
[0027] When the backend desktop component detects that any of the target frontend desktop components performs an exception handling operation on the backend desktop component, the backend desktop component responds to the exception handling operation;
[0028] Wherein, the exception handling operation is determined by the following method;
[0029] Each of the target front-end desktop components determines, based on the received data packets, whether there is a packet loss anomaly between the back-end desktop component and the target front-end desktop component;
[0030] When it is determined that the packet loss exception exists between the back-end desktop component and the target front-end desktop component, the target front-end desktop component determines the exception handling operation corresponding to the packet loss exception and performs the exception handling operation on the back-end desktop component; the exception handling operation includes a connection reconstruction operation and / or a subscription retransmission operation.
[0031] A second aspect of the present invention discloses a real-time data transmission device, the device being applied to an electronic device having an application installed therein, the electronic device being communicatively connected to a network attached storage device, and the electronic device being able to access the network attached storage device through the application. The device includes a backend desktop component, and the backend desktop component belongs to the application. The application further includes a backend application component associated with the backend desktop component, at least one frontend desktop component, and a frontend application component corresponding to each of the frontend desktop components. The backend desktop component includes:
[0032] A receiving module, configured to receive a first heartbeat message sent by any of the front-end desktop components after the back-end desktop component establishes a WebSocket connection with at least one of the front-end desktop components; the first heartbeat message carries a subscription list; the subscription list is used to register a data push service for at least one data topic;
[0033] A determination module, configured to determine the front-end desktop component that sends the first heartbeat information as an associated front-end desktop component;
[0034] The receiving module is further configured to receive target data sent by the back-end application component; the target data includes the latest data with data changes in the back-end application component and / or data update information for the latest data;
[0035] The determining module is further configured to determine, based on all the subscription lists, a subscription status corresponding to each of the associated front-end desktop components; the subscription status includes a subscribed state or an unsubscribed state;
[0036] A push module is used to determine the associated front-end desktop component whose subscription status is the subscribed status as the target front-end desktop component, and push the target data to each of the target front-end desktop components, so that each of the target front-end desktop components pushes the target data to the target front-end application component corresponding to the target front-end desktop component.
[0037] As an optional implementation, in the second aspect of the present invention, the application further includes at least one suite of network disk tools, synchronization and backup, and task manager.
[0038] As an optional implementation, in the second aspect of the present invention, the determination module is further configured to, after the determination module determines the subscription status corresponding to each of the associated front-end desktop components based on all the subscription lists, determine the associated front-end desktop component whose subscription status is the unsubscribed state as a disconnected front-end desktop component, and not push the target data to any of the disconnected front-end desktop components;
[0039] And, the backend desktop component also includes:
[0040] A generation module, used to generate stop push information;
[0041] The sending module is used to send the stop push information to the back-end application component; the stop push information is used to instruct the back-end application component to stop providing the data push service to any of the disconnected front-end desktop components.
[0042] As an optional implementation, in the second aspect of the present invention, the specific manner in which the determination module determines the subscription status corresponding to each associated front-end desktop component based on all the subscription lists includes:
[0043] Counting the disconnection duration of each associated front-end desktop component; the disconnection duration is the duration during which the back-end desktop component does not receive the heartbeat information sent by the associated front-end desktop component;
[0044] Determine whether the disconnection duration of each of the associated front-end desktop components is less than or equal to a preset duration threshold;
[0045] When it is determined that the disconnection duration of any of the associated front-end desktop components is less than or equal to the preset duration threshold, determining the subscription state corresponding to the associated front-end desktop component as the subscribed state;
[0046] When it is determined that the disconnection duration of any of the associated front-end desktop components is greater than the preset duration threshold, the subscription state corresponding to the associated front-end desktop component is determined to be the unsubscribed state.
[0047] As an optional implementation, in the second aspect of the present invention, the backend desktop component further includes:
[0048] An information feedback module is used to return subscription confirmation information about the subscription list to each associated front-end desktop component after the receiving module receives the first heartbeat information sent by any of the front-end desktop components, so that the associated front-end desktop component sends the subscription confirmation information to the first front-end application component corresponding to the associated front-end desktop component; the subscription confirmation information is used to instruct the first front-end application component to send subscription notification information about the subscription list to the back-end application component.
[0049] As an optional implementation, in the second aspect of the present invention, the backend desktop component further includes:
[0050] A clearing module, configured to clear a subscription request that matches a second heartbeat message sent by any of the associated front-end desktop components after the receiving module receives the second heartbeat message; the second heartbeat message carries subscription cancellation information; the subscription cancellation information is used to cancel the data push service of the associated front-end desktop component for at least one of the data topics;
[0051] The information feedback module is also used to return deregistration confirmation information about the subscription deregistration information to each deregistered front-end desktop component, so that the deregistered front-end desktop component sends the deregistration confirmation information to the second front-end application component corresponding to the deregistered front-end desktop component; wherein the deregistered front-end desktop component is the front-end desktop component that sends the second heartbeat information to the back-end desktop component; the deregistration confirmation information is used to instruct the second front-end application component to send deregistration notification information about the subscription deregistration information to the back-end application component.
[0052] As an optional implementation, in the second aspect of the present invention, the target data includes a plurality of data packets;
[0053] The backend desktop component further includes:
[0054] An exception handling module is configured to respond to an exception handling operation when it is detected that any of the target front-end desktop components performs an exception handling operation on the back-end desktop component during the process in which the push module pushes the target data to each of the target front-end desktop components so that each of the target front-end desktop components pushes the target data to the target front-end application component corresponding to the target front-end desktop component;
[0055] Wherein, the exception handling operation is determined by the following method;
[0056] Each of the target front-end desktop components determines, based on the received data packets, whether there is a packet loss anomaly between the back-end desktop component and the target front-end desktop component;
[0057] When it is determined that the packet loss exception exists between the back-end desktop component and the target front-end desktop component, the target front-end desktop component determines the exception handling operation corresponding to the packet loss exception and performs the exception handling operation on the back-end desktop component; the exception handling operation includes a connection reconstruction operation and / or a subscription retransmission operation.
[0058] A third aspect of the present invention discloses an electronic device, comprising:
[0059] a memory storing executable program code;
[0060] a processor coupled to the memory;
[0061] The processor calls the executable program code stored in the memory to execute part or all of the steps of the real-time data transmission method disclosed in the first aspect of the present invention.
[0062] A fourth aspect of the present invention discloses a real-time data transmission system, the system comprising at least the real-time data transmission apparatus disclosed in the second aspect of the present invention, and a network attached storage device communicatively connected to the real-time data transmission apparatus, wherein service data is stored on the network attached storage device. When the network attached storage device functions as a backend application component and pushes target data in the service data to the real-time data transmission apparatus, the real-time data transmission apparatus performs a data transmission operation on the target data according to the real-time data transmission method disclosed in the first aspect of the present invention.
[0063] or,
[0064] The system includes at least the electronic device disclosed in the third aspect of the present invention, and a network-attached storage device communicatively connected to the electronic device, and business data is stored on the network-attached storage device. When the network-attached storage device serves as a back-end application component and pushes target data in the business data to the electronic device, the electronic device performs a data transmission operation for the target data according to the real-time data transmission method disclosed in the first aspect of the present invention.
[0065] The fifth aspect of the present invention discloses a computer storage medium, which stores computer instructions. When the computer instructions are called, they are used to execute some or all steps of the real-time data transmission method disclosed in the first aspect of the present invention.
[0066] Compared with the prior art, the present invention has the following beneficial effects:
[0067] The implementation of the present invention can be applied to electronic devices installed with an application, and the application includes a back-end desktop component, a back-end application component, a front-end desktop component and a front-end application component. The method can establish a WebSocket connection between the back-end desktop component and at least one front-end desktop component. The back-end desktop component can receive the first heartbeat information carrying the subscription list sent by the front-end desktop component to register the relevant data push service. When the back-end desktop component receives the target data pushed by the back-end application component, the subscription status of each front-end desktop component is determined according to the subscription list, and the front-end desktop component in the subscribed state is determined as the target front-end desktop component to push the target data to the target front-end desktop component. Real-time data push between multiple terminals can be achieved by establishing a WebSocket connection, thereby improving the transmission efficiency and transmission stability of real-time data and reducing the data transmission errors. The possibility of increasing memory usage and causing the system to crash due to data transmission is reduced, which is conducive to improving the system's operating stability, and is conducive to achieving real-time data synchronization between multiple terminals, and thus is conducive to maintaining data consistency between multiple terminals; and, transmitting real-time data through a WebSocket connection can reduce the size of the data packet, thereby reducing the network resources required for real-time data transmission, which is conducive to improving network resource utilization; and, when the data has not changed, the back-end does not need to transmit data to the front-end, which is conducive to reducing the frequency of data transmission between the front-end and the back-end, thereby helping to reduce the back-end server load and reduce unnecessary network resource consumption, and is conducive to improving system operating performance and stability; and, improving the accuracy of determining the target front-end desktop component that needs to push target data, thereby helping to improve the accuracy and efficiency of pushing target data, and thus helping to further improve the accuracy and efficiency of real-time data transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0069] Figure 1 This is a flow chart of a real-time data transmission method disclosed in an embodiment of the present invention;
[0070] Figure 2 This is a flow chart of another real-time data transmission method disclosed in an embodiment of the present invention;
[0071] Figure 3 This is a flow chart of another real-time data transmission method disclosed in an embodiment of the present invention;
[0072] Figure 4 This is a structural diagram of a real-time data transmission device disclosed in an embodiment of the present invention;
[0073] Figure 5 It is a structural diagram of another real-time data transmission device disclosed in an embodiment of the present invention;
[0074] Figure 6 This is a schematic structural diagram of an electronic device disclosed in an embodiment of the present invention;
[0075] Figure 7 It is a structural diagram of a real-time data transmission system disclosed in an embodiment of the present invention;
[0076] Figure 8 It is a structural diagram of another real-time data transmission system disclosed in an embodiment of the present invention. DETAILED DESCRIPTION
[0077] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0078] The terms "first," "second," and so on, in the description and claims of the present invention and the accompanying drawings are used to distinguish between different items, not to describe a specific order. Furthermore, the terms "including," "having," and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product, or end comprising a series of steps or elements is not limited to the listed steps or elements but may optionally include steps or elements not listed therein, or may optionally include other steps or elements inherent to such process, method, product, or end.
[0079] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present invention. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute a separate or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0080] The present invention discloses a real-time data transmission method, device, electronic device and system. The method is applied to an electronic device installed with an application, and the application includes a back-end desktop component, a back-end application component, a front-end desktop component and a front-end application component. The method can, after the back-end desktop component establishes a WebSocket connection with at least one front-end desktop component, the back-end desktop component can receive a first heartbeat message carrying a subscription list sent by the front-end desktop component to register for a related data push service. Then, when the back-end desktop component receives the target data pushed by the back-end application component, the subscription status of each front-end desktop component is determined according to the subscription list, and the front-end desktop component in the subscribed state is determined as the target front-end desktop component to push the target data to the target front-end desktop component. The method can realize real-time data push between multiple terminals by establishing a WebSocket connection, thereby improving the transmission efficiency and Transmission stability reduces the possibility of system crashes caused by the continuous increase in memory occupied by data transmission, thereby improving the system's operating stability, and is conducive to achieving real-time data synchronization between multiple terminals, and thus is conducive to maintaining data consistency between multiple terminals; and, transmitting real-time data through a WebSocket connection can reduce the size of the data packet, thereby reducing the network resources required for real-time data transmission, which is conducive to improving network resource utilization; and, when the data has not changed, the back-end does not need to transmit data to the front-end, which is conducive to reducing the frequency of data transmission between the front-end and the back-end, thereby helping to reduce the back-end server load and reduce unnecessary network resource consumption, which is conducive to improving system operating performance and stability; and, improving the accuracy of determining the target front-end desktop component that needs to push the target data, thereby helping to improve the accuracy and efficiency of pushing the target data, and thus helping to further improve the accuracy and efficiency of real-time data transmission.
[0081] Example 1
[0082] See also Figure 1 , Figure 1 This is a flow chart of a real-time data transmission method disclosed in an embodiment of the present invention. Figure 1 The described real-time data transmission method can be applied to a real-time data transmission device, which may include a real-time data transmission terminal, a real-time data transmission device, and a server, wherein the server may be a local server or a local server, which is not limited in the embodiment of the present invention; the method can also be applied to an electronic device, which has an application installed in it, and the electronic device is in communication connection with a network attached storage device, and the electronic device can access the network attached storage device through the application, wherein the application may include a back-end desktop component, a back-end application component associated with the back-end desktop component, at least one front-end desktop component, and a front-end application component corresponding to each front-end desktop component, which is not limited in the embodiment of the present invention. Figure 1 As shown, the real-time data transmission method may include the following operations:
[0083] 101. After a backend desktop component establishes a WebSocket connection with at least one frontend desktop component, the backend desktop component receives a first heartbeat message sent by any frontend desktop component, and determines the frontend desktop component that sends the first heartbeat message as an associated frontend desktop component.
[0084] In an embodiment of the present invention, optionally, the above-mentioned WebSocket connection can be a WebSocket long connection, which is not limited in the embodiment of the present invention; further, there is a heartbeat mechanism between the back-end desktop component and the associated front-end desktop component, and the associated front-end desktop component needs to send heartbeat information (such as: heartbeat packet) to the back-end desktop component at a preset time interval, wherein the first heartbeat information and the second heartbeat information in the embodiment of the present invention both belong to the heartbeat information corresponding to the above-mentioned heartbeat mechanism.
[0085] In the embodiment of the present invention, the first heartbeat information carries a subscription list; wherein the subscription list is used to register a data push service for at least one data topic.
[0086] 102. The backend desktop component receives target data sent by the backend application component.
[0087] In an embodiment of the present invention, the target data may include the latest data with data changes in the back-end application component and / or data update information for the latest data; wherein, optionally, the above-mentioned target data may be the latest data in the database corresponding to the back-end application component after at least one of the data addition operation, data modification operation and data deletion operation, which is not limited in the embodiment of the present invention; further optionally, if any front-end application component performs at least one of the above-mentioned data operations on a certain data, the front-end application component may notify the back-end application component via an HTTP request so that the back-end application component performs the same data operation on the above-mentioned data in the above-mentioned database, thereby obtaining the latest data, which is not limited in the embodiment of the present invention; wherein, optionally, the data update information may be used to instruct the target front-end desktop component determined subsequently to perform the above-mentioned data operation on the original data corresponding to the latest data, thereby obtaining the latest data, which is not limited in the embodiment of the present invention.
[0088] In the embodiment of the present invention, for example, it is assumed that the same account is logged in on four devices A, B, C, and D respectively. If the user deletes a task in the front-end application component of device A, the operation will notify the corresponding back-end application component through an HTTP request, and then the back-end application component will delete the data in the database. The change in data will trigger the data push mechanism of the back-end application component, and this data update information will be pushed to the back-end desktop component, and then forwarded by the back-end desktop component to all devices that use the account to log in (i.e., devices B, C, and D). Therefore, the front-end desktop components on devices B, C, and D will receive this deletion notification. After receiving the notification, the front-end application component will identify and delete the corresponding task. Similarly, other types of data operations (such as adding or modifying tasks) will also be processed according to a similar process to ensure that the data on all devices remains consistent and synchronized, which is not limited in the embodiment of the present invention.
[0089] 103. The backend desktop component determines the subscription status corresponding to each associated frontend desktop component according to all subscription lists.
[0090] In the embodiment of the present invention, the subscription status corresponding to each associated front-end desktop component may include a subscribed state or an unsubscribed state.
[0091] 104. The backend desktop component determines the associated frontend desktop component with the subscription status as subscribed as the target frontend desktop component, and pushes target data to each target frontend desktop component, so that each target frontend desktop component pushes the target data to the target frontend application component corresponding to the target frontend desktop component.
[0092] In the embodiment of the present invention, the backend desktop component pushes target data to at least one target frontend desktop component according to all subscription lists through a WebSocket connection.
[0093] In the embodiment of the present invention, optionally, after the target front-end desktop component pushes the target data to the corresponding target front-end application component, the method may further include the following operations:
[0094] The target front-end application component performs data parsing operations on the target data to obtain data parsing results;
[0095] The target front-end application component executes the business logic corresponding to the data analysis result based on the data analysis result; and / or, based on the data analysis result, renders the client corresponding to the target front-end application component, which is not limited in this embodiment of the present invention.
[0096] In an embodiment of the present invention, optionally, the data parsing result may include the type of data received by parsing the subscribed data subject, which is not limited by the embodiment of the present invention. For example, two application scenarios of download task management and network connection information synchronization are taken as examples: in the application scenario of download task management, if the received data is identified as a list of user download tasks through the subscription key value (that is, the above-mentioned data subject that needs to be subscribed), the front-end application component will update the status, progress, file size and real-time speed of the relevant download tasks, so as to ensure that the user can view the latest progress of the download task in real time; in the application scenario of network disk connection information synchronization, when the received data is confirmed to be the user's network disk connection information through the subscription key value, the front-end application component will synchronously update the relevant attributes of the network disk, including authorization status, name, capacity and membership level information, which ensures that the user can obtain the latest account details and service status when using the network disk service, which is not limited by the embodiment of the present invention.
[0097] In the embodiment of the present invention, for example, the specific description of each component included in the communication system can be as follows:
[0098] 1. Front-end desktop component: As the client's transit layer, it is responsible for establishing a persistent WebSocket connection with the back-end desktop component, managing the heartbeat mechanism, subscribing / unsubscribing to message channels, and pushing received real-time data to the front-end application component;
[0099] The functions of the front-end desktop components are as follows: (1) Communication agent: uniformly handles the establishment, maintenance (heartbeat), and reconnection of WebSocket connections; (2) Message distribution: distributes the real-time data pushed by the back-end to the corresponding front-end application components according to the business type; (3) State management: maintains the connection status to ensure that the front-end application components do not need to pay attention to the underlying communication details.
[0100] 2. Front-end application components: specific business function modules (such as network disk tools, music players, etc.), focusing on user interaction and business logic processing;
[0101] The functions of the front-end application components are as follows: (1) User interaction: providing a UI interface and responding to user operations (such as uploading and downloading files); (2) Business logic: processing local data (such as caching and status updates) and relying on the front-end desktop components to obtain real-time server-side data; (3) Subscription communication: subscribing to specific message channels (such as "file upload progress") through the front-end desktop components to receive real-time updates.
[0102] 3. Backend desktop component: server-side communication middleware, encapsulating WebSocket protocol, connection pool management, message routing and other infrastructure;
[0103] The functions of the back-end desktop components are as follows: (1) Connection management: Maintaining WebSocket connections with multiple front-end desktop components, handling authentication, current limiting, and load balancing; (2) Message routing: Forwarding requests to the corresponding back-end application components according to business type (such as music request → music service); (3) Unified protocol: Providing standardized interfaces (such as heartbeat response, error code) to simplify the development of back-end application components.
[0104] 4. Back-end application components: independent business services (such as network disk storage services and music metadata services), handling specific business logic and data persistence;
[0105] The functions of back-end application components are as follows: (1) Business processing: executing core logic (such as file sharding storage and audio transcoding); (2) Data interaction: receiving requests through back-end desktop components, returning processing results or pushing asynchronous events; (3) Decoupling dependencies: independent deployment, interacting with back-end desktop components through standardized interfaces, and avoiding direct dependence on front-end protocols.
[0106] Optionally, the backend application component may adopt a network attached storage device, or may adopt other types of backend application components, which is not limited in the embodiment of the present invention.
[0107] Furthermore, illustratively, the role positioning and key technical responsibilities of each component in the communication system may be as shown in Table 1, which is not limited in the embodiment of the present invention.
[0108] Components Role Positioning Key technical responsibilities Front-end desktop components Communications Hub WebSocket connection management and message distribution Front-end application components Business Terminal Build user interface, user interaction, and business logic Backend desktop components Service Gateway Protocol encapsulation, routing distribution, connection pool management Backend application components Business Engine Data processing, algorithm execution, and persistent storage
[0109] Table 1
[0110] It can be seen that the method described in the embodiment of the present invention can be applied to electronic devices installed with an application, and the application includes a back-end desktop component, a back-end application component, a front-end desktop component and a front-end application component. The method can establish a WebSocket connection between the back-end desktop component and at least one front-end desktop component. The back-end desktop component can receive the first heartbeat information carrying the subscription list sent by the front-end desktop component to register for the relevant data push service. When the back-end desktop component receives the target data pushed by the back-end application component, the subscription status of each front-end desktop component is determined according to the subscription list. The front-end desktop component in the subscribed state is then determined as the target front-end desktop component to push the target data to the target front-end desktop component. Real-time data push between multiple terminals can be achieved by establishing a WebSocket connection, thereby improving the transmission efficiency and stability of real-time data. Reducing the possibility of system crashes caused by the continuous increase in memory usage due to data transmission is beneficial to improving the system's operating stability, and is beneficial to achieving real-time data synchronization between multiple terminals, and thus is beneficial to maintaining data consistency between multiple terminals; and transmitting real-time data through a WebSocket connection can reduce the size of the data packet, thereby reducing the network resources required for real-time data transmission, which is beneficial to improving network resource utilization; and when the data has not changed, the back-end does not need to transmit data to the front-end, which is beneficial to reducing the frequency of data transmission between the front-end and the back-end, thereby helping to reduce the back-end server load and reduce unnecessary network resource consumption, and is beneficial to improving system operating performance and stability; and, improving the accuracy of determining the target front-end desktop component that needs to push target data, thereby helping to improve the accuracy and efficiency of pushing target data, and thus helping to further improve the accuracy and efficiency of real-time data transmission.
[0111] In an optional embodiment, after the back-end desktop component receives the first heartbeat information sent by any front-end desktop component, the method may further include the following operations:
[0112] For each associated front-end desktop component, the back-end desktop component returns subscription confirmation information about the subscription list to the associated front-end desktop component, so that the associated front-end desktop component sends the subscription confirmation information to the first front-end application component corresponding to the associated front-end desktop component; the subscription confirmation information is used to instruct the first front-end application component to send subscription notification information about the subscription list to the back-end application component.
[0113] The subscription notification information is used to notify the back-end application component that the first front-end application component has registered for the data push service for the above data topic.
[0114] It can be seen that this optional embodiment can, after the back-end desktop component receives the first heartbeat information, the back-end desktop component returns the corresponding subscription confirmation information to the associated front-end desktop component that sent the first heartbeat information, so that the associated front-end desktop component synchronizes the subscription confirmation information to the corresponding front-end application component to instruct the front-end application component to notify the back-end application component that it has subscribed to the data push service, which can improve the information synchronization efficiency and accuracy of the relevant information of the registration subscription between multiple terminals, thereby facilitating the accurate and efficient pushing of data to the subscribed front-end desktop components and front-end application components in the subsequent data push process, and further helps to improve the efficiency and accuracy of real-time data transmission.
[0115] In this optional embodiment, the method may further include the following operations:
[0116] After the back-end desktop component receives the second heartbeat information sent by any associated front-end desktop component, the back-end desktop component clears the subscription request that matches the second heartbeat information; the second heartbeat information carries subscription cancellation information; the subscription cancellation information is used to cancel the data push service of the associated front-end desktop component for at least one data topic;
[0117] For each deregistered front-end desktop component, the back-end desktop component returns deregistration confirmation information about the subscription deregistration information to the deregistered front-end desktop component, so that the deregistered front-end desktop component sends the deregistration confirmation information to the second front-end application component corresponding to the deregistered front-end desktop component; wherein, the deregistered front-end desktop component is the front-end desktop component that sends the second heartbeat information to the back-end desktop component; the deregistration confirmation information is used to instruct the second front-end application component to send deregistration notification information about the subscription deregistration information to the back-end application component.
[0118] The deregistration notification information is used to notify the back-end application component that the second front-end application component has deregistered / cancelled the data push service for the above-mentioned data subject.
[0119] It can be seen that this optional embodiment can also enable the back-end desktop component to clear the relevant subscription request after receiving the second heartbeat message carrying the subscription cancellation information, and return the corresponding cancellation confirmation information to the cancellation front-end desktop component that sent the second heartbeat message, so that the cancellation front-end desktop component synchronizes the cancellation confirmation information to the corresponding front-end application component to instruct the front-end application component to notify the back-end application component that the data push service has been canceled, which can improve the information synchronization efficiency and accuracy of the relevant information of the cancellation subscription between multiple terminals, thereby helping to reduce the possibility of the back-end pushing data to the front-end that has canceled the subscription to the data push service in the subsequent data push process, and further help to further improve the efficiency and accuracy of real-time data transmission.
[0120] In this optional embodiment, optionally, the first heartbeat information may be sent to the backend desktop component in the following manner:
[0121] Any front-end application component sends a subscription list to the front-end desktop component corresponding to the front-end application component; the subscription list includes a subscription request of the front-end application component for at least one data topic;
[0122] The front-end desktop component generates first heartbeat information based on the subscription list and sends the first heartbeat information to the back-end desktop component.
[0123] Optionally, the second heartbeat information can be sent to the backend desktop component in the following ways:
[0124] Any first front-end application component sends subscription cancellation information to the associated front-end desktop component corresponding to the first front-end application component; the subscription cancellation information includes a subscription cancellation request of the first front-end application component for at least one data topic;
[0125] The associated front-end desktop component generates second heartbeat information based on the subscription cancellation information, and sends the second heartbeat information to the back-end desktop component.
[0126] It can be seen that this optional embodiment can also enable the front-end application component to send subscription list / subscription cancellation information to the front-end desktop component, and then the front-end desktop component can generate corresponding heartbeat information based on the subscription list / subscription cancellation information, and send the heartbeat information to the back-end desktop component. Transmitting heartbeat information through the front-end desktop component can enable the front-end application component to not need to pay attention to the underlying communication details, so that the front-end application component can focus on user interaction and business logic processing, thereby improving the system operation efficiency and operation stability; and, transmitting subscription list / subscription cancellation information through heartbeat information can improve the transmission efficiency of information related to subscription registration / cancellation operations, which is conducive to improving the efficiency of real-time data transmission.
[0127] In another optional embodiment, the target data may include multiple data packets;
[0128] Optionally, in the process of the backend desktop component pushing target data to each target frontend desktop component so that each target frontend desktop component pushes the target data to the target frontend application component corresponding to the target frontend desktop component, the method may further include the following operations:
[0129] When the backend desktop component detects that any target frontend desktop component performs an exception handling operation on the backend desktop component, the backend desktop component responds to the exception handling operation.
[0130] Optionally, the exception handling action can be determined by:
[0131] Each target front-end desktop component determines whether there is a packet loss anomaly between the back-end desktop component and the target front-end desktop component based on the received data packet;
[0132] When it is determined that there is a packet loss exception between the back-end desktop component and the target front-end desktop component, the target front-end desktop component determines the exception handling operation corresponding to the packet loss exception and performs the exception handling operation on the back-end desktop component; the exception handling operation includes a connection reconstruction operation and / or a subscription retransmission operation.
[0133] Among them, the connection reconstruction operation can be used to re-establish the WebSocket connection between the target front-end desktop component and the back-end desktop component; the subscription retransmission operation can be used to re-transmit the subscription list corresponding to the target front-end desktop component to the back-end desktop component to re-subscribe to the relevant data push service.
[0134] Optionally, the cause of abnormal packet loss may be abnormal network connection (such as network interruption) or loss of heartbeat information, or other reasons, which are not limited in the embodiment of the present invention.
[0135] It can be seen that this optional embodiment can enable the front-end desktop component to actively trigger and execute corresponding exception handling operations when a data transmission exception occurs between the back-end desktop component and the front-end desktop component, which can improve the timeliness of capturing data transmission exceptions, thereby helping to improve the timeliness and efficiency of exception handling, and further helping to reduce data loss or resources required for data retransmission due to data transmission exceptions, and further helping to further improve the stability and reliability of real-time data transmission.
[0136] Example 2
[0137] See also Figure 2 , Figure 2 This is a flow chart of a real-time data transmission method disclosed in an embodiment of the present invention. Figure 2 The described real-time data transmission method can be applied to a real-time data transmission device, which may include a real-time data transmission terminal, a real-time data transmission device, and a server, wherein the server may be a local server or a local server, which is not limited in the embodiment of the present invention; the method can also be applied to an electronic device, which has an application installed in it, and the electronic device is in communication connection with a network attached storage device, and the electronic device can access the network attached storage device through the application, wherein the application may include a back-end desktop component, a back-end application component associated with the back-end desktop component, at least one front-end desktop component, and a front-end application component corresponding to each front-end desktop component, which is not limited in the embodiment of the present invention. Figure 2 As shown, the real-time data transmission method may include the following operations:
[0138] 201. After a backend desktop component establishes a WebSocket connection with at least one frontend desktop component, the backend desktop component receives a first heartbeat message sent by any frontend desktop component, and determines the frontend desktop component that sends the first heartbeat message as an associated frontend desktop component.
[0139] In the embodiment of the present invention, the first heartbeat information carries a subscription list; the subscription list is used to register a data push service for at least one data topic.
[0140] 202. The backend desktop component receives target data sent by the backend application component.
[0141] In the embodiment of the present invention, the target data includes the latest data with data changes in the backend application component and / or data update information for the latest data.
[0142] 203. The backend desktop component determines the subscription status corresponding to each associated frontend desktop component according to all subscription lists.
[0143] In the embodiment of the present invention, the subscription status corresponding to each associated front-end desktop component may include a subscribed state or an unsubscribed state.
[0144] 204. The backend desktop component determines the associated frontend desktop component whose subscription state is unsubscribed as a disconnected frontend desktop component, and the backend desktop component does not push target data to any disconnected frontend desktop component.
[0145] 205. The backend desktop component generates a stop push message and sends the stop push message to the backend application component.
[0146] In the embodiment of the present invention, the stop push information is used to instruct the backend application component to stop providing data push service to any disconnected front-end desktop component.
[0147] In the embodiment of the present invention, the back-end desktop component refuses to push target data to any disconnected front-end desktop component.
[0148] 206. The backend desktop component determines the associated frontend desktop component with the subscription status as subscribed as the target frontend desktop component, and pushes target data to each target frontend desktop component, so that each target frontend desktop component pushes the target data to the target frontend application component corresponding to the target frontend desktop component.
[0149] In the embodiment of the present invention, for other detailed descriptions of steps 201 to 203 and step 206, please refer to the detailed description of steps 101 to 104 in the first embodiment, which will not be repeated in the embodiment of the present invention.
[0150] It can be seen that the method described in the embodiment of the present invention can be applied to electronic devices installed with an application, and the application includes a back-end desktop component, a back-end application component, a front-end desktop component and a front-end application component. The method can establish a WebSocket connection between the back-end desktop component and at least one front-end desktop component. The back-end desktop component can receive the first heartbeat information carrying the subscription list sent by the front-end desktop component to register for the relevant data push service. When the back-end desktop component receives the target data pushed by the back-end application component, the subscription status of each front-end desktop component is determined according to the subscription list. The front-end desktop component in the subscribed state is then determined as the target front-end desktop component to push the target data to the target front-end desktop component. Real-time data push between multiple terminals can be achieved by establishing a WebSocket connection, thereby improving the transmission efficiency and stability of real-time data. Reducing the possibility of system crashes caused by the continuous increase in memory usage due to data transmission is beneficial to improving the system's operating stability, and is beneficial to achieving real-time data synchronization between multiple terminals, and thus is beneficial to maintaining data consistency between multiple terminals; and transmitting real-time data through a WebSocket connection can reduce the size of the data packet, thereby reducing the network resources required for real-time data transmission, which is beneficial to improving network resource utilization; and when the data has not changed, the back-end does not need to transmit data to the front-end, which is beneficial to reducing the frequency of data transmission between the front-end and the back-end, thereby helping to reduce the back-end server load and reduce unnecessary network resource consumption, and is beneficial to improving system operating performance and stability; and, improving the accuracy of determining the target front-end desktop component that needs to push target data, thereby helping to improve the accuracy and efficiency of pushing target data, and thus helping to further improve the accuracy and efficiency of real-time data transmission. In addition, the back-end desktop component can identify the front-end desktop component in an unsubscribed state as a disconnected front-end desktop component, refuse to push target data to the disconnected front-end desktop component, and notify the back-end application component to stop pushing target data to the disconnected front-end desktop component. This can improve the accuracy of determining the disconnected front-end desktop component that does not need to push target data, thereby helping to reduce the possibility of target data being pushed incorrectly, and reducing the network resources consumed by erroneous data push, which in turn helps to further improve the accuracy and efficiency of real-time data transmission.
[0151] In an optional embodiment, the application program may further include at least one suite of network disk tools, synchronization and backup, and task manager.
[0152] Among them, the network disk tool can be used to store data in the cloud, synchronization and backup can be used for data synchronization and data backup functions between different devices / applications, and the task manager can be used to manage the operating status of the system on electronic devices.
[0153] Exemplarily, the application may be UGREEN Cloud or other types of applications, which is not limited in the embodiment of the present invention.
[0154] It can be seen that the application in this optional embodiment has suites such as network disk tools, synchronization and backup, and task managers, which can realize efficient and accurate real-time data transmission functions between multiple terminals in an application that provides users with multiple data management functions.
[0155] In another optional embodiment, the backend desktop component determines the subscription status corresponding to each associated frontend desktop component based on all subscription lists, which may include the following operations:
[0156] The backend desktop component counts the disconnection duration of each associated frontend desktop component; the disconnection duration is the duration during which the backend desktop component does not receive the heartbeat information sent by the associated frontend desktop component;
[0157] The backend desktop component determines whether the disconnection duration of each associated frontend desktop component is less than or equal to a preset duration threshold;
[0158] When it is determined that the disconnection time of any associated front-end desktop component is less than or equal to the preset time threshold, the back-end desktop component determines the subscription state corresponding to the associated front-end desktop component as the subscribed state;
[0159] When it is determined that the disconnection duration of any associated front-end desktop component is greater than a preset duration threshold, the back-end desktop component determines the subscription state corresponding to the associated front-end desktop component as an unsubscribed state.
[0160] It should be noted that, under normal circumstances, the front-end application component will actively notify the back-end application component to cancel the subscription (that is, transmit the above-mentioned cancellation notification information) so that the back-end application component stops sending the data required by the front-end application component to the back-end desktop component; however, in order to prevent the front-end application component from failing to notify the back-end application component due to network anomalies or heartbeat loss, the back-end desktop component will default to considering that the front-end application component has canceled the subscription (that is, it determines that the front-end desktop component is in an unsubscribed state) after not receiving the heartbeat packet sent by the front-end desktop component within a period of time, and take corresponding measures to implement a layer of exception handling mechanism.
[0161] It can be seen that the back-end desktop component in this optional embodiment can count the disconnection duration of each front-end desktop component. If the disconnection duration is less than or equal to the preset duration threshold, it is determined that the front-end desktop component is still in the subscribed state. If the disconnection duration is too long, it is determined that the front-end desktop component has been unsubscribed, that is, it is in the unsubscribed state. By providing an exception handling mechanism, the flexibility and efficiency of determining the subscription status of the front-end desktop component can be improved, which is conducive to improving the accuracy of determining the target front-end desktop component that needs to push target data, and further conducive to improving the efficiency and accuracy of real-time data transmission.
[0162] In the embodiment of the present invention, for example, please refer to Figure 3 , Figure 3 This is a flow chart of another real-time data transmission method disclosed in an embodiment of the present invention. Figure 3 As shown, the specific process of this method can be specifically as follows:
[0163] After establishing a WebSocket connection between the front-end desktop component and the back-end desktop component, the front-end application component registers / unsubscribes with the front-end desktop component. The front-end desktop component then sends a heartbeat message with the subscription list / unsubscription information to the back-end desktop component. After successful registration / unsubscription (i.e., confirmation of the subscription list / unsubscription information by the back-end desktop component), the front-end application component notifies the corresponding back-end application component, indicating that it has successfully subscribed / unsubscribed to the back-end desktop component. This allows the back-end application component to push data to the front-end application component through the back-end desktop component and the front-end desktop component when data changes, or denies the back-end application component from pushing data to the front-end application component. Once the back-end desktop component receives new data, it immediately pushes the latest data to all connected front-end desktop components (i.e., those that are subscribed), ensuring consistent and synchronized data across all devices. After receiving the latest data, the front-end desktop component pushes the latest data to the corresponding front-end application component. Upon receiving the latest data update, the front-end application component first parses the data and determines the type of data received based on the subscription key value, then executes the corresponding business logic. During the above data transmission process, if a network interruption or other anomalies occur, the front-end desktop component can automatically try to re-establish the WebSocket connection, thereby helping to properly recover the data lost during the disconnection.
[0164] In the embodiment of the present invention, the following experimental results are obtained by experimentally testing the real-time data transmission method:
[0165] By adopting the WebSocket protocol instead of the traditional HTTP polling mechanism, it is possible to achieve a very stable application memory usage corresponding to the communication system regardless of whether there is a data transmission task in progress. Experimental data show that in the non-task state, the initial memory is 129MB, and it remains at 129MB after 10 minutes; when there is a task running, it decreases from the initial 149MB to 142MB (after 10 minutes), and only slightly increases to 148MB after a long period of operation (such as after 120 minutes). In contrast, the memory consumption of the traditional HTTP polling method will gradually increase over time (the memory reaches 1196MB after 10 minutes). It can be seen that the method proposed in the present invention is significantly lower than the memory peak of the prior art, and the memory peak is reduced by about 87.63%. The data can be calculated by the following formula:
[0166]
[0167] Furthermore, after a continuous one-hour monitoring test, the memory usage remained stable, the page did not freeze, and the user experience was very smooth;
[0168] Furthermore, after 24 hours of continuous monitoring and testing, no client crashes were found due to the use of this real-time data transmission method, indicating that this method has higher reliability and stability.
[0169] Furthermore, the data length of WebSocket pushes ranges from 142 to 436 bytes, which translates to a maximum of 0.406KB. Compared to transmitting the same amount of data using HTTP polling (588KB), this method reduces the packet size by ≥99%. This not only significantly saves network bandwidth resources but also improves data transmission efficiency.
[0170] Furthermore, when the data has not changed, the WebSocket connection allows the server to not respond, thereby effectively reducing unnecessary server load and resource consumption, and improving the overall performance and stability of the system.
[0171] Example 3
[0172] See also Figure 4 , Figure 4 1 is a structural diagram of a real-time data transmission device disclosed in an embodiment of the present invention. Figure 4The real-time data transmission device described may include a real-time data transmission terminal, a real-time data transmission device, and a server, wherein the server may be a local server or a local server, which is not limited in the embodiment of the present invention; the device may be applied to an electronic device, which has an application installed therein, and the electronic device is in communication connection with a network attached storage device, and the electronic device may access the network attached storage device through the application, which is not limited in the embodiment of the present invention. Figure 4 As shown, the real-time data transmission device 30 may include a backend desktop component, and the backend desktop component belongs to an application. The application further includes a backend application component associated with the backend desktop component, at least one frontend desktop component, and a frontend application component corresponding to each frontend desktop component. The backend desktop component may include:
[0173] The receiving module 301 is configured to receive a first heartbeat message sent by any front-end desktop component after the back-end desktop component establishes a WebSocket connection with at least one front-end desktop component; the first heartbeat message carries a subscription list; the subscription list is used to register a data push service for at least one data topic;
[0174] A determination module 302 is configured to determine the front-end desktop component that sends the first heartbeat information as an associated front-end desktop component;
[0175] The receiving module 301 is further configured to receive target data sent by the backend application component; the target data includes the latest data with data changes in the backend application component and / or data update information for the latest data;
[0176] The determination module 302 is further configured to determine the subscription status corresponding to each associated front-end desktop component based on all subscription lists; the subscription status includes a subscribed state or an unsubscribed state;
[0177] The push module 303 is used to determine the associated front-end desktop component with a subscription status of subscribed as the target front-end desktop component, and push the target data to each target front-end desktop component, so that each target front-end desktop component pushes the target data to the target front-end application component corresponding to the target front-end desktop component.
[0178] It can be seen that the device described in the embodiment of the present invention can, after the back-end desktop component establishes a WebSocket connection with at least one front-end desktop component, receive the first heartbeat information carrying the subscription list sent by the front-end desktop component to register the relevant data push service, and then when the back-end desktop component receives the target data pushed by the back-end application component, determine the subscription status of each front-end desktop component according to the subscription list, and then determine the front-end desktop component in the subscribed state as the target front-end desktop component to push the target data to the target front-end desktop component, and can realize real-time data push between multiple terminals by establishing a WebSocket connection, thereby improving the transmission efficiency and transmission stability of real-time data, and reducing the possibility of system crash due to the continuous increase in memory occupied by data transmission, which is beneficial It is conducive to improving the operational stability of the system and realizing real-time data synchronization between multiple terminals, thereby facilitating maintaining data consistency between multiple terminals; and, transmitting real-time data through a WebSocket connection can reduce the size of the data packet, thereby reducing the network resources required for real-time data transmission, thereby improving network resource utilization; and, when the data has not changed, the back-end does not need to transmit data to the front-end, thereby reducing the frequency of data transmission between the front-end and the back-end, thereby reducing the back-end server load and unnecessary network resource consumption, thereby improving the system operational performance and stability; and, improving the accuracy of determining the target front-end desktop component that needs to push the target data, thereby improving the accuracy and efficiency of pushing the target data, thereby further improving the accuracy and efficiency of real-time data transmission.
[0179] In an optional embodiment, the application further includes at least one suite of network disk tools, synchronization and backup, and task manager.
[0180] It can be seen that the application implemented in this optional embodiment has suites such as network disk tools, synchronization and backup, and task managers, which can realize efficient and accurate real-time data transmission functions between multiple terminals in applications that provide users with multiple data management functions.
[0181] In this optional embodiment, optionally, the determination module 302 is further configured to, after the determination module 302 determines the subscription status corresponding to each associated front-end desktop component according to all subscription lists, determine the associated front-end desktop component whose subscription status is unsubscribed as a disconnected front-end desktop component, and not push target data to any disconnected front-end desktop component;
[0182] As well as Figure 5 As shown, the backend desktop component may also include:
[0183] A generating module 304 is used to generate a stop push message;
[0184] The sending module 305 is used to send a stop push message to the backend application component; the stop push message is used to instruct the backend application component to stop providing data push service to any disconnected front-end desktop component.
[0185] It can be seen that the device described in implementing this optional embodiment can also determine the front-end desktop component in an unsubscribed state as a disconnected front-end desktop component, so as to refuse to push target data to the disconnected front-end desktop component, and notify the back-end application component to stop pushing target data to the disconnected front-end desktop component, which can improve the accuracy of determining the disconnected front-end desktop component that does not need to push target data, thereby helping to reduce the possibility of target data being pushed incorrectly, and reducing the network resources consumed due to erroneous data push, which in turn helps to further improve the accuracy and efficiency of real-time data transmission.
[0186] In this optional embodiment, the specific manner in which the determination module 302 determines the subscription status corresponding to each associated front-end desktop component based on all subscription lists may include:
[0187] Count the disconnection duration of each associated front-end desktop component; the disconnection duration is the duration during which the back-end desktop component does not receive the heartbeat information sent by the associated front-end desktop component;
[0188] Determine whether the disconnection duration of each associated front-end desktop component is less than or equal to a preset duration threshold;
[0189] When it is determined that the disconnection time of any associated front-end desktop component is less than or equal to the preset time threshold, the subscription state corresponding to the associated front-end desktop component is determined to be a subscribed state;
[0190] When it is determined that the disconnection time of any associated front-end desktop component is greater than a preset time threshold, the subscription state corresponding to the associated front-end desktop component is determined to be an unsubscribed state.
[0191] It can be seen that the device described in the implementation of this optional embodiment can also count the disconnection duration of each front-end desktop component. If the disconnection duration is less than or equal to the preset duration threshold, it is determined that the front-end desktop component is still in the subscribed state. If the disconnection duration is too long, it is determined that the front-end desktop component has been unsubscribed, that is, it is in the unsubscribed state. By providing an exception handling mechanism, the flexibility and efficiency of determining the subscription status of the front-end desktop component can be improved, which is conducive to improving the accuracy of determining the target front-end desktop component that needs to push target data, and further conducive to improving the efficiency and accuracy of real-time data transmission.
[0192] In another optional embodiment, as Figure 5 As shown, the backend desktop component may also include:
[0193] The information feedback module 306 is used to return subscription confirmation information about the subscription list to each associated front-end desktop component after the receiving module 301 receives the first heartbeat information sent by any front-end desktop component, so that the associated front-end desktop component sends the subscription confirmation information to the first front-end application component corresponding to the associated front-end desktop component; the subscription confirmation information is used to instruct the first front-end application component to send subscription notification information about the subscription list to the back-end application component.
[0194] It can be seen that the device described in the implementation of this optional embodiment can, after the back-end desktop component receives the first heartbeat information, return the corresponding subscription confirmation information to the associated front-end desktop component that sent the first heartbeat information, so that the associated front-end desktop component synchronizes the subscription confirmation information to the corresponding front-end application component to instruct the front-end application component to notify the back-end application component that it has subscribed to the data push service, which can improve the information synchronization efficiency and accuracy of the relevant information of the registration subscription between multiple terminals, thereby facilitating the accurate and efficient pushing of data to the subscribed front-end desktop components and front-end application components in the subsequent data push process, and further helps to improve the efficiency and accuracy of real-time data transmission.
[0195] In this optional embodiment, optionally, as Figure 5 As shown, the backend desktop component may also include:
[0196] A clearing module 307 is configured to clear a subscription request that matches a second heartbeat message sent by any associated front-end desktop component after the receiving module 301 receives the second heartbeat message; the second heartbeat message carries subscription cancellation information; the subscription cancellation information is used to cancel the data push service of the associated front-end desktop component for at least one data topic;
[0197] The information feedback module 306 is also used to return deregistration confirmation information about the subscription deregistration information to each deregistered front-end desktop component, so that the deregistered front-end desktop component sends the deregistration confirmation information to the second front-end application component corresponding to the deregistered front-end desktop component; wherein, the deregistered front-end desktop component is the front-end desktop component that sends the second heartbeat information to the back-end desktop component; the deregistration confirmation information is used to instruct the second front-end application component to send deregistration notification information about the subscription deregistration information to the back-end application component.
[0198] It can be seen that the device described in the implementation of this optional embodiment can also, after the back-end desktop component receives the second heartbeat information carrying the subscription cancellation information, clear the relevant subscription request and return the corresponding cancellation confirmation information to the cancellation front-end desktop component that sent the second heartbeat information, so that the cancellation front-end desktop component synchronizes the cancellation confirmation information to the corresponding front-end application component to instruct the front-end application component to notify the back-end application component that the data push service has been canceled, which can improve the information synchronization efficiency and accuracy of the relevant information of the cancellation subscription between multiple terminals, thereby helping to reduce the possibility of the back-end pushing data to the front-end that has canceled the subscription to the data push service in the subsequent data push process, and further help to further improve the efficiency and accuracy of real-time data transmission.
[0199] In another optional embodiment, Figure 5 As shown, the target data includes multiple data packets;
[0200] The backend desktop component may further include:
[0201] The exception handling module 308 is configured to respond to the exception handling operation when it is detected that any target front-end desktop component performs an exception handling operation on a back-end desktop component during the process in which the push module 303 pushes the target data to each target front-end desktop component so that each target front-end desktop component pushes the target data to the target front-end application component corresponding to the target front-end desktop component;
[0202] Among them, the exception handling operation is determined by the following method;
[0203] Each target front-end desktop component determines whether there is a packet loss anomaly between the back-end desktop component and the target front-end desktop component based on the received data packet;
[0204] When it is determined that there is a packet loss exception between the back-end desktop component and the target front-end desktop component, the target front-end desktop component determines the exception handling operation corresponding to the packet loss exception and performs the exception handling operation on the back-end desktop component; the exception handling operation includes a connection reconstruction operation and / or a subscription retransmission operation.
[0205] It can be seen that the device described in the implementation of this optional embodiment can enable the front-end desktop component to actively trigger and execute corresponding exception handling operations when a data transmission exception occurs between the back-end desktop component and the front-end desktop component, which can improve the timeliness of capturing data transmission exceptions, thereby helping to improve the timeliness and efficiency of exception handling, and further helping to reduce data loss or resources required for data retransmission due to data transmission exceptions, and further helping to further improve the stability and reliability of real-time data transmission.
[0206] Example 4
[0207] See also Figure 6 , Figure 6 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of the present invention. Figure 6 As shown, the electronic device 40 may include:
[0208] A memory 401 storing executable program code;
[0209] a processor 402 coupled to the memory 401;
[0210] The processor 402 calls the executable program code stored in the memory 401 to execute part or all of the steps of the real-time data transmission method described in the first embodiment or the second embodiment of the present invention.
[0211] Example 5
[0212] An embodiment of the present invention discloses a computer storage medium storing computer instructions. When the computer instructions are called, they are used to execute some or all of the steps in the real-time data transmission method described in Embodiment 1 or Embodiment 2 of the present invention.
[0213] Example 6
[0214] See also Figure 7 , Figure 7 This is a structural diagram of a real-time data transmission system disclosed in an embodiment of the present invention. Figure 7 As shown, an embodiment of the present invention discloses a real-time data transmission system, which includes at least a real-time data transmission device 30 as described in the third embodiment of the present invention, and a network attached storage device 50 in communication with the real-time data transmission device, and business data is stored on the network attached storage device 50. When the network attached storage device 50 serves as a backend application component and pushes target data in the business data to the real-time data transmission device 30, the real-time data transmission device 30 performs a data transmission operation for the target data according to the real-time data transmission method described in the first embodiment of the present invention or the second embodiment of the present invention;
[0215] or,
[0216] In the embodiment of the present invention, as another optional implementation method, please refer to Figure 8 , Figure 8 FIG is a structural diagram of another real-time data transmission system disclosed in an embodiment of the present invention. Figure 8As shown, an embodiment of the present invention discloses a real-time data transmission system, which includes at least an electronic device 40 as described in Example 3 of the present invention, and a network-attached storage device 50 communicatively connected to the electronic device, and business data is stored on the network-attached storage device 50. When the network-attached storage device 50 serves as a back-end application component and pushes target data in the business data to the electronic device 40, the electronic device 40 performs a data transmission operation for the target data according to the real-time data transmission method described in Example 1 or Example 2 of the present invention.
[0217] Example 7
[0218] An embodiment of the present invention discloses a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to enable a computer to execute some or all of the steps in the real-time data transmission method described in Example 1 or Example 2.
[0219] The device embodiments described above are merely illustrative, wherein the modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, i.e., they may be located in one place or distributed across multiple network modules. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Those skilled in the art can understand and implement the present invention without inventive effort.
[0220] Through the detailed description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus the necessary general hardware platform, or of course, by means of hardware. Based on this understanding, the above technical solution, in essence, or the portion that contributes to the prior art, can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, including a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium capable of carrying or storing data.
[0221] Finally, it should be noted that the real-time data transmission method, device, electronic device and system disclosed in the embodiments of the present invention are only preferred embodiments of the present invention, and are only used to illustrate the technical solutions of the present invention, rather than to limit them. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features therein can be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A real-time data transmission method, the method being applied to an electronic device having an application installed therein, the electronic device being communicatively connected to a network attached storage device, and the electronic device being able to access the network attached storage device through the application, characterized in that: The application includes a backend desktop component, a backend application component associated with the backend desktop component, at least one frontend desktop component, and a frontend application component corresponding to each frontend desktop component. The method includes: After the backend desktop component establishes a WebSocket connection with at least one of the frontend desktop components, the backend desktop component receives a first heartbeat message sent by any of the frontend desktop components, and determines the frontend desktop component that sent the first heartbeat message as the associated frontend desktop component; the first heartbeat message carries a subscription list; the subscription list is used to register a data push service for at least one data topic; The backend desktop component receives target data sent by the backend application component; the target data includes the latest data with data changes in the backend application component and / or data update information for the latest data; The backend desktop component determines the subscription status corresponding to each of the associated frontend desktop components according to all the subscription lists; the subscription status includes a subscribed state or an unsubscribed state; The back-end desktop component determines the associated front-end desktop component whose subscription status is the subscribed status as the target front-end desktop component, and pushes the target data to each target front-end desktop component, so that each target front-end desktop component pushes the target data to the target front-end application component corresponding to the target front-end desktop component.
2. The real-time data transmission method according to claim 1, characterized in that: The application also includes at least one suite of network disk tools, synchronization and backup, and task manager.
3. The real-time data transmission method according to claim 1, characterized in that: After the backend desktop component determines the subscription status corresponding to each of the associated frontend desktop components based on all the subscription lists, the method further includes: The back-end desktop component determines the associated front-end desktop component whose subscription state is the unsubscribed state as a disconnected front-end desktop component, and the back-end desktop component does not push the target data to any of the disconnected front-end desktop components; The backend desktop component generates a stop push message and sends the stop push message to the backend application component; the stop push message is used to instruct the backend application component to stop providing the data push service to any of the disconnected front-end desktop components.
4. The real-time data transmission method according to claim 1, wherein: The backend desktop component determines the subscription status corresponding to each associated frontend desktop component according to all the subscription lists, including: The back-end desktop component counts the disconnection duration of each associated front-end desktop component; the disconnection duration is the duration during which the back-end desktop component does not receive the heartbeat information sent by the associated front-end desktop component; The back-end desktop component determines whether the disconnection duration of each of the associated front-end desktop components is less than or equal to a preset duration threshold; When it is determined that the disconnection duration of any of the associated front-end desktop components is less than or equal to the preset duration threshold, the back-end desktop component determines the subscription state corresponding to the associated front-end desktop component as the subscribed state; When it is determined that the disconnection duration of any of the associated front-end desktop components is greater than the preset duration threshold, the back-end desktop component determines the subscription state corresponding to the associated front-end desktop component as the unsubscribed state.
5. The real-time data transmission method according to any one of claims 1 to 4, characterized in that: After the back-end desktop component receives the first heartbeat information sent by any of the front-end desktop components, the method further includes: For each of the associated front-end desktop components, the back-end desktop component returns subscription confirmation information about the subscription list to the associated front-end desktop component, so that the associated front-end desktop component sends the subscription confirmation information to the first front-end application component corresponding to the associated front-end desktop component; the subscription confirmation information is used to instruct the first front-end application component to send subscription notification information about the subscription list to the back-end application component.
6. The real-time data transmission method according to claim 5, characterized in that: The method further comprises: After the back-end desktop component receives the second heartbeat information sent by any of the associated front-end desktop components, the back-end desktop component clears the subscription request that matches the second heartbeat information; the second heartbeat information carries subscription cancellation information; the subscription cancellation information is used to cancel the data push service of the associated front-end desktop component for at least one of the data topics; For each deregistered front-end desktop component, the back-end desktop component returns deregistration confirmation information about the subscription deregistration information to the deregistered front-end desktop component, so that the deregistered front-end desktop component sends the deregistration confirmation information to the second front-end application component corresponding to the deregistered front-end desktop component; wherein, the deregistered front-end desktop component is the front-end desktop component that sends the second heartbeat information to the back-end desktop component; the deregistration confirmation information is used to instruct the second front-end application component to send deregistration notification information about the subscription deregistration information to the back-end application component.
7. The real-time data transmission method according to any one of claims 1, 2, 3, 4 and 6, characterized in that: The target data includes a plurality of data packets; Wherein, in the process where the backend desktop component pushes the target data to each of the target frontend desktop components so that each of the target frontend desktop components pushes the target data to the target frontend application component corresponding to the target frontend desktop component, the method further includes: When the backend desktop component detects that any of the target frontend desktop components performs an exception handling operation on the backend desktop component, the backend desktop component responds to the exception handling operation; Wherein, the exception handling operation is determined by the following method; Each of the target front-end desktop components determines, based on the received data packets, whether there is a packet loss anomaly between the back-end desktop component and the target front-end desktop component; When it is determined that the packet loss exception exists between the back-end desktop component and the target front-end desktop component, the target front-end desktop component determines the exception handling operation corresponding to the packet loss exception and performs the exception handling operation on the back-end desktop component; the exception handling operation includes a connection reconstruction operation and / or a subscription retransmission operation.
8. A real-time data transmission device, the device being applied to an electronic device having an application installed therein, the electronic device being communicatively connected to a network attached storage device, and the electronic device being able to access the network attached storage device through the application, characterized in that: The device includes a backend desktop component, and the backend desktop component belongs to the application. The application further includes a backend application component associated with the backend desktop component, at least one frontend desktop component, and a frontend application component corresponding to each frontend desktop component. The backend desktop component includes: A receiving module, configured to receive a first heartbeat message sent by any of the front-end desktop components after the back-end desktop component establishes a WebSocket connection with at least one of the front-end desktop components; the first heartbeat message carries a subscription list; the subscription list is used to register a data push service for at least one data topic; A determination module, configured to determine the front-end desktop component that sends the first heartbeat information as an associated front-end desktop component; The receiving module is further configured to receive target data sent by the back-end application component; the target data includes the latest data with data changes in the back-end application component and / or data update information for the latest data; The determining module is further configured to determine, based on all the subscription lists, a subscription status corresponding to each of the associated front-end desktop components; the subscription status includes a subscribed state or an unsubscribed state; A push module is used to determine the associated front-end desktop component whose subscription status is the subscribed status as the target front-end desktop component, and push the target data to each of the target front-end desktop components, so that each of the target front-end desktop components pushes the target data to the target front-end application component corresponding to the target front-end desktop component.
9. An electronic device, characterized in that: The electronic device comprises: a memory storing executable program code; a processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the real-time data transmission method according to any one of claims 1 to 7.
10. A real-time data transmission system, characterized in that: The system comprises at least the real-time data transmission apparatus according to claim 8, and a network attached storage device communicatively connected to the real-time data transmission apparatus, wherein the network attached storage device stores business data, and when the network attached storage device functions as a back-end application component and pushes target data in the business data to the real-time data transmission apparatus, the real-time data transmission apparatus performs a data transmission operation for the target data according to the real-time data transmission method according to any one of claims 1 to 7; or, The system includes at least the electronic device as described in claim 9, and a network-attached storage device communicatively connected to the electronic device, and business data is stored on the network-attached storage device. When the network-attached storage device serves as a back-end application component and pushes target data in the business data to the electronic device, the electronic device performs a data transmission operation for the target data according to the real-time data transmission method as described in any one of claims 1-7.
11. A computer storage medium, characterized in that The computer storage medium stores computer instructions, and when the computer instructions are called, they are used to execute the real-time data transmission method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Message processing method and device and computer readable storage medium
CN115834657A
Real-time data pushing method, scheduling system, electronic equipment and storage medium
CN119254829A
Real-time picture data transmission method based on Websocket protocol
CN119316494A
Systems and / or methods for testing client reactions to simulated disruptions
US20130262931A1