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

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

Info

Publication number
CN112417355B
CN112417355B CN202011363619.0A CN202011363619A CN112417355B CN 112417355 B CN112417355 B CN 112417355B CN 202011363619 A CN202011363619 A CN 202011363619A CN 112417355 B CN112417355 B CN 112417355B
Authority
CN
China
Prior art keywords
domain
server
webpage
data
request
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.)
Active
Application number
CN202011363619.0A
Other languages
Chinese (zh)
Other versions
CN112417355A (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

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 application 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-webpage, the cross-domain sub-webpage is mounted under the domain name main webpage through an inline frame, a same-domain data sharing library corresponding to the domain name main webpage is queried according to the interaction information, and whether feedback data corresponding to the interaction information is stored in the same-domain data sharing library is judged; if the same-domain data sharing library does not store feedback data, a data interaction request is sent to the server through a long connection single channel between the domain name main webpage and the server, feedback data corresponding to interaction information returned by the server is received, the feedback data and the target webpage identification are stored in a correlated mode in the same-domain data sharing library, and data interaction is carried out between the cross-domain sub-webpage and the same-domain data sharing library through an inline frame.

Description

Data interaction method, device, equipment and storage medium based on long connection single channel
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for data interaction based on a long connection single channel.
Background
If real-time information interaction is needed between the web page of the browser and the server, a long connection single channel needs to be established between the web page and the server so as to achieve the purpose of information interaction.
However, when a plurality of cross-domain webpages exist in the browser, each cross-domain webpage respectively establishes a long connection single channel with the server, so that the server needs to maintain a plurality of long connection single channels, the maintenance cost is high, and the server is relatively heavy due to the fact that the server resources are occupied by the plurality of long connection single channels, and the interaction performance is affected; and the problem that part of the long connection single channels cannot work normally, so that part of cross-domain webpages cannot interact with a server in real time and the like.
Disclosure of Invention
The embodiment of the application provides a data interaction method, a device, computer equipment and a storage medium based on a long connection single channel, which are used for solving 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-webpage mounted under a domain name main webpage 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 or not;
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, and storing the feedback data and the target webpage identification in the same-domain data sharing library in an associated manner.
A long connection single channel-based data interaction device, 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;
the request source determining module is used for determining 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 judging whether the same-domain data sharing library stores feedback data corresponding to the interaction information or not according to the interaction information query same-domain data sharing library corresponding to the domain name main webpage if the 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 the server through a long connection single channel between the domain name main webpage and the server if the feedback data is not stored in the same-domain data sharing library, receiving feedback data corresponding to the 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 carrying out data interaction between 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 described above when the computer program is executed.
A computer readable storage medium storing a computer program which when executed by a processor performs the steps of the long connection single channel based data interaction method described above.
According to the data interaction method, the 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 identifier, and the corresponding mode is selected for subsequent data interaction, so that resources are reasonably allocated, and resource waste is avoided. 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 resources are reasonably utilized, and resource waste is avoided. If the same-domain data sharing library does not store feedback data, a data interaction request is sent to the server through a long connection single channel between the domain name main webpage and the server, feedback data corresponding to interaction information returned by the server is received, and the feedback data and the target webpage identification are stored in the same-domain data sharing library in an associated mode, so that feedback data corresponding to the domain name sub webpage corresponding to the target webpage identification can be searched quickly. If the request source corresponding to the data interaction request is the same-domain sub-webpage, the data interaction request is sent to the server through a long connection single channel between the domain name main webpage and the server, feedback data corresponding to interaction information returned by the server is received, and the feedback data is sent to the same-domain sub-webpage, so that the data interaction between the domain name main webpage, the same-domain sub-webpage and the cross-domain sub-webpage is realized through only 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 application, the drawings that are needed in the description of the embodiments of the present application will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of an application environment of a data interaction method with a long connection single channel according to an embodiment of the present application;
FIG. 2 is a flow chart of a method of data interaction for a long connection single channel in an embodiment of the application;
FIG. 3 is another flow chart of a method of data interaction for a long connection single channel in an embodiment of the application;
FIG. 4 is another flow chart of a method of data interaction for a long connection single channel in an embodiment of the application;
FIG. 5 is another flow chart of a method of data interaction for a long connection single channel in an embodiment of the application;
FIG. 6 is a schematic block diagram of a long connection single channel data interaction device in accordance with an embodiment of the present application;
FIG. 7 is a schematic diagram of a computer device in accordance with an embodiment of the application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The application 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 as shown in fig. 1, the browser and the server communicate through a network, the browser comprises a domain name main webpage and a domain name sub webpage connected with the domain name main webpage, and the domain name sub webpage comprises a same domain sub webpage and a cross-domain sub webpage mounted under the domain name main webpage 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 webpage, the same-domain sub webpage and the cross-domain sub webpage through only one long connection single channel, ensuring the smoothness of data interaction, reducing the cost of maintaining the long connection single channel by the server and relieving the pressure of the server. Wherein the browser may be installed on, but is not limited to, various personal computers, notebook computers, smartphones, tablet computers, and portable wearable devices. The server may be implemented as a single server or as a cluster of servers.
The domain name main webpage refers to a webpage used for creating a long connection single channel with a server.
The same domain sub-web page is a web page that is identical to the domain name, port, and protocol of the domain name main web page. The domain name, also called network domain, is the name of a computer or a computer group on the Internet, which is composed of a series of names separated by dots, and is used for locating and identifying the computer during data transmission.
The cross-domain sub-web page refers to a web page with at least one different domain name, port and protocol from the domain name main web page, the cross-domain sub-web page is mounted in the domain name main web page through an inline frame, and due to the homologous policy of a browser, interaction cannot be directly performed between two cross-domain web pages. The inline frame refers to an iframe, which is used to embed one page into another page, and in this embodiment, the inline frame embeds multiple cross-domain sub-pages in the domain name main page.
In one embodiment, as shown in fig. 2, a data interaction method based on a long connection single channel is provided, and the method is applied to the browser in fig. 1 for illustration, 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 to the domain name main webpage by the domain name sub webpage and is intended to interact with the server, and the data interaction request can be a request for inquiring 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 a domain name sub-webpage, and it is understood that the target domain name and the target webpage identifier in the same data interaction request may be uniquely directed 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 sub-web page wants to interact data 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.
Wherein the request source is a sub-web page that identifies a data interaction request to be sent to the domain name master web page. The browser determines a uniquely pointed domain name sub-webpage according to the target domain name and the target webpage identifier, and further determines a request source, namely determines whether the domain name sub-webpage sending the data interaction request is a cross-domain sub-webpage or a same-domain sub-webpage, and selects a corresponding mode for subsequent data interaction so as to reasonably allocate resources and avoid resource waste.
S203: if the request source corresponding to the data interaction request is a cross-domain sub-webpage, the cross-domain sub-webpage is mounted under the domain name main webpage through an inline frame, the same-domain data sharing library is queried according to the interaction information, and whether the same-domain data sharing library stores feedback data corresponding to the interaction information is judged.
The feedback data refers to data, which is determined according to the interaction information and needs to be fed back to a domain name sub-webpage corresponding to the target domain name and the target webpage identifier.
The same domain data sharing library is a library for storing data locally by the domain name main webpage, and can be used for storing Local Storage, session, cookie and the like.
In this embodiment, the domain name main webpage queries the same-domain data sharing library according to the interaction information, determines whether the same-domain data sharing library stores feedback data corresponding to the interaction information according to the target webpage identifier, and if the same-domain data sharing library stores feedback data corresponding to the interaction information, can directly obtain the feedback data, and sends the feedback data to the domain name sub-webpage through the inline frame, so as to reasonably utilize resources and avoid resource waste.
S204: if the same-domain data sharing library does not store feedback data, a data interaction request is sent to the server through a long connection single channel between the domain name main webpage and the server, feedback data corresponding to interaction information returned by the server is received, the feedback data and the target webpage identification are stored in a same-domain data sharing library in an associated mode, and data interaction is carried out between the cross-domain sub-webpage and the same-domain data sharing library through an inline frame.
The long connection single channel is a channel for carrying out data interaction between the domain name main webpage and the server. That is, the domain name main webpage performs data interaction with the server through a long connection single channel, the same-domain sub webpage and the cross-domain sub webpage perform data interaction with the domain name main webpage through an inline frame, the data interaction between the server and the domain name main webpage and the data interaction between the cross-domain sub webpage and the domain name main webpage can be realized through the long connection single channel by utilizing the long connection single channel and the inline frame, the data interaction process between the server and the browser can be realized through the long connection single channel, the maintenance of the channel is more convenient and rapid, the maintenance cost of the channel is effectively reduced, and the smooth data interaction between the domain name main webpage and the server can be ensured. The method and the device solve the problems that in the prior art, when a browser opens webpages in a plurality of different domains, the webpages all establish long connection single channels with a server, and because the number of the long connection single channels between the webpages and the server is limited, when the number of the long connection single channels exceeds the preset number, part of webpages cannot interact with the server, so that data interaction is interrupted.
In this embodiment, if the same domain data sharing database does not store feedback data, the data interaction request is sent to the server through a long connection single channel between the domain name main webpage 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 domain name main webpage and the cross-domain sub webpage and the server can be ensured through one long connection single channel. And storing the feedback data and the target webpage identifier in a same-domain data sharing library in an associated mode so as to quickly find the feedback data corresponding to the domain name sub webpage corresponding to the target webpage identifier.
Further, when the response time length of the data interaction request is longer than the preset time length, namely when the data interaction request is abnormal, judging whether the long connection single channel is abnormal, if the long connection single channel is abnormal, recursively calling long polling, creating a new long connection single channel between the domain name main webpage and the server to continue the data interaction request, ensuring that only one long connection single channel is created between the server and the domain name main webpage to realize smooth data interaction request, thereby saving maintenance cost of the server and reasonably utilizing resources.
As an example, preset response time length is preset, when the time length of the domain name main webpage receiving the data interaction request is not less than the preset response time length, namely, the data interaction request is overtime, at the moment, abnormal conditions occur in the data interaction request, whether the abnormal conditions occur in the long connection single channel or not is judged, and when the abnormal conditions occur in the long connection single channel, long polling is called through recursion, so that a long connection single channel is created between the domain name main webpage and the server. The preset duration is a preset duration.
S205: if the request source corresponding to the data interaction request is the same-domain sub-webpage, the data interaction request is sent to the server through a long connection single channel between the domain name main webpage and the server, feedback data corresponding to interaction information returned by the server is received, and the feedback data is sent to the same-domain sub-webpage according to the target webpage identification.
In this embodiment, when the request source corresponding to the data interaction request is the same-domain sub-webpage, the long connection single channel is directly used for performing data interaction, so that the domain name main webpage, the same-domain sub-webpage and the cross-domain sub-webpage perform data interaction with the server only through one long connection single channel, and smoothness of data interaction is ensured.
According to the data interaction method based on the long connection single channel, which is provided by the embodiment, the request source corresponding to the data interaction request is determined according to the target domain name and the target webpage identifier, and the corresponding mode is selected for the subsequent data interaction, so that resources are reasonably allocated, and resource waste is avoided. 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 resources are reasonably utilized, and resource waste is avoided. If the same-domain data sharing library does not store feedback data, a data interaction request is sent to the server through a long connection single channel between the domain name main webpage and the server, feedback data corresponding to interaction information returned by the server is received, and the feedback data and the target webpage identification are stored in the same-domain data sharing library in an associated mode, so that feedback data corresponding to the domain name sub webpage corresponding to the target webpage identification can be searched quickly. If the request source corresponding to the data interaction request is the same-domain sub-webpage, the data interaction request is sent to the server through a long connection single channel between the domain name main webpage and the server, feedback data corresponding to interaction information returned by the server is received, the feedback data is sent to the same-domain sub-webpage according to the target webpage identification, and the data interaction between the domain name main webpage, the same-domain sub-webpage and the cross-domain sub-webpage is realized through only one long connection single channel and the server, so that the smoothness of the data interaction is ensured.
In one 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 the target domain name and the server website.
The connection request is a request which is sent to the domain name main webpage by the domain name sub webpage and is intended to carry out data interaction with the server. For example, the data interactions may be data queries or the like.
The target domain name is a domain name representing a domain name main page corresponding to the domain name main page so that the domain name main page accepts the connection request. The server web address, i.e. the IP address of the server, can be understood as an internet protocol address, so that the domain name master web page determines the server address where the domain name child web page wants to interact with data. It should be noted that the target domain name and the server website are in the same domain, so as to ensure that the domain name main webpage and the server can smoothly establish a long connection single channel, and ensure that the subsequent domain name main webpage and the server can perform data interaction.
Specifically, when the domain name sub-web page wants to interact with the server, the domain name sub-web page sends a connection request to the domain name main web page. And when the domain name main webpage 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 or not. If the same domain data sharing library does not have a connection success identification, the browser is indicated to have not created a long connection with the server. At this time, the domain name main webpage generates a connection request sending server, and provides technical support for the subsequent creation of a long connection single channel.
S302: if the response information fed back by the server is received within the preset response time, 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 is created, a connection success identifier is generated, and the connection success identifier is stored 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 or not.
The response information is information for indicating that the domain name main webpage successfully creates a long connection single channel.
The connection success identifier is an identifier indicating that the domain name main webpage successfully creates a long connection single channel with the server. The connection success identification is stored in the same-domain data sharing library of the domain name main webpage, and because each cross-domain sub webpage is mounted under the domain name main webpage through the inline frame, 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 the server, the same-domain data sharing library of the domain name main webpage is firstly queried 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 webpage and the server do not create a long connection single channel is indicated, at the moment, the cross-domain sub-webpage stores feedback data needing to be subjected to data interaction in the same-domain data sharing library, the cross-domain main webpage checks whether the same-domain data sharing library stores the feedback data or not at regular time, and when the feedback data is stored, the feedback data is sent to the server according to the target webpage identification corresponding to the feedback data, and the feedback data is obtained. When the connection success identifier does not exist in the same-domain data sharing library, it is indicated that the domain name main webpage does not establish a long connection single channel with the server, at this time, the cross-domain sub webpage sends a connection request to the domain name main webpage, the domain name main webpage 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 webpage corresponding to the target domain name and the server corresponding to the server website, realize data interaction between the domain name main webpage, the same-domain sub webpage and the cross-domain sub webpage with the server only through one long connection single channel, ensure smoothness of data interaction, reduce cost of maintaining the long connection single channel by the server, and reduce server pressure.
As an example, cross-domain sub-web page 1 wants to interact data with a server. The cross-domain sub-web page 1 sends a connection request to the domain name main web page so that the domain name main web page and the server establish a long connection single channel, and the connection success identification is stored in the same-domain data sharing library of the domain name main web page. When the cross-domain sub-webpage 2 also wants to perform data interaction with the server, the cross-domain sub-webpage 2 checks the same-domain data sharing library of the domain name main webpage through the inline frame. Because the cross-domain sub-webpage 1 and the cross-domain sub-webpage 2 are mounted on the same domain name main webpage, the cross-domain sub-webpage 1 and the cross-domain sub-webpage 2 share the same domain data sharing library of the domain name main webpage, so that an inline frame of the webpage 2 can detect that the inline frame of the webpage 1 in the same domain data sharing library data establishes long connection and stores the long connection in the identity of the same domain data sharing library. The cross-domain sub-web page 2 does not allow 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 the server is received within the preset response time, the long connection single channel between the domain name main webpage corresponding to the target domain name and the server corresponding to the server website is created, the connection success identification is generated, the connection success identification is stored in the same-domain data sharing library, the long connection single channel between the domain name main webpage corresponding to the target domain name and the server corresponding to the server website is created, the data interaction between the domain name main webpage, the same-domain sub webpage and the cross-domain sub webpage is achieved through only one long connection single channel and the server, smoothness of data interaction is guaranteed, cost of maintaining the long connection single channel by the server is reduced, and server pressure 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 identifier does not exist in the same-domain data sharing library, executing the connection request to be sent to the server.
According to the data interaction method based on the long connection single channel, the same-domain data sharing library is queried in advance, whether the connection success identifier exists in the same-domain data sharing library or not is judged, the connection success identifier does not exist in the same-domain data sharing library, and then the connection request is sent to the server, so that the fact that only one long connection single channel is established between the domain name main webpage and the server is guaranteed, the pressure of the server is relieved, and the follow-up smooth data interaction is guaranteed.
In one embodiment, as shown in fig. 5, step S205, sending the data interaction request to the server through a long connection single channel between the domain name main web page and the server, includes:
s501: a timing detection mechanism is established, the timing detection mechanism comprising detecting the interval duration.
The timing detection mechanism refers to a mechanism for detecting the same-domain data sharing library of a domain name main webpage at fixed time.
The detection interval duration is the duration of two adjacent timing detection intervals, for example, the detection interval duration can be 0.2 seconds, that is, the domain name main webpage queries the same domain data sharing library every 0.2 seconds. The detection interval duration is smaller than the preset duration.
S502: and automatically inquiring the same-domain data sharing library according to the detection duration, and judging whether a data interaction request exists in the same-domain data sharing library.
In this embodiment, the domain name main webpage automatically queries the same-domain data sharing library of the domain name main webpage according to the detection duration, for example, the domain name main webpage may query the same-domain data sharing library every 0.2 seconds to check whether to store the data interaction request sent by the domain name sub webpage, 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, transmitting interaction information of the data interaction request to a server through a long connection single channel.
In this embodiment, when the same-domain data sharing library stores a data interaction request, the interaction information of the data interaction request is sent to the server through a long connection single channel, so that smooth interaction between different web pages 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, wherein 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 a data interaction request exists in the same-domain data sharing library. If the same-domain data sharing stock is in the data interaction request, the interaction information of the data interaction request is sent to the server through a long connection single channel so as to process the data interaction request in time.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic, and should not limit the implementation process of the embodiment of the present application.
In an embodiment, a data interaction device based on a long connection single channel is provided, where 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 by one. As shown in fig. 6, the data interaction device based on a long connection single channel includes a data interaction request receiving module 601, a request source determining module 602, a judging module 603, a first processing module 604 and a second processing module 605. The functional modules are described 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 web page 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 web page identifier.
The judging module 603 is configured to, if the request source corresponding to the data interaction request is a cross-domain sub-web page, mount the cross-domain sub-web page under the domain name main web page through the inline frame, query a same-domain data sharing library corresponding to the domain name main web page according to the interaction information, and judge whether the same-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 webpage 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 webpage identifier in association to the same-domain data sharing library, and perform data interaction with the same-domain data sharing library through an inline frame by using the cross-domain sub-webpage.
And the second processing module 605 is configured to send the data interaction request to the 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 same-domain sub webpage, receive feedback data corresponding to the interaction information returned by the server, and send the feedback data to the same-domain sub webpage.
Preferably, before the data interaction request receiving module 601, the data interaction device based on a long connection single channel further includes: and the connection request receiving module and the long connection single channel creating module.
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 creation module is used for creating a long connection single channel between a domain name main webpage corresponding to the target domain name and a server corresponding to the server website if response information fed back by the server is received within a preset response time, generating a connection success identifier, and storing the connection success identifier in the same-domain data sharing database.
Preferably, the data interaction device based on a long connection single channel further comprises, after the connection request receiving module. The query module and the execution module.
And the query module is used for querying 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.
And the execution module is used for executing the connection request to be sent to the server if the connection success identifier does not exist in the same-domain data sharing library.
Preferably, the first processing module 604 or the second processing module 605 includes: the device comprises a timing detection mechanism establishment unit, an automatic query unit and an interaction information sending unit.
And the timing detection mechanism establishment 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 a data interaction request exists in the same-domain data sharing library.
And the interaction information sending unit is used for sending the interaction information of the data interaction request to the server through a long connection single channel if the same-domain data sharing stock is in the data interaction request.
For specific limitations of the data interaction device based on the long connection single channel, reference may be made to the above limitation of the data interaction method based on the long connection single channel, and the description thereof will not be repeated here. The modules in the data interaction device based on the long connection single channel can be fully or partially realized by software, hardware and a combination thereof. The above modules may be embedded in hardware or independently built in a processor in a computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above 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 includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used to store interaction information. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements a data interaction method based on a long connection single channel.
In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor executes the computer program to implement the steps of the data interaction method based on the long connection single channel in the foregoing embodiment, such as steps S201 to S205 shown in fig. 2, or steps shown in fig. 3 to 5, which are not repeated herein. Alternatively, the processor may implement the functions of each module/unit in this embodiment of the long connection single channel-based data interaction device when executing the computer program, for example, the functions of the data interaction request receiving module 601, the request source determining module 602, the judging module 603, the first processing module 604, and the second processing module 605 shown in fig. 6 are not repeated here.
In an embodiment, a computer readable storage medium is provided, and a computer program is stored on the computer readable storage medium, where the computer program is executed by a processor to implement the steps of the data interaction method based on a long connection single channel in the foregoing embodiment, for example, steps S201 to S205 shown in fig. 2, or steps shown in fig. 3 to 5, which are not repeated herein. Alternatively, the processor may implement the functions of each module/unit in this embodiment of the long connection single channel-based data interaction device when executing the computer program, for example, the functions of the data interaction request receiving module 601, the request source determining module 602, the judging module 603, the first processing module 604, and the second processing module 605 shown in fig. 6 are not repeated here.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile 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), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions.
The above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application 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 scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (9)

1. The data interaction method based on the long connection single channel is characterized by comprising the following steps executed by a browser:
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; if the response information fed back by the server is received within the preset response time, 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 is created, a connection success identifier is generated, and the connection success identifier is stored in a same-domain data sharing database;
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-webpage, the cross-domain sub-webpage is mounted under a domain name main webpage through an inline frame, a same-domain data sharing library corresponding to the domain name main webpage is queried according to the interaction information, and whether the same-domain data sharing library stores feedback data corresponding to the interaction information is judged;
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 in the same-domain data sharing library in an associated manner, and performing data interaction between 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 according to claim 1, wherein after the determining a 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 the same-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 same-domain sub-webpage according to a target webpage identifier.
3. The long connection single channel-based data interaction method according to claim 2, wherein after receiving a 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 same-domain data sharing library, executing the connection request and sending the connection request to a server.
4. The long connection single channel-based data interaction method according to claim 1 or 2, wherein the sending the data interaction request to the server through the long connection single channel between the domain name main web page and the server comprises:
establishing a timing detection mechanism, wherein the timing detection mechanism comprises 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 or not;
and if the same-domain data sharing library is stored in the data interaction request, transmitting interaction information of the data interaction request to a server through a long connection single channel.
5. A data interaction device based on a long connection single channel, comprising:
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; if the response information fed back by the server is received within the preset response time, 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 is created, a connection success identifier is generated, and the connection success identifier is stored in a same-domain data sharing database;
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;
the request source determining module is used for determining 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 judging whether the same-domain data sharing library stores feedback data corresponding to the interaction information or not according to the interaction information query same-domain data sharing library corresponding to the domain name main webpage if the 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 the server through a long connection single channel between the domain name main webpage and the server if the feedback data is not stored in the same-domain data sharing library, receiving feedback data corresponding to the 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 carrying out data interaction between the cross-domain sub-webpage and the same-domain data sharing library through the inline frame.
6. The long connection single channel based data interaction device of claim 5, wherein after the determining module, the long connection single channel based data interaction device further comprises:
and the second processing module is used for sending the data interaction request to the 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 the same-domain sub webpage, receiving feedback data corresponding to the interaction information returned by the server, and sending the feedback data to the same-domain sub webpage.
7. The long connection single channel based data interaction device of claim 5, wherein the long connection single channel based data interaction device further comprises, prior to the data interaction request receiving module:
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 creation 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.
8. Computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the long connection single channel based data interaction method according to any of claims 1 to 4 when the computer program is executed.
9. A computer-readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the steps of the long connection single channel based data interaction method according to any of claims 1 to 4.
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 CN112417355A (en) 2021-02-26
CN112417355B true 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 (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
CN111666514A (en) * 2020-04-28 2020-09-15 平安科技(深圳)有限公司 Data processing method and device for realizing cross-domain request at webpage end and related equipment

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10880340B2 (en) * 2008-11-26 2020-12-29 Free Stream Media Corp. Relevancy improvement through targeting of information based on data gathered from a networked device associated with a security sandbox of a client device
US9459936B2 (en) * 2009-05-01 2016-10-04 Kaazing Corporation Enterprise client-server system and methods of providing web application support through distributed emulation of websocket communications
US10905337B2 (en) * 2019-02-26 2021-02-02 Bao Tran Hearing and monitoring system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
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
张磊等."跨媒体语义共享子空间学习研究进展".《计算机学报》.2017,1394-1421. *

Also Published As

Publication number Publication date
CN112417355A (en) 2021-02-26

Similar Documents

Publication Publication Date Title
CN109064345B (en) Message processing method, system and computer readable storage medium
CN112073405B (en) Webpage data loading method and device, computer equipment and storage medium
CN110213523B (en) Video conference processing method, system, device, computer equipment and storage medium
CN110781482B (en) Login method, login device, computer equipment and storage medium
WO2021218018A1 (en) Data processing method and apparatus for implementing cross-domain request at webpage end, and related device
CN111107176B (en) Data transmission method and device, computer equipment and storage medium
CN110708247B (en) Message routing method, message routing device, computer equipment and storage medium
CN112153170B (en) Method, device and equipment for accessing server and storage medium
WO2019127890A1 (en) Vulnerability scanning method, device, computer apparatus, and storage medium
CN110995617B (en) MQTT-based data transmission method and device, computer equipment and storage medium
CN110602169A (en) Service calling method and device, computer equipment and storage medium
CN104980478A (en) Cache sharing method, devices and system in content delivery network
CN109495553B (en) Webpage display control method and system and reverse proxy server
CN110730196A (en) Network resource access method, computer equipment and storage medium
CN108595280B (en) Interface adaptation method and device, computer equipment and storage medium
CN112685669A (en) Page rendering method and system
CN111224939B (en) Task request intercepting method and device, computer equipment and storage medium
CN106412079B (en) Request processing method and system
CN111813826A (en) WHOIS query method, system and storage medium
CN112417355B (en) Data interaction method, device, equipment and storage medium based on long connection single channel
CN115913597A (en) Method and device for determining lost host
CN114285659A (en) Reverse proxy method, device, equipment and storage medium
CN111026988A (en) Page loading method, device and system and computer equipment
CN114070820B (en) Domain name redirection method, device, medium and electronic equipment
CN112771835B (en) Method and device for processing outer link rewriting

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