CN112417355A - Data interaction method, device and equipment based on long-connection single channel and storage medium - Google Patents

Data interaction method, device and equipment based on long-connection single channel and storage medium Download PDF

Info

Publication number
CN112417355A
CN112417355A CN202011363619.0A CN202011363619A CN112417355A CN 112417355 A CN112417355 A CN 112417355A CN 202011363619 A CN202011363619 A CN 202011363619A CN 112417355 A CN112417355 A CN 112417355A
Authority
CN
China
Prior art keywords
domain
data
server
request
data interaction
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202011363619.0A
Other languages
Chinese (zh)
Other versions
CN112417355B (en
Inventor
罗伟东
李攀
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Hexun Huagu Information Technology Co ltd
Original Assignee
Shenzhen Hexun Huagu Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Hexun Huagu Information Technology Co ltd filed Critical Shenzhen Hexun Huagu Information Technology Co ltd
Priority to CN202011363619.0A priority Critical patent/CN112417355B/en
Publication of CN112417355A publication Critical patent/CN112417355A/en
Application granted granted Critical
Publication of CN112417355B publication Critical patent/CN112417355B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention discloses a data interaction method, a device, equipment and a storage medium based on a long connection single channel, wherein the method comprises the steps of receiving a data interaction request, and determining a request source corresponding to the data interaction request according to a target domain name and a target webpage identifier; if the request source corresponding to the data interaction request is a cross-domain sub-web page, and the cross-domain sub-web page is mounted under the domain name main web page through an inline frame, inquiring a same-domain data sharing library corresponding to the domain name main web page according to the interaction information, and judging whether the same-domain data sharing library stores feedback data corresponding to the interaction information; and if the same-domain data sharing library does not store feedback data, sending a data interaction request to the server through a long connection single channel between the domain name main webpage and the server, receiving feedback data corresponding to interaction information returned by the server, storing the feedback data and the target webpage identification in the same-domain data sharing library in an associated manner, and performing data interaction on the cross-domain sub-webpage and the same-domain data sharing library through the inline frame.

Description

Data interaction method, device and equipment based on long-connection single channel and storage medium
Technical Field
The invention relates to the technical field of computers, in particular to a data interaction method, a data interaction device, data interaction equipment and a data interaction storage medium based on a long connection single channel.
Background
If information needs to be interacted between a webpage of a browser and a server in real time, a long connection single channel needs to be established between the webpage and the server so as to achieve the purpose of information interaction.
However, when multiple cross-domain webpages exist in the browser, each cross-domain webpage establishes a long connection single channel with the server, so that the server needs to maintain multiple long connection single channels, the maintenance cost is high, and the server is burdened by the multiple long connection single channels due to the fact that the multiple long connection single channels occupy server resources, and the interaction performance is affected; and the problem that part of cross-domain web pages cannot interact with the server in real time due to the fact that part of long connection single channels cannot work normally.
Disclosure of Invention
The embodiment of the invention provides a data interaction method, a data interaction device, computer equipment and a storage medium based on a long connection single channel, and aims to solve the problem that a plurality of cross-domain webpages exist in a browser.
A data interaction method based on a long connection single channel comprises the following steps:
receiving a data interaction request, wherein the data interaction request comprises a target domain name, a target webpage identifier, a server identifier and interaction information;
determining a request source corresponding to the data interaction request according to the target domain name and the target webpage identifier;
if the request source corresponding to the data interaction request is a cross-domain sub-web page mounted under a domain name main web page through an inline frame, inquiring a same-domain data sharing library according to the interaction information, and judging whether the same-domain data sharing library stores feedback data corresponding to the interaction information;
and if the co-domain data sharing library does not store the feedback data, sending the data interaction request to a server through a long connection single channel between the domain name main webpage and the server, receiving feedback data corresponding to the interaction information returned by the server, and storing the feedback data and the target webpage identification in the co-domain data sharing library in an associated manner.
A data interaction device based on a long connection single channel comprises:
the data interaction request receiving module is used for receiving a data interaction request, wherein the data interaction request comprises a target domain name, a target webpage identifier, a server identifier and interaction information;
a request source determining module, configured to determine a request source corresponding to the data interaction request according to the target domain name and the target webpage identifier;
the judging module is used for inquiring a same-domain data sharing library corresponding to the domain name main webpage according to the interaction information and judging whether the same-domain data sharing library stores feedback data corresponding to the interaction information or not if a request source corresponding to the data interaction request is a cross-domain sub-webpage which is mounted under the domain name main webpage through an inline frame;
and the first processing module is used for sending the data interaction request to a server through a long connection single channel between the domain name main webpage and the server if the same-domain data sharing library does not store the feedback data, receiving the feedback data corresponding to the interaction information returned by the server, storing the feedback data and the target webpage identifier in the same-domain data sharing library in an associated manner, and performing data interaction on the cross-domain sub-webpage and the same-domain data sharing library through the inline frame.
A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the long connection single channel-based data interaction method when executing the computer program.
A computer-readable storage medium, which stores a computer program that, when being executed by a processor, implements the steps of the above-mentioned long-connection single-channel-based data interaction method.
According to the data interaction method, the data interaction device, the computer equipment and the storage medium based on the long connection single channel, the request source corresponding to the data interaction request is determined according to the target domain name and the target webpage identification, a corresponding mode is selected for subsequent data interaction, resources are reasonably distributed, and resource waste is avoided. And if the request source corresponding to the data interaction request is a cross-domain sub-webpage mounted under the domain name main webpage through the inline frame, inquiring the same-domain data sharing library according to the interaction information, and judging whether the same-domain data sharing library stores feedback data corresponding to the interaction information or not, so that the resources are reasonably utilized, and the resource waste is avoided. And if the same-domain data sharing library does not store feedback data, sending a data interaction request to the server through a long connection single channel between the domain name main webpage and the server, receiving feedback data corresponding to interaction information returned by the server, and storing the feedback data and the target webpage identifier into the same-domain data sharing library in an associated manner so as to search feedback data corresponding to the domain name sub-webpage corresponding to the target webpage identifier quickly and later. And if the request source corresponding to the data interaction request is the same-domain sub-web page, sending the data interaction request to the server through a long connection single channel between the domain name main web page and the server, receiving feedback data corresponding to the interaction information returned by the server, and sending the feedback data to the same-domain sub-web page, so that the data interaction of the domain name main web page, the same-domain sub-web page and the cross-domain sub-web page with the server is realized only through one long connection single channel, and the smoothness of the data interaction is ensured.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
FIG. 1 is a schematic diagram of an application environment of a data interaction method for a long connection single channel according to an embodiment of the present invention;
FIG. 2 is a flow chart of a data interaction method for a long connection single channel according to an embodiment of the present invention;
FIG. 3 is another flow chart of a method for data interaction with a long connection single channel according to an embodiment of the invention;
FIG. 4 is another flow chart of a method for data interaction with a long connection single channel in an embodiment of the invention;
FIG. 5 is another flow chart of a method for data interaction with a long connection single channel in an embodiment of the invention;
FIG. 6 is a schematic block diagram of a data interaction apparatus with a long connection single channel according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of a computer device according to an embodiment of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The invention provides a data interaction method based on a long connection single channel, which can be applied to an application environment shown in figure 1. Specifically, the data interaction method based on the long connection single channel is applied to a data interaction system based on the long connection single channel, the data interaction system based on the long connection single channel comprises a browser and a server which are shown in fig. 1, the browser and the server communicate through a network, the browser comprises a domain name main web page and a domain name sub web page connected with the domain name main web page, and the domain name sub web page comprises a same-domain sub web page and a cross-domain sub web page mounted under the domain name main web page through an inline frame. The data interaction method based on the long connection single channel is used for realizing data interaction between the domain name main web page, the same-domain sub web page and the cross-domain sub web page and the server only through the long connection single channel, so that the smoothness of the data interaction is ensured, the cost for maintaining the long connection single channel by the server is reduced, and the pressure of the server is relieved. Wherein the browser may be installed on, but not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server may be implemented as a stand-alone server or as a server cluster of multiple servers.
The domain name main web page is a web page used for creating a long connection single channel with a server.
The sub-web page in the same domain is the same web page as the domain name, port and protocol of the main web page in the domain name. The domain name, also called network domain, is the name of a certain computer or computer group on the Internet composed of a string of names separated by points, and is used for positioning and identifying the computer during data transmission.
The cross-domain sub-web page is a web page with at least one of a domain name, a port and a protocol different from a domain name main web page, the cross-domain sub-web page is mounted in the domain name main web page through an inline frame, due to a homologous policy of a browser, direct interaction between two cross-domain web pages cannot be performed, and in the embodiment, the cross-domain sub-web page is mounted in the domain name main web page through the inline frame so as to realize interaction between each cross-domain sub-web page and the domain name main web page. The inline frame is an iframe and is used for embedding another page in one page, and the inline frame is used for embedding a plurality of cross-domain sub-web pages in a domain name main web page in the embodiment.
In an embodiment, as shown in fig. 2, a data interaction method based on a long connection single channel is provided, which is described by taking the browser in fig. 1 as an example, and includes the following steps:
s201: and receiving a data interaction request, wherein the data interaction request comprises a target domain name, a target webpage identifier, a server identifier and interaction information.
The data interaction request is a request which is sent by the domain name sub-web page to the domain name main web page and wants to perform data interaction with the server, and the data interaction request can be a request for querying data and the like.
The target domain name refers to a domain name corresponding to the domain name sub-web page. The target webpage identifier is an identifier for uniquely identifying the domain name sub-webpage, and it can be understood that the target domain name and the target webpage identifier in the same data interaction request can uniquely point to the same domain name sub-webpage. In this example, the domain name sub-web page includes a same-domain sub-web page and a cross-domain sub-web page mounted under the domain name main web page through an inline frame.
The server identifier is an identifier for uniquely identifying a server to be accessed, and in this embodiment, the server identifier is a server address. The interaction information is information that the domain name subnet page wants to perform data interaction with the server.
S202: and determining a request source corresponding to the data interaction request according to the target domain name and the target webpage identifier.
The request source is used for identifying a sub-web page for sending a data interaction request to a domain name main web page. The browser determines the domain name sub-web page uniquely pointed by the browser according to the target domain name and the target web page identification, and further determines the request source, namely determines whether the domain name sub-web page sending the data interaction request is a cross-domain sub-web page or a same-domain sub-web page, and selects a corresponding mode for subsequent data interaction so as to reasonably distribute resources and avoid resource waste.
S203: and if the request source corresponding to the data interaction request is a cross-domain sub-web page, and the cross-domain sub-web page is mounted under the domain name main web page through the inline frame, querying the same-domain data sharing library according to the interaction information, and judging whether the same-domain data sharing library stores feedback data corresponding to the interaction information.
The feedback data refers to data which is determined according to the interactive information and needs to be fed back to the target domain name and the domain name sub-web page corresponding to the target web page identifier.
The shared-domain data library is a library for storing data locally by a domain name main webpage, and can be used for storing Local Storage, Session, cookie and the like.
In this embodiment, the domain name main web page queries the domain name data sharing library according to the interaction information, determines whether the domain name data sharing library stores feedback data corresponding to the interaction information according to the target web page identifier, and if the domain name data sharing library stores the feedback data corresponding to the interaction information, the feedback data can be directly acquired, and the feedback data is sent to the domain name sub-web page through the inline frame, so that resources are reasonably utilized, and resource waste is avoided.
S204: and if the same-domain data sharing library does not store feedback data, sending a data interaction request to the server through a long connection single channel between the domain name main webpage and the server, receiving feedback data corresponding to interaction information returned by the server, storing the feedback data and the target webpage identification in the same-domain data sharing library in an associated manner, and performing data interaction on the cross-domain sub-webpage and the same-domain data sharing library through the inline frame.
The long connection single channel is a channel for data interaction between the domain name main webpage and the server. That is to say, the domain name main web page carries out data interaction with the server through a long connection single channel, the same domain sub-web page and the cross domain sub-web page carry out data interaction with the domain name main web page through the inline frame, the server and the domain name main web page can be realized through the long connection single channel and the inline frame, the data interaction between the cross domain sub-web page and the domain name main web page can be realized, namely, the interaction between the server and the browser can be realized through a long connection single channel, only one long connection single channel needs to be maintained in the process of carrying out data interaction between the server and the browser, the channel maintenance is convenient and fast, the channel maintenance cost is effectively reduced, and the domain name main web page and the server can. The problem of among the prior art, when the browser opened the webpage in a plurality of different domains, the webpage all established long connection single channel with the server, because the long connection single channel quantity between webpage and the server is limited, when long connection single channel quantity exceeded when predetermineeing the quantity, then the partial webpage can't carry out data interaction with the server, leads to data interaction to break off is solved.
In this embodiment, if the data sharing library in the same domain does not store feedback data, the data interaction request is sent to the server through a long connection single channel between the main web page of the domain name and the server, and the feedback data corresponding to the interaction information returned by the server is received, so that smooth data interaction between the main web page of the domain name and the cross-domain sub-web page of the domain name and the server can be ensured through a long connection single channel. And storing the feedback data and the target webpage identification into a same-domain data sharing library in an associated manner so as to search the feedback data corresponding to the domain name subnet page corresponding to the target webpage identification in a subsequent and rapid manner.
Furthermore, when the response time of the data interaction request is longer than the preset time, namely the data interaction request is abnormal, whether the abnormal condition occurs in a long connection single channel or not is judged, if the abnormal condition occurs in the long connection single channel, the long polling is called recursively, a new long connection single channel is established between the domain name main web page and the server so as to continue the data interaction request, and the server and the domain name main web page are ensured to establish only one long connection single channel to realize the smooth operation of the data interaction request, so that the maintenance cost of the server is saved, and resources are reasonably utilized.
As an example, a preset response duration is preset, when the duration of receiving the data interaction request by the domain name main web page is not less than the preset response duration, that is, the data interaction request is overtime, at this time, an abnormal condition occurs in the data interaction request, whether an abnormal condition occurs in a long connection single channel is judged, and when an abnormal condition occurs in a long connection single channel, long polling is called through recursion, so that a long connection single channel is created between the domain name main web page and the server. The preset duration is a preset duration.
S205: and if the request source corresponding to the data interaction request is the same-domain sub-web page, sending the data interaction request to the server through a long connection single channel between the domain name main web page and the server, receiving feedback data corresponding to the interaction information returned by the server, and sending the feedback data to the same-domain sub-web page according to the target web page identifier.
In this embodiment, when the request source corresponding to the data interaction request is the same-domain sub-web page, the long connection single channel is directly used for data interaction, so that the domain name main web page, the same-domain sub-web page and the cross-domain sub-web page perform data interaction with the server only through one long connection single channel, and the smoothness of the data interaction is ensured.
According to the data interaction method based on the long connection single channel, the request source corresponding to the data interaction request is determined according to the target domain name and the target webpage identifier, a corresponding mode is selected for subsequent data interaction, resources are reasonably distributed, and resource waste is avoided. And if the request source corresponding to the data interaction request is a cross-domain sub-webpage mounted under the domain name main webpage through the inline frame, inquiring the same-domain data sharing library according to the interaction information, and judging whether the same-domain data sharing library stores feedback data corresponding to the interaction information or not, so that the resources are reasonably utilized, and the resource waste is avoided. And if the same-domain data sharing library does not store feedback data, sending a data interaction request to the server through a long connection single channel between the domain name main webpage and the server, receiving feedback data corresponding to interaction information returned by the server, and storing the feedback data and the target webpage identifier into the same-domain data sharing library in an associated manner so as to search feedback data corresponding to the domain name sub-webpage corresponding to the target webpage identifier quickly and later. If the request source corresponding to the data interaction request is the same-domain sub-web page, the data interaction request is sent to the server through a long connection single channel between the domain name main web page and the server, feedback data corresponding to the interaction information returned by the server is received, and the feedback data is sent to the same-domain sub-web page according to the target web page identification, so that data interaction of the domain name main web page, the same-domain sub-web page and the cross-domain sub-web page with the server is realized through only one long connection single channel, and the smoothness of the data interaction is ensured.
In an embodiment, as shown in fig. 3, before step S201, that is, before receiving the data interaction request, the data interaction method based on the long connection single channel further includes:
s301: and receiving a connection request, and sending the connection request to a server, wherein the connection request comprises a target domain name and a server website.
The connection request is a request which is sent from the domain name sub-webpage to the domain name main webpage and is required to perform data interaction with the server. For example, the data interaction may be a data query or the like.
The target domain name is a domain name indicating a domain name corresponding to the main web page so that the main web page receives the connection request. The server address, i.e. the IP address of the server, can be understood as an internet protocol address, so that the domain name main web page determines the address of the server where the domain name sub-web page wants to perform data interaction. It should be noted that the target domain name and the server website are in the same domain, so as to ensure that the main web page of the domain name and the server can smoothly establish a long connection single channel, and ensure that the main web page of the subsequent domain name and the server can perform data interaction.
Specifically, when the domain name sub-web page wants to perform data interaction with the server, the domain name sub-web page sends a request for connection to the domain name main web page. And when the domain name main web page receives the connection request, inquiring the same-domain data sharing library to judge whether the same-domain data sharing library has a connection success identifier. And if the data sharing library in the same domain does not have the connection success identification, the browser does not establish long connection with the server. At the moment, the domain name main webpage generates a connection request sending server, and provides technical support for subsequently creating a long connection single channel.
S302: and if response information fed back by the server is received within preset response time, creating a long connection single channel between the domain name main webpage corresponding to the target domain name and the server corresponding to the server website, generating a connection success identifier, and storing the connection success identifier in the same-domain data sharing library.
The preset response time is preset, and the server responds to the connection request time, so that the domain name main webpage can determine whether the connection with the server is successful.
The response information is information for indicating that the domain name main web page successfully creates the long connection single channel.
The connection success identification is an identification which represents that the domain name main webpage successfully creates a long connection single channel with the server. The connection success identification is stored in a same-domain data sharing library in the domain name main webpage, and each cross-domain sub-webpage is mounted under the domain name main webpage through an inline frame, so that each cross-domain sub-webpage can access the same-domain data sharing library of the domain name main webpage, and when the cross-domain sub-webpage wants to perform data interaction with a server, the same-domain data sharing library of the domain name main webpage is inquired firstly to determine whether the connection success identification exists in the same-domain data sharing library. When the connection success identification does not exist in the same-domain data sharing library, the fact that the domain name main web page does not establish a long connection single channel with the server is shown, at the moment, the cross-domain sub-web page stores feedback data needing data interaction in the same-domain data sharing library, the cross-domain main web page regularly checks whether the feedback data are stored in the same-domain data sharing library, and when the feedback data are stored, the feedback data are sent to the server according to the target web page identification corresponding to the feedback data to obtain the feedback data. When the connection success identification does not exist in the same-domain data sharing library, the fact that the domain name main web page does not establish a long connection single channel with the server is indicated, at the moment, the cross-domain sub-web page sends a connection request to the domain name main web page, the domain name main web page receives the connection request and sends the connection request to the server so as to establish a long connection single channel between the domain name main web page corresponding to the target domain name and the server corresponding to the server website, data interaction between the domain name main web page, the same-domain sub-web page and the cross-domain sub-web page and the server only through one long connection single channel is achieved, the smoothness of data interaction is guaranteed, the cost of maintaining the long connection single channel by the server is.
As an example, the cross-domain sub-web page 1 wants to interact with the server for data. The cross-domain sub-web page 1 sends a connection request to the domain name main web page so as to establish a long connection single channel between the domain name main web page and the server, and the connection success identifier is stored in the same-domain data sharing library of the domain name main web page. When the cross-domain sub-web page 2 also wants to perform data interaction with the server, the cross-domain sub-web page 2 checks the shared database of the same domain data of the main web page of the domain name through the inline frame. Since the cross-domain sub-web page 1 and the cross-domain sub-web page 2 are mounted on the same domain name main web page, the cross-domain sub-web page 1 and the cross-domain sub-web page 2 share the same domain name data sharing library of the domain name main web page, so that the inline frame of the web page 2 can detect the identifier of the inline frame of the web page 1 in the same domain name data sharing library, which establishes the long connection and stores the long connection into the same domain name data sharing library. The cross-domain sub-web page 2 does not cause the domain name main web page to establish a long connection single channel with the server.
According to the data interaction method based on the long connection single channel, response information fed back by a server is received within preset response time, the long connection single channel between a domain name main web page corresponding to a target domain name and the server corresponding to a server website is created, a connection success identifier is generated, the connection success identifier is stored in a same-domain data sharing library, the long connection single channel between the domain name main web page corresponding to the target domain name and the server corresponding to the server website is created, data interaction between the domain name main web page, the same-domain sub-web page and a cross-domain sub-web page is achieved only through one long connection single channel and the server, the smoothness of data interaction is guaranteed, the cost for maintaining the long connection single channel by the server is reduced, and the pressure of the server is relieved.
In an embodiment, as shown in fig. 4, after step S301, that is, after receiving the connection request, the data interaction method based on the long connection single channel further includes.
S401: and inquiring the same-domain data sharing library based on the connection request, and judging whether a connection success identifier exists in the same-domain data sharing library.
S402: and if the connection success identification does not exist in the data sharing library of the same domain, executing to send the connection request to the server.
In the data interaction method based on the long connection single channel provided by this embodiment, the co-domain data sharing library is queried in advance, whether a connection success identifier exists in the co-domain data sharing library is judged, and the connection request is sent to the server only when the connection success identifier does not exist in the co-domain data sharing library, so that it is ensured that only one long connection single channel is established between the domain name main webpage and the server, the pressure of the server is reduced, and it is ensured that subsequent data interaction can be performed smoothly.
In one embodiment, as shown in fig. 5, step S205, sending a data interaction request to a server through a long connection single channel between a domain name main webpage and the server, includes:
s501: and establishing a timing detection mechanism, wherein the timing detection mechanism comprises a detection interval duration.
The timing detection mechanism refers to a mechanism for regularly detecting a data shared library in the same domain by a main webpage of a domain name.
The detection interval duration is the duration of two adjacent timing detection intervals, for example, the detection interval duration may be 0.2 seconds, that is, the domain name main web page queries the shared database of the same domain data every 0.2 seconds. It should be noted that the detection interval duration is less than the preset duration.
S502: and automatically inquiring the same-domain data sharing library according to the detection duration, and judging whether the same-domain data sharing library has a data interaction request.
In this embodiment, the domain name main web page automatically queries the same-domain data sharing library of the domain name main web page according to the detection duration, for example, the domain name main web page may query the same-domain data sharing library every 0.2 seconds, and check whether to store the data interaction request sent by the domain name sub-web page, so as to process the data interaction request in time.
S503: and if the same-domain data sharing stock is in the data interaction request, sending the interaction information of the data interaction request to the server through a long connection single channel.
In this embodiment, when the data sharing inventory in the same domain is in the data interaction request, the interaction information of the data interaction request is sent to the server through the long connection single channel, so that smooth interaction between different webpages and the server is ensured.
The data interaction method based on the long-connection single channel provided by the embodiment establishes a timing detection mechanism, and the timing detection mechanism comprises detection interval duration. And automatically inquiring the same-domain data sharing library at regular time according to the detection duration, and judging whether the same-domain data sharing library has a data interaction request. And if the same-domain data sharing stock is in the data interaction request, sending the interaction information of the data interaction request to a server through a long connection single channel so as to process the data interaction request in time.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
In an embodiment, a data interaction device based on a long connection single channel is provided, and the data interaction device based on the long connection single channel corresponds to the data interaction method based on the long connection single channel in the above embodiment one to one. As shown in fig. 6, the data interaction apparatus based on the long connection single channel includes a data interaction request receiving module 601, a request source determining module 602, a determining module 603, a first processing module 604, and a second processing module 605. The functional modules are explained in detail as follows:
the data interaction request receiving module 601 is configured to receive a data interaction request, where the data interaction request includes a target domain name, a target webpage identifier, a server identifier, and interaction information.
The request source determining module 602 is configured to determine a request source corresponding to the data interaction request according to the target domain name and the target webpage identifier.
The determining module 603 is configured to, if a request source corresponding to the data interaction request is a cross-domain sub-web page, and the cross-domain sub-web page is mounted under the domain name main web page through an inline frame, query a co-domain data sharing library corresponding to the domain name main web page according to the interaction information, and determine whether the co-domain data sharing library stores feedback data corresponding to the interaction information.
The first processing module 604 is configured to send a data interaction request to the server through a long connection single channel between the domain name main web page and the server if the same-domain data sharing library does not store feedback data, receive feedback data corresponding to interaction information returned by the server, store the feedback data and the target web page identifier in the same-domain data sharing library in an associated manner, and perform data interaction on the cross-domain sub-web page and the same-domain data sharing library through the inline frame.
The second processing module 605 is configured to, if a request source corresponding to the data interaction request is a co-domain sub-web page, send the data interaction request to the server through a long connection single channel between the domain name main web page and the server, receive feedback data corresponding to the interaction information returned by the server, and send the feedback data to the co-domain sub-web page.
Preferably, before the data interaction request receiving module 601, the data interaction apparatus based on the long connection single channel further includes: a connection request receiving module and a long connection single channel creating module.
And the connection request receiving module is used for receiving a connection request and sending the connection request to the server, wherein the connection request comprises a target domain name and a server website.
And the long connection single channel creating module is used for creating a long connection single channel between the domain name main webpage corresponding to the target domain name and the server corresponding to the server website if response information fed back by the server is received within preset response time, generating a connection success identifier, and storing the connection success identifier in the same-domain data sharing library.
Preferably, after the connection request receiving module, the data interaction device based on the long connection single channel further comprises. The device comprises a query module and an execution module.
And the query module is used for querying the same-domain data sharing library based on the connection request and judging whether the connection success identification exists in the same-domain data sharing library.
And the execution module is used for executing the sending of the connection request to the server if the connection success identification does not exist in the data sharing library of the same domain.
Preferably, the first processing module 604 or the second processing module 605 includes: the device comprises a timing detection mechanism establishing unit, an automatic query unit and an interactive information sending unit.
And the timing detection mechanism establishing unit is used for establishing a timing detection mechanism, and the timing detection mechanism comprises a detection interval duration.
And the automatic query unit is used for automatically querying the same-domain data sharing library according to the detection duration and judging whether the same-domain data sharing library has a data interaction request.
And the interactive information sending unit is used for sending the interactive information of the data interaction request to the server through the long connection single channel if the same-domain data sharing stock is in the data interaction request.
For specific definition of the data interaction device based on the long connection single channel, refer to the above definition of the data interaction method based on the long connection single channel, and are not described herein again. The modules in the data interaction device based on the long connection single channel can be wholly or partially realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independently established in a processor in the computer equipment, and can also be stored in a memory in the computer equipment in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 7. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing interaction information. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a data interaction method based on a long connected single channel.
In an embodiment, a computer device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the steps of the data interaction method based on the long connection single channel in the foregoing embodiments are implemented, for example, steps S201 to S205 shown in fig. 2 or steps shown in fig. 3 to fig. 5, which are not described herein again to avoid repetition. Alternatively, when executing the computer program, the processor implements functions of each module/unit in the data interaction device based on the long connection single channel, for example, functions of the data interaction request receiving module 601, the request source determining module 602, the determining module 603, the first processing module 604, and the second processing module 605 shown in fig. 6, which are not described herein again to avoid repetition.
In an embodiment, a computer-readable storage medium is provided, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the data interaction method based on a long connection single channel in the foregoing embodiments are implemented, for example, steps S201 to S205 shown in fig. 2 or steps shown in fig. 3 to fig. 5, and are not described herein again to avoid repetition. Alternatively, when executing the computer program, the processor implements functions of each module/unit in the data interaction device based on the long connection single channel, for example, functions of the data interaction request receiving module 601, the request source determining module 602, the determining module 603, the first processing module 604, and the second processing module 605 shown in fig. 6, which are not described herein again to avoid repetition.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (10)

1. A data interaction method based on a long connection single channel is characterized by comprising the following steps executed by a browser:
receiving a data interaction request, wherein the data interaction request comprises a target domain name, a target webpage identifier, a server identifier and interaction information;
determining a request source corresponding to the data interaction request according to the target domain name and the target webpage identifier;
if the request source corresponding to the data interaction request is a cross-domain sub-web page, and the cross-domain sub-web page is mounted under a domain name main web page through an inline frame, inquiring a same-domain data sharing library corresponding to the domain name main web page according to the interaction information, and judging whether the same-domain data sharing library stores feedback data corresponding to the interaction information;
and if the same-domain data sharing library does not store the feedback data, sending the data interaction request to a server through a long connection single channel between the domain name main webpage and the server, receiving feedback data corresponding to the interaction information returned by the server, storing the feedback data and the target webpage identification into the same-domain data sharing library in an associated manner, and performing data interaction on the cross-domain sub-webpage and the same-domain data sharing library through the inline frame.
2. The long connection single channel-based data interaction method of claim 1, wherein after the determining the request source corresponding to the data interaction request, the long connection single channel-based data interaction method further comprises:
and if the request source corresponding to the data interaction request is a co-domain sub-webpage, sending the data interaction request to a server through a long connection single channel between the domain name main webpage and the server, receiving feedback data corresponding to the interaction information returned by the server, and sending the feedback data to the co-domain sub-webpage according to a target webpage identifier.
3. The long connection single channel-based data interaction method of claim 1, wherein before the receiving the data interaction request, the long connection single channel-based data interaction method further comprises:
receiving a connection request, and sending the connection request to a server, wherein the connection request comprises a target domain name and a server website;
and if response information fed back by the server is received within preset response time, creating a long connection single channel between the domain name main webpage corresponding to the target domain name and the server corresponding to the server website, generating a connection success identifier, and storing the connection success identifier in a same-domain data sharing library.
4. The long connection single channel-based data interaction method of claim 3, wherein after receiving the connection request, the long connection single channel-based data interaction method further comprises;
inquiring a same-domain data sharing library based on the connection request, and judging whether a connection success identifier exists in the same-domain data sharing library;
and if the connection success identification does not exist in the data sharing library of the same domain, executing the connection request to be sent to the server.
5. The data interaction method based on the long connection single channel of claim 1 or 2, wherein the sending the data interaction request to a server through the long connection single channel between the domain name main webpage and the server comprises:
establishing a timing detection mechanism, wherein the timing detection mechanism comprises a detection interval duration;
automatically inquiring a same-domain data sharing library according to the detection duration, and judging whether the same-domain data sharing library has the data interaction request;
and if the same-domain data sharing inventory is in the data interaction request, sending interaction information of the data interaction request to a server through a long connection single channel.
6. A data interaction device based on a long connection single channel is characterized by comprising:
the data interaction request receiving module is used for receiving a data interaction request, wherein the data interaction request comprises a target domain name, a target webpage identifier, a server identifier and interaction information;
a request source determining module, configured to determine a request source corresponding to the data interaction request according to the target domain name and the target webpage identifier;
the judging module is used for inquiring a same-domain data sharing library corresponding to the domain name main webpage according to the interaction information and judging whether the same-domain data sharing library stores feedback data corresponding to the interaction information or not if a request source corresponding to the data interaction request is a cross-domain sub-webpage which is mounted under the domain name main webpage through an inline frame;
and the first processing module is used for sending the data interaction request to a server through a long connection single channel between the domain name main webpage and the server if the same-domain data sharing library does not store the feedback data, receiving the feedback data corresponding to the interaction information returned by the server, storing the feedback data and the target webpage identifier in the same-domain data sharing library in an associated manner, and performing data interaction on the cross-domain sub-webpage and the same-domain data sharing library through the inline frame.
7. The apparatus for data interaction based on long connection single channel of claim 6, wherein after the determining module, the apparatus for data interaction based on long connection single channel further comprises:
and the second processing module is used for sending the data interaction request to a server through a long connection single channel between the domain name main webpage and the server if the request source corresponding to the data interaction request is a sub-webpage in the same domain, receiving feedback data corresponding to the interaction information returned by the server, and sending the feedback data to the sub-webpage in the same domain.
8. The apparatus for data interaction based on long connection single channel of claim 6, wherein before the data interaction request receiving module, the apparatus for data interaction based on long connection single channel further comprises:
the connection request receiving module is used for receiving a connection request and sending the connection request to a server, wherein the connection request comprises a target domain name and a server website;
and the long connection single channel creating module is used for creating a long connection single channel between the domain name main webpage corresponding to the target domain name and the server corresponding to the server website if response information fed back by the server is received within preset response time, generating a connection success identifier, and storing the connection success identifier in a same-domain data sharing library.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor when executing the computer program implements the steps of the long connection single channel based data interaction method according to any one of claims 1 to 5.
10. A computer-readable storage medium, in which a computer program is stored, which, when being executed by a processor, carries out the steps of the long connection single channel-based data interaction method according to any one of claims 1 to 5.
CN202011363619.0A 2020-11-27 2020-11-27 Data interaction method, device, equipment and storage medium based on long connection single channel Active CN112417355B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011363619.0A CN112417355B (en) 2020-11-27 2020-11-27 Data interaction method, device, equipment and storage medium based on long connection single channel

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011363619.0A CN112417355B (en) 2020-11-27 2020-11-27 Data interaction method, device, equipment and storage medium based on long connection single channel

Publications (2)

Publication Number Publication Date
CN112417355A true CN112417355A (en) 2021-02-26
CN112417355B CN112417355B (en) 2023-09-05

Family

ID=74842969

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011363619.0A Active CN112417355B (en) 2020-11-27 2020-11-27 Data interaction method, device, equipment and storage medium based on long connection single channel

Country Status (1)

Country Link
CN (1) CN112417355B (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100281107A1 (en) * 2009-05-01 2010-11-04 Fallows John R Enterprise client-server system and methods of providing web application support through distributed emulation of websocket communications
CN104572263A (en) * 2014-12-30 2015-04-29 腾讯科技(深圳)有限公司 Page data interaction method, related device and system
WO2017101694A1 (en) * 2015-12-15 2017-06-22 广州市动景计算机科技有限公司 Web page display method and apparatus, and server
CN108282455A (en) * 2017-09-28 2018-07-13 广州市动景计算机科技有限公司 Web-page requests method, apparatus and domain-name information analysis result processing method, device
CN108833585A (en) * 2018-07-03 2018-11-16 北京小米移动软件有限公司 Information interacting method, device and storage medium
WO2019019493A1 (en) * 2017-07-28 2019-01-31 平安科技(深圳)有限公司 Data sharing method and device, and computer readable storage medium
US20190297122A1 (en) * 2008-11-26 2019-09-26 David Harrison Relevancy improvement through targeting of information based on data gathered from a networked device associated with a security sandbox of a client device
US20200268260A1 (en) * 2019-02-26 2020-08-27 Bao Tran Hearing and monitoring system
CN111666514A (en) * 2020-04-28 2020-09-15 平安科技(深圳)有限公司 Data processing method and device for realizing cross-domain request at webpage end and related equipment

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190297122A1 (en) * 2008-11-26 2019-09-26 David Harrison Relevancy improvement through targeting of information based on data gathered from a networked device associated with a security sandbox of a client device
US20100281107A1 (en) * 2009-05-01 2010-11-04 Fallows John R Enterprise client-server system and methods of providing web application support through distributed emulation of websocket communications
CN104572263A (en) * 2014-12-30 2015-04-29 腾讯科技(深圳)有限公司 Page data interaction method, related device and system
WO2017101694A1 (en) * 2015-12-15 2017-06-22 广州市动景计算机科技有限公司 Web page display method and apparatus, and server
WO2019019493A1 (en) * 2017-07-28 2019-01-31 平安科技(深圳)有限公司 Data sharing method and device, and computer readable storage medium
CN108282455A (en) * 2017-09-28 2018-07-13 广州市动景计算机科技有限公司 Web-page requests method, apparatus and domain-name information analysis result processing method, device
CN108833585A (en) * 2018-07-03 2018-11-16 北京小米移动软件有限公司 Information interacting method, device and storage medium
US20200268260A1 (en) * 2019-02-26 2020-08-27 Bao Tran Hearing and monitoring system
CN111666514A (en) * 2020-04-28 2020-09-15 平安科技(深圳)有限公司 Data processing method and device for realizing cross-domain request at webpage end and related equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
张磊等: "\"跨媒体语义共享子空间学习研究进展\"", 《计算机学报》 *

Also Published As

Publication number Publication date
CN112417355B (en) 2023-09-05

Similar Documents

Publication Publication Date Title
CN110781482B (en) Login method, login device, computer equipment and storage medium
CN112073405B (en) Webpage data loading method and device, computer equipment and storage medium
CN111666514A (en) Data processing method and device for realizing cross-domain request at webpage end and related equipment
US11184465B2 (en) Network communication for establishing a QUIC connection
CN110602169B (en) Service calling method and device, computer equipment and storage medium
EP4343585A1 (en) Resource acquisition method and system, webvpn proxy server and server
CN110708247B (en) Message routing method, message routing device, computer equipment and storage medium
WO2019127890A1 (en) Vulnerability scanning method, device, computer apparatus, and storage medium
CN112153170B (en) Method, device and equipment for accessing server and storage medium
CN111193716A (en) Service data calling method and device, computer equipment and storage medium
CN108595280B (en) Interface adaptation method and device, computer equipment and storage medium
CN112685669A (en) Page rendering method and system
US10701073B2 (en) Terminal authentication method and device
CN113923008B (en) Malicious website interception method, device, equipment and storage medium
CN112417355B (en) Data interaction method, device, equipment and storage medium based on long connection single channel
CN115242873B (en) Message response method and device for PCB (printed circuit board) equipment, computer equipment and storage medium
CN111026988A (en) Page loading method, device and system and computer equipment
CN113596105B (en) Content acquisition method, edge node and computer readable storage medium
US20170289315A1 (en) Data communication method and apparatus
CN111934909A (en) Method and device for switching IP (Internet protocol) resources of host and standby machine, computer equipment and storage medium
CN111405639A (en) Wireless network connection method and device, readable storage medium and computer equipment
CN113343275B (en) Data access method and data management service system
CN114189493B (en) Distributed signaling communication method, computer device, signaling system and storage medium
CN116828022B (en) Method, device, equipment and medium for managing connection relation with server
CN115022278B (en) CDN processing method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant