Data communication method and device, electronic equipment and computer storage medium
By installing an extension on the browser and using a WebSocket long connection to establish a communication relay station with the server, the problem of unstable communication between the browser and the server is solved, achieving stable and efficient data communication and supporting remote management and real-time status monitoring of the browser.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-10
- Publication Date
- 2026-03-10
AI Technical Summary
In existing technologies, WebSocket connections between browsers and servers are easily affected by network conditions, leading to unstable communication and low flexibility.
By installing an extension on the browser, a communication relay station is established with the server using a WebSocket long connection, bypassing network environment restrictions and achieving full-duplex communication. The extension can also listen for and send browser status information and receive management policies and notification messages.
Ensure the stability and timeliness of communication between the browser and the server, improve the flexibility of data communication, simplify interaction details, and support remote management and real-time status monitoring of the browser.
Smart Images

Figure CN121644635A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data communication technology, and in particular to a data communication method, apparatus, electronic device, and computer storage medium. Background Technology
[0002] When developing web applications, especially in scenarios such as real-time communication, online collaboration, gaming, financial transactions, social media, and remote device management, ensuring the timeliness of data communication between the server and the browser is crucial. To improve the timeliness of data communication, developers often use WebSocket persistent connections to implement communication between the browser and the server.
[0003] WebSocket, as a protocol for establishing persistent, full-duplex connections between browsers and servers, significantly improves the efficiency and effectiveness of real-time communication. Compared to polling and HTTP long connections, using WebSocket long connections for communication between browsers and servers offers advantages such as low latency and high timeliness.
[0004] However, the current method of using WebSocket long connections to achieve communication between browsers and servers is easily hindered by network environment limitations (such as firewalls or proxy server restrictions), which can lead to communication restrictions and instability. Existing data communication methods have low communication flexibility. Summary of the Invention
[0005] This application provides a data communication method, apparatus, electronic device, and computer storage medium, which can solve the problems of limited and unstable communication between browsers and servers in the prior art, and improve the flexibility of data communication.
[0006] In a first aspect, embodiments of this application provide a data communication method applied to a terminal, the terminal having a browser installed, and the browser having extensions installed; the method includes:
[0007] Obtain the pre-configured target server address;
[0008] Establish a long-lived WebSocket connection with the server corresponding to the target server address through the extension;
[0009] After establishing a connection, the extension sends the browser's status information to the server; and
[0010] After the connection is established, the extension program receives the connection status information of the WebSocket long connection and transmits the connection status information to the browser through a preset interface.
[0011] In one possible implementation, the above data communication method further includes:
[0012] The extension listens to the browser's status information after a connection is established;
[0013] When the browser's state information changes, an extension that establishes a connection sends a status change notification to the server.
[0014] In one possible implementation, based on a WebSocket long-lived connection, the browser's status information is sent to the server, including:
[0015] After the connection is established, the extension sends browser status information to the server's WebSocket service port at preset time intervals.
[0016] In one possible implementation, the browser's state information includes at least one of the following: browser application state information, browser device state information, and browser network connection state information.
[0017] In one possible implementation, a WebSocket long-lived connection is established between the extension and the server corresponding to the target server address, including:
[0018] The extension program sends a handshake request to the server corresponding to the target server address.
[0019] If the response information contained in the handshake response to the handshake request is verified successfully, a long-lived WebSocket connection is established with the server via the extension.
[0020] In one possible implementation, the above data communication method further includes:
[0021] After establishing a connection, the extension program receives management policy information for the browser from the server; the management policy information includes at least one of access permission policy information, resource usage policy information, and data encryption policy information.
[0022] Remote management and control of the browser based on management policy information.
[0023] In one possible implementation, the above data communication method further includes:
[0024] After establishing a connection, the extension program receives notification messages sent by the server to the browser; the notification messages include at least one of the following: system update messages, service status change messages, and account activity warning messages.
[0025] Display notification messages in the browser interface.
[0026] Secondly, embodiments of this application provide a data communication device applied to a terminal, the terminal having a browser installed, and the browser having extensions installed; the device includes:
[0027] The acquisition module is used to obtain the pre-configured target server address;
[0028] The connection module is used to create a long-lived WebSocket connection with the server corresponding to the target server address via the extension.
[0029] The communication module is used to send browser status information to the server through the extension program after the connection is established; and to receive connection status information of the WebSocket long connection through the extension program after the connection is established, and transmit the connection status information to the browser through a preset interface.
[0030] Thirdly, embodiments of this application provide an electronic device, including: a processor and a memory; wherein the memory stores a computer program, the computer program being adapted to be loaded by the processor and execute the method steps provided in the first aspect of embodiments of this application.
[0031] Fourthly, embodiments of this application provide a computer storage medium storing a plurality of instructions adapted for loading by a processor and executing the method steps provided in the first aspect of embodiments of this application.
[0032] The aforementioned data communication method, apparatus, electronic device, and computer storage medium are applied to a terminal. The terminal has a browser installed, and the browser has an extension installed. During communication with a server, the terminal obtains a pre-configured target server address, establishes a WebSocket long connection with the server corresponding to the target server address through the extension, sends browser status information to the server through the established connection, and receives connection status information of the WebSocket long connection through the established connection, and transmits the connection status information to the browser through a preset interface. Throughout the data communication process, the extension acts as a communication relay between the browser and the server. Using the extension to establish a WebSocket long connection supporting full-duplex communication not only bypasses network environment restrictions by leveraging the extension's permissions, ensuring the stability of communication between the browser and the server, but also achieves full-duplex communication based on the WebSocket protocol, guaranteeing timely communication. This technical solution solves the problems of limited and unstable communication between browsers and servers in existing technologies, improving the flexibility of data communication. Attached Figure Description
[0033] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0034] Figure 1 A schematic diagram illustrating the application environment of a data communication method provided for an exemplary embodiment of this application;
[0035] Figure 2 A flowchart illustrating a data communication method provided for an exemplary embodiment of this application;
[0036] Figure 3 A flowchart illustrating another data communication method provided for an exemplary embodiment of this application;
[0037] Figure 4 A schematic diagram of the architecture of a data communication method provided for an exemplary embodiment of this application;
[0038] Figure 5 This is a schematic diagram of the structure of a data communication device in one embodiment;
[0039] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0040] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0041] In the description of this application, it should be understood that the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances. Furthermore, in the description of this application, unless otherwise stated, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship.
[0042] The data communication method provided in this application embodiment can be applied to, for example... Figure 1The application environment shown is as follows. Terminal 10 communicates with server 20 via a network. Terminal 10 has a browser installed, and the browser has extensions installed. Server 20 integrates a management platform for remote monitoring and management of the browser on terminal 10. A data storage system can store the data that server 20 needs to process. The data storage system can be integrated on server 20 or placed on a cloud or other network server. Terminal 10 obtains the pre-configured target server address; establishes a WebSocket long connection with the server corresponding to the target server address through the extension; sends the browser's status information to the server through the established extension; and receives the WebSocket long connection status information through the established extension, and transmits the connection status information to the browser through a preset interface.
[0043] It is worth noting that terminal 10 can be implemented using a standalone terminal or a terminal cluster composed of multiple terminals. Terminal 10 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. Server 20 can be implemented using a standalone server or a server cluster composed of multiple servers.
[0044] In one embodiment, such as Figure 2 As shown, a data communication method is provided, which is applied to... Figure 1 Taking terminal 10 as an example, the explanation includes the following steps:
[0045] S201: Obtain the pre-configured target server address.
[0046] Optionally, when an extension installed on the browser of terminal 10 is launched, terminal 10 obtains the target server address pre-configured by the browser, i.e., the URL (Uniform Resource Locator) of the target server. This target server address can be either the browser's default server address or a server address that has been modified and configured by the user. Obtaining the pre-configured target server address when the extension is launched ensures that the extension can subsequently connect to the specified server based on that target server address.
[0047] S202: Establish a long-lived WebSocket connection with the server corresponding to the target server address through the extension.
[0048] WebSocket is a protocol that enables full-duplex communication over a single TCP (Transmission Control Protocol) connection. It allows both the browser and server to send data at any time without waiting for the other to send or acknowledge it first. Compared to the traditional HTTP protocol, WebSocket is more efficient and real-time. A WebSocket persistent connection refers to a communication method that establishes a persistent connection between the browser and server based on the WebSocket protocol and maintains that connection state. In other words, a WebSocket persistent connection allows the browser and server to establish a connection once and then keep that connection open without needing to close it after each communication. WebSocket persistent connections allow the server to proactively push data to the browser without waiting for the browser's request.
[0049] Optionally, terminal 10 establishes a WebSocket long connection with the server corresponding to the target server address through the extension, thereby using the extension as a relay station for communication between the browser and the server. In this embodiment, using the extension to establish a WebSocket long connection with the server can, on the one hand, bypass network environment restrictions by leveraging the extension's permissions, thereby ensuring the stability of communication between the browser and the server; on the other hand, it can also achieve full-duplex communication based on the WebSocket protocol, thereby ensuring the timeliness of communication.
[0050] S203: After establishing a connection, send the browser's status information to the server through the extension; and after establishing a connection, receive the connection status information of the WebSocket long connection through the extension, and transmit the connection status information to the browser through a preset interface.
[0051] Optionally, terminal 10, through an extension program that has established a WebSocket long connection with the server, sends browser status information to a specific WebSocket service port on the server. This browser status information includes at least one of the following: browser application status information, browser device status information, and browser network connection status information. Simultaneously, terminal 10 can also, through the aforementioned extension program after establishing the connection, feed back the WebSocket long connection status information to a preset interface of the browser, such as the browser's native Application Programming Interface (API), so that the browser can promptly receive the WebSocket long connection status information, such as data transmission status information, connection closure status information, data reception status information, connection success status information, and connection failure status information.
[0052] Among them, the data sending status indicates that the extension or server has data to send to the other party; the connection closed status indicates that the WebSocket long connection has been actively closed or abnormally closed due to network problems; the data receiving status indicates that the extension or server has received data from the other party; the connection successful status indicates that the WebSocket long connection has been established between the extension and the server and is ready for data exchange; and the connection failed status indicates that the WebSocket long connection encountered a problem during the establishment process and failed to establish a connection.
[0053] The aforementioned data communication method is applied to a terminal equipped with a browser and an extension. During communication with the server, the terminal obtains a pre-configured target server address, establishes a WebSocket long connection with the server corresponding to that address through the extension, sends browser status information to the server after the connection is established, and receives connection status information from the WebSocket long connection through the extension, transmitting this information back to the browser via a preset interface. Throughout the entire data communication process, the extension acts as a communication intermediary between the browser and the server. Using the extension to establish a full-duplex WebSocket long connection with the server not only bypasses network environment restrictions by leveraging the extension's permissions, ensuring the stability of communication between the browser and the server, but also achieves full-duplex communication based on the WebSocket protocol, guaranteeing timely communication. This data communication method solves the problems of limited and unstable communication between browsers and servers in existing technologies, improving the flexibility of data communication.
[0054] In one embodiment, such as Figure 3 As shown, another data communication method is provided, which can be applied to... Figure 1 Taking terminal 10 as an example, the explanation includes the following steps:
[0055] S301: Obtain the pre-configured target server address.
[0056] Specifically, S301 is the same as S201, and will not be repeated here.
[0057] S302: Send a handshake request to the server corresponding to the target server address through the extension procedure.
[0058] Optionally, developers can pre-create a WebSocket object based on a pre-configured target server address within the extension's content script (such as JavaScript). Once a WebSocket object is created, the extension on the browser automatically sends an HTTP header containing an upgrade request to the server, requesting that the connection between the extension and the server be upgraded to a persistent WebSocket connection. After receiving the client's WebSocket handshake request, the server checks key fields in the request header, such as Upgrade, Connection, and Sec-WebSocket-Key, to ensure that the request complies with the WebSocket protocol requirements. If the server accepts the request after checking the key fields, it sends an HTTP response containing a specific handshake response, thereby establishing the persistent WebSocket connection.
[0059] S303: If the response information contained in the handshake response to the handshake request is verified, a long-lived WebSocket connection is established with the server via the extension.
[0060] Optionally, the browser receives an HTTP response from the server containing a specific handshake response. This response includes a Sec-WebSocket-Accept header, which is a value calculated based on the Sec-WebSocket-Key provided by the browser in the request. If the handshake response contains the correct Sec-WebSocket-Accept value, the browser's extensions can consider the handshake successful and thus establish a long-lived WebSocket connection with the server.
[0061] S304: Listen to the browser's status information through the extension after the connection is established.
[0062] Optionally, browser-provided event listener APIs allow extensions to register event listeners. After creating a WebSocket object in the extension's content script, developers can set event listeners in the content script to monitor browser state information based on these APIs. This browser state information includes at least one of the following: application state information, device state information, and network connection state information. Application state information includes, but is not limited to, login state information (such as login status switching information, login time information, login location information, etc.), interface state information (such as interface display information, scroll position information, selected item information, etc.), and user identity state information (such as user ID, user personalization information, user session information, etc.). Device state information includes, but is not limited to, device type information, operating system version information, battery status information, memory and storage space information, etc. Network connection state information includes, but is not limited to, WebSocket long-lived connection state information (such as connection success, connection failure, etc.).
[0063] S305: After establishing a connection, the extension program sends browser status information to the server's WebSocket service port at preset time intervals.
[0064] The preset time interval is a manually set time interval, such as 1 second. This interval can also be adjusted according to actual needs, such as to 1 minute or 5 minutes. A shorter preset time interval results in higher real-time communication between the extension and the server, but also means higher consumption of network and computing resources. The WebSocket service port refers to the specific port number on the server that listens for WebSocket connection requests. This port can be arbitrary, but for compatibility and security, and to avoid blocking by firewalls and network devices, a standard HTTP or HTTPS port is usually chosen, such as 80 (unencrypted HTTP) or 443 (encrypted HTTPS).
[0065] Optionally, terminal 10 sends browser status information to the WebSocket service port 443 on the server at preset time intervals of 1 second via an extension on the browser. This browser status information includes at least one of the following: browser application status information, browser device status information, and browser network connection status information. After receiving the browser status information sent by the extension, the server can analyze it based on monitored user behavior, system performance, network connection status, etc., and generate corresponding management policy information and / or message policy information, thereby achieving remote management of the browser.
[0066] It is worth noting that this embodiment only describes a preferred implementation of this application. The extension is not limited to sending browser status information to the server's WebSocket service port at preset time intervals. It can also be based on a heartbeat mechanism, sending heartbeat data packets to the server's WebSocket service port at preset time intervals to maintain connection activity and avoid connection interruption due to network or server timeouts. The content and format of the status information sent by the extension to the server are not limited in this embodiment.
[0067] S306: When the browser's state information changes, send a status information change notification to the server through the extension after the connection is established.
[0068] Optionally, after establishing a WebSocket connection with the server, the extension continuously monitors the browser's status information during data communication. When the browser's status information (such as login status) changes (e.g., switching from logged-in to logged-out), the extension captures this event and sends a status change notification to the server's WebSocket service port. Upon receiving the status change notification, the server analyzes and processes it through its integrated management platform, generating corresponding management policy information and / or message policy information, thereby enabling remote management of the browser.
[0069] S307: After establishing a connection, the extension program receives the connection status information of the WebSocket long connection and transmits the connection status information to the browser through a preset interface.
[0070] Optionally, while sending the browser's status information and status change notifications to the server's WebSocket service port, the extension can also feed back the WebSocket long-lived connection status information (such as data sending status, connection closing status, data receiving status, connection success status, connection failure status, etc.) to the browser through a preset interface. It is worth noting that this preset interface is a specific interface on the browser used to receive connection status information fed back by the extension, and it differs from the browser's listening API mentioned above.
[0071] S308: After establishing a connection, the extension receives management policy information for the browser from the server.
[0072] The management policy information includes at least one of the following: access permission policy information, resource usage policy information, and data encryption policy information. Specifically, access permission policy information defines the range of websites or resources a user can access through a browser. For example, a company may want to restrict employees' access to non-work-related websites or only allow access to specific internal services. In this case, access permission policy information may include a whitelist (a list of allowed websites) and a blacklist (a list of prohibited websites). Resource usage policy information is mainly used to control the browser's use of system resources (such as CPU and memory) to prevent individual web pages or plugins from excessively consuming resources and affecting system performance. For example, resource usage policy information may be used to restrict automatic video playback on the browser, control ad loading, and limit the resource consumption of background tabs. Data encryption policy information is mainly used to specify encryption standards and protocols for data transmission to ensure the security of sensitive information during transmission, such as requiring the use of TLS / SSL encrypted connections. For example, data encryption policy information may be used for selecting data encryption algorithms and managing keys.
[0073] Optionally, the management platform on the server sends at least one of the aforementioned access permission policy information, resource usage policy information, and data encryption policy information to the terminal 10 through an extension program that has established a WebSocket long connection. The terminal 10 receives the management policy information sent by the management platform through the extension program that has established the connection, so as to realize the server's remote management and control of the browser.
[0074] S309: Remotely manage and control the browser based on management policy information.
[0075] Remote management control includes at least one of access control, resource usage control, and data encryption control.
[0076] Understandably, after receiving at least one of the access permission policy information, resource usage policy information, and data encryption policy information issued by the management platform, terminal 10 will perform access permission control and / or resource usage control and / or data encryption control on the browser according to the received policy information. For example, if terminal 10 receives access permission policy information, it will restrict specific websites or resources that users can access according to the access permission policy information, which helps prevent data leakage or non-compliant network use. If terminal 10 receives resource usage policy information, it will restrict automatic video playback on the browser, control ad loading, and limit the resource consumption of background tabs, which helps optimize device performance and avoid excessive consumption of computing and network resources. If terminal 10 receives data encryption policy information, it will use the encryption standards and protocols specified in the data encryption policy information for data transmission, thereby ensuring the security of data transmission.
[0077] S310: After establishing a connection, the extension receives notification messages for the browser sent by the server.
[0078] The notification messages include at least one of the following: system update messages, service status change messages, and account activity warning messages. Specifically, system update messages are notifications sent when the integrated management platform on the server detects an update to an application on the browser, helping browser users stay informed about system updates. System update messages include, but are not limited to, the name of the updated application, the updated application version number, a summary of the update content, and a download link for the updated file. Service status change messages are notifications sent when the server detects a change in the browser's service status, helping browser users stay informed about the change. Service status change messages include, but are not limited to, the name of the changed service and the time of the service status change. Account activity warning messages are notifications sent when the integrated management platform on the server detects abnormal activity in a browser account, helping browser users identify potential security issues and take measures (such as changing passwords) to protect account security. Account activity warning messages include, but are not limited to, notifications for unauthorized login attempts, password changes, account modifications, and large transactions.
[0079] Optionally, the management platform on the server sends at least one of the above-mentioned system update messages, service status change messages, and account activity warning messages to the terminal 10 through the extension program after establishing a WebSocket long connection. The terminal 10 receives the notification messages sent by the management platform through the extension program after establishing the connection to prompt the user.
[0080] S311: Display notification messages in the browser interface.
[0081] Understandably, after terminal 10 receives at least one of the following messages from the management platform: system update message, service status change message, or account activity warning message, terminal 10 will display these notification messages on the browser interface to alert the user that the system has been updated and / or the service status has changed and / or account activity has become abnormal. For example, if terminal 10 receives a system update message, it will display the updated application name, the updated application version number, a summary of the update content, and a download link for the updated file on the browser interface. If terminal 10 receives a service status change message, it will display the changed service name and the time of the service status change on the browser interface. If terminal 10 receives an account activity warning message, it will display prompts for unauthorized login attempts, password changes, account modifications, and large transactions on the browser interface.
[0082] Please see Figure 4 This is a schematic diagram of the architecture corresponding to this embodiment. Data communication between the browser and the server is achieved through an extension layer. Specifically, the extension layer containing the extension program establishes a WebSocket long-lived connection with the corresponding server based on the target server address. During data communication, the extension layer simultaneously exposes the connection status information of the WebSocket long-lived connection (including data sending status information, data receiving status information, connection closing status information, connection success status information, connection failure status information, etc.) to both the browser and the server, enabling full-duplex communication between the browser and the server. Furthermore, the extension layer continuously monitors the browser's status information, reports the browser's status information to the server, and then sends the management policy information and message notification information issued by the server to the browser, realizing remote monitoring of the browser by the server.
[0083] In this embodiment, firstly, by using the WebSocket protocol, a persistent bidirectional communication channel can be established between the front-end browser and the back-end server. Once the WebSocket long connection is established, both the browser and the server can send data at any time without having to re-establish and disconnect the connection for each communication, unlike traditional HTTP requests. Secondly, by using a browser extension to establish a WebSocket long connection with the server, network environment restrictions can be bypassed by leveraging the extension's permissions, improving the flexibility and stability of communication. This also simplifies the interaction details between the browser and the server, reducing communication complexity. Thirdly, during data communication, both the browser and the server can receive the WebSocket long connection status information, allowing browser users and server administrators to promptly capture changes in the WebSocket connection status through the extension, ensuring the timeliness and reliability of communication. Fourthly, based on the strong extensibility of the extension, various capabilities for connecting to other business modules can be quickly added through the extension, such as reporting browser status information, sending messages to the management platform, and issuing policies to the management platform, thus improving the scalability of data communication.
[0084] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0085] Based on the inventive concept of the above data communication method, such as Figure 5 As shown in the illustration, this application also provides a data communication device 500 for implementing the data communication method described above. The data communication device 500 includes:
[0086] Module 501 is used to obtain the pre-configured target server address;
[0087] Connection module 502 is used to create a WebSocket long connection with the server corresponding to the target server address through the extension;
[0088] The communication module 503 is used to send browser status information to the server through the extension program after the connection is established; and to receive the connection status information of the WebSocket long connection through the extension program after the connection is established, and to transmit the connection status information to the browser through a preset interface.
[0089] In one embodiment, the communication module 503 is further configured to listen to the browser's status information through the extension after the connection is established; and if the browser's status information changes, send a status information change notification to the server through the extension after the connection is established.
[0090] In one embodiment, the communication module 503 is further configured to send browser status information to the server's WebSocket service port at preset time intervals via the extension program after the connection is established.
[0091] In one embodiment, the browser's state information includes at least one of the browser's application state information, browser's device state information, and browser's network connection state information.
[0092] In one embodiment, the connection module 502 is specifically used to send a handshake request to the server corresponding to the target server address through an extension program; if the response information contained in the handshake response of the server to the handshake request is verified, a WebSocket long connection with the server is established through the extension program.
[0093] In one embodiment, the communication module 503 is further configured to receive management policy information for the browser sent by the server through the extension program after the connection is established; the management policy information includes at least one of access permission policy information, resource usage policy information, and data encryption policy information; and to remotely manage and control the browser based on the management policy information.
[0094] In one embodiment, the communication module 503 is further configured to receive notification messages sent by the server to the browser through the extension program after the connection is established; the notification messages include at least one of system update messages, service status change messages, and account activity warning messages; and display the notification messages on the browser interface.
[0095] Each module in the aforementioned data communication device 500 can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0096] This application also provides an electronic device, which can be a terminal, and its internal structure diagram can be as follows: Figure 6 As shown, this electronic device includes a processor, memory, input / output interface, communication interface, display unit, and input device. The processor, memory, and input / output interface are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interface. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The input / output interface is used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a data communication method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the electronic device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the electronic device, or external keyboards, touchpads, or mice, etc.
[0097] Those skilled in the art will understand that Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the electronic device to which the present application is applied. The specific electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0098] In one possible implementation, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0099] Obtain the pre-configured target server address;
[0100] Establish a long-lived WebSocket connection with the server corresponding to the target server address through the extension;
[0101] After establishing a connection, the extension sends the browser's status information to the server; and
[0102] After the connection is established, the extension program receives the connection status information of the WebSocket long connection and transmits the connection status information to the browser through a preset interface.
[0103] In one possible implementation, the processor, while executing the computer program, also performs the following steps: listening to the browser's status information through the extension after establishing a connection; and sending a status information change notification to the server through the extension after establishing a connection if the browser's status information changes.
[0104] In one possible implementation, the processor, while executing the computer program, also performs the following steps: sending browser status information to the server's WebSocket service port at preset time intervals via an extension program that has established a connection.
[0105] In one possible implementation, the browser's state information includes at least one of the following: browser application state information, browser device state information, and browser network connection state information.
[0106] In one possible implementation, the processor, when executing the computer program, also performs the following steps: sending a handshake request to the server corresponding to the target server address via an extension program; and establishing a long-lived WebSocket connection with the server via the extension program if the response information contained in the server's handshake response to the handshake request is verified.
[0107] In one possible implementation, the processor, when executing the computer program, also performs the following steps: receiving management policy information for the browser from the server through an extension program after establishing a connection; the management policy information includes at least one of access permission policy information, resource usage policy information, and data encryption policy information; and remotely managing and controlling the browser based on the management policy information.
[0108] In one possible implementation, the processor, while executing the computer program, also performs the following steps: receiving notification messages for the browser from the server via an extension program after establishing a connection; the notification messages include at least one of system update messages, service status change messages, and account activity warning messages; and displaying the notification messages on the browser's interface.
[0109] This application also provides a computer storage medium storing instructions that, when run on a computer or processor, cause the computer or processor to perform one or more steps in the above embodiments. If the constituent modules of the above-described electronic device are implemented as software functional units and sold or used as independent products, they can be stored in the above-described computer-readable storage medium.
[0110] In one possible implementation, a computer storage medium is provided on which a computer program is stored, and when the computer program is executed by a processor, it performs the following steps:
[0111] Obtain the pre-configured target server address;
[0112] Establish a long-lived WebSocket connection with the server corresponding to the target server address through the extension;
[0113] After establishing a connection, the extension sends the browser's status information to the server; and
[0114] After the connection is established, the extension program receives the connection status information of the WebSocket long connection and transmits the connection status information to the browser through a preset interface.
[0115] In one possible implementation, when the computer program is executed by the processor, it also performs the following steps: listening to the browser's state information through the extension after establishing a connection; and sending a state information change notification to the server through the extension after establishing a connection if the browser's state information changes.
[0116] In one possible implementation, when the computer program is executed by the processor, it also performs the following steps: by establishing a connection through an extension program, it sends browser status information to the server's WebSocket service port at preset time intervals.
[0117] In one possible implementation, the browser's state information includes at least one of the following: browser application state information, browser device state information, and browser network connection state information.
[0118] In one possible implementation, when the computer program is executed by the processor, it also performs the following steps: sending a handshake request to the server corresponding to the target server address via an extension program; and establishing a long WebSocket connection with the server via the extension program if the response information contained in the handshake response to the handshake request is verified.
[0119] In one possible implementation, when the computer program is executed by the processor, it further performs the following steps: receiving management policy information for the browser from the server through the extension program after establishing a connection; the management policy information includes at least one of access permission policy information, resource usage policy information, and data encryption policy information; and remotely managing and controlling the browser based on the management policy information.
[0120] In one possible implementation, when the computer program is executed by the processor, it further performs the following steps: receiving notification messages for the browser from the server through the extension program after the connection is established; the notification messages include at least one of system update messages, service status change messages, and account activity warning messages; and displaying the notification messages on the browser's interface.
[0121] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer storage medium or transmitted through the computer storage medium. The computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., digital versatile discs (DVDs)), or semiconductor media (e.g., solid-state drives (SSDs)).
[0122] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks. Unless otherwise specified, the technical features of this embodiment and its implementation can be combined arbitrarily.
[0123] The embodiments described above are merely preferred embodiments of this application and are not intended to limit the scope of this application. Any modifications and improvements made by those skilled in the art to the technical solutions of this application without departing from the spirit of this application should fall within the protection scope defined by the claims.
[0124] The foregoing has described specific embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
Claims
1. A method of data communication, characterized by, The application is applied to a terminal, wherein the terminal is installed with a browser, and the browser is installed with an extension program; the method comprises the following steps: obtaining a target server address configured in advance; establishing a WebSocket long connection between the extension program and a server corresponding to the target server address; sending state information of the browser to the server through the connected extension program; and receiving connection state information of the WebSocket long connection through the connected extension program, and transmitting the connection state information to the browser through a preset interface.
2. The method of claim 1, wherein, The method further comprises the following steps: listening to the state information of the browser through the connected extension program; sending state information change prompt information to the server through the connected extension program in the case that the state information of the browser changes.
3. The method of claim 1, wherein, The step of sending the state information of the browser to the server through the connected extension program comprises the following step: sending the state information of the browser to a WebSocket service port of the server through the connected extension program at a preset time interval.
4. The method of any one of claims 1-3, wherein, The state information of the browser comprises at least one of application state information of the browser, device state information of the browser, and network connection state information of the browser.
5. The method of claim 1, wherein, The step of establishing the WebSocket long connection between the extension program and the server corresponding to the target server address comprises the following steps: sending a handshake request to the server corresponding to the target server address through the extension program; establishing the WebSocket long connection between the extension program and the server in the case that response information contained in a handshake response of the server to the handshake request is verified.
6. The method of claim 1, wherein, The method further comprises the following steps: receiving management policy information for the browser issued by the server through the connected extension program; the management policy information comprises at least one of access permission policy information, resource use policy information, and data encryption policy information; performing remote management control on the browser based on the management policy information.
7. The method of claim 1, wherein, The method further comprises the following steps: receiving notification message information for the browser issued by the server through the connected extension program; the notification message information comprises at least one of system update message information, service state change message information, and account activity warning message information; displaying the notification message information on an interface of the browser.
8. A data communication device, characterized by The application is applied to a terminal, wherein the terminal is installed with a browser, and the browser is installed with an extension program; the device comprises the following modules: an obtaining module, configured to obtain a target server address configured in advance; a connection module, configured to establish a WebSocket long connection between the extension program and a server corresponding to the target server address; The communication module is configured to send state information of the browser to the server through the extension program after the connection is established, and receive connection state information of the WebSocket long connection through the extension program after the connection is established, and transmit the connection state information to the browser through a preset interface.
9. An electronic device, comprising: The method comprises the following steps: The processor and the memory; the memory stores a computer program, and the processor realizes the method steps of any one of claims 1-7 when executing the computer program.
10. A computer storage medium, characterized in that, The computer storage medium stores a plurality of instructions, and the instructions are suitable for being loaded and executed by the processor to perform the method steps of any one of claims 1-7.