CN113238881B - Page communication method and device - Google Patents

Page communication method and device Download PDF

Info

Publication number
CN113238881B
CN113238881B CN202110593645.0A CN202110593645A CN113238881B CN 113238881 B CN113238881 B CN 113238881B CN 202110593645 A CN202110593645 A CN 202110593645A CN 113238881 B CN113238881 B CN 113238881B
Authority
CN
China
Prior art keywords
page
message
loading
service
creation
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
CN202110593645.0A
Other languages
Chinese (zh)
Other versions
CN113238881A (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.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet 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 Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202110593645.0A priority Critical patent/CN113238881B/en
Publication of CN113238881A publication Critical patent/CN113238881A/en
Application granted granted Critical
Publication of CN113238881B publication Critical patent/CN113238881B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/542Event management; Broadcasting; Multicasting; Notifications
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/541Client-server

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The disclosure relates to the technical field of computers, and in particular relates to a method and a device for page communication, which are used for solving the problems of low page communication efficiency and poor security in the prior art, wherein the method comprises the following steps: when the terminal equipment determines that the preset triggering condition is met, a communication channel is established between the first page and the second page, the communication channel is multiplexed, a loading request message is correspondingly generated and sent to the second page in response to a service request triggered by the service to be presented in the first page, when the loading response message which is returned by the second page and carries the attribute identification of the loading message is determined to be received, the service data of the service to be presented and loaded by the second page are acquired in the multiplexing communication channel, so that the terminal equipment can solve the problem of communication requirement between the first page and the second page by establishing the communication channel, and can timely sense the abnormal condition of a communication counterpart, thereby improving the efficiency of page communication and guaranteeing the purpose of safe communication between the pages.

Description

Page communication method and device
Technical Field
The disclosure relates to the field of computer technology, and in particular, to a method and a device for page communication.
Background
Iframe is a hypertext markup language (HyperText Markup Language, HTML) tag by which one page can be embedded into another as a presentation area in one page. Alternatively, pages with different domain names may also nest with each other when a preset constraint is reached. For example, in the page of the site a, the page of the site B may be embedded into the page of the site B through the iframe, and then the page of the site B is called an iframe page (also called a child page), and the page of the site a is a parent page corresponding to the iframe page. In the parent page of site a, a cross-domain call may be initiated to site B.
In the prior art, when a parent page and a child page communicate with each other, an asynchronous message delivery function (postMessage) application programming interface (Application Programming Interface, API) is typically used for communication.
However, since the postMessage is returned immediately after the message to be sent is put into the queue, and then the next task is continuously executed, regardless of whether other programs process the message, when the parent page initiates the service to the child page, communication between the parent page and the child page is performed based on the postMessage API, and therefore, an immediate monitoring mode needs to be started, that is, a server specially used for monitoring is required to be set immediately, all data after the returned value of the postMessage is received is monitored, then the data is screened, matched data is screened out, and because a large amount of irrelevant data exists in all monitored data, communication is performed simply based on the postMessage API, so that the efficiency of page communication of the data is greatly reduced, and meanwhile, because the page of the iframe cannot timely sense the abnormal condition of the communication counterpart, a security risk exists.
Therefore, there is a need to devise a new approach to solve the above-mentioned problems.
Disclosure of Invention
The embodiment of the disclosure provides a page communication method and device, which are used for solving the problems that the page communication efficiency is low and the abnormal situation of a communication counterpart cannot be perceived in time in the prior art.
The specific technical scheme provided by the embodiment of the disclosure is as follows:
in a first aspect, a method of page communication includes:
when the preset triggering condition is determined to be met, a communication channel is established between the first page and the second page;
responding to a service request triggered by a service to be presented in the first page, generating a loading request message corresponding to the service request, and sending the loading request message to the second page through the communication channel, so that the second page loads the service data of the service to be presented based on the loading request message, wherein the loading request message at least comprises a service identifier and a loading message attribute identifier of the service to be presented;
and when the loading response message returned by the second page is determined to carry the loading message attribute identifier, acquiring the service data of the service to be presented loaded by the second page through the communication channel.
Optionally, when the determining meets the preset triggering condition, the determining includes:
when a communication request aiming at the second page, which is triggered in the first page, is received, a preset triggering condition is determined to be met; or,
when a communication request triggered by a preset thread is received, the preset triggering condition is determined to be met.
Optionally, the first page is a parent page, and the second page is a child page;
or,
the first page is a sub page, and the second page is a parent page.
Optionally, when the determining that the preset trigger condition is met, establishing a communication channel between the first page and the second page includes:
when the preset triggering condition is determined to be met, the following operations are circularly executed until the fact that the creation response message returned by the second page is received and carrying the creation message attribute identifier is determined:
generating a creation channel message for establishing a communication channel between the first page and the second page, wherein the creation channel message at least comprises a creation message attribute identifier;
sending the creation channel message to the second page through an asynchronous message delivery function postmessage application programming interface API;
Judging whether a creation response message carrying the creation message attribute identifier is received or not;
and determining that the establishment of the communication channel between the first page and the second page is completed based on the received creation response message carrying the creation message attribute identifier.
Optionally, the method further comprises:
after receiving the create response message, looking up a source origin attribute of the create response message, and determining that the create response message is returned by the second page based on the origin attribute.
Optionally, the determining whether a creation response message carrying the creation message attribute identifier is received further includes:
if it is determined that the creation response message carrying the creation message attribute identifier is not received, a timer set for receiving the creation response message is overtime, and it is determined that the judgment number does not reach the set threshold, the creation message attribute identifier is updated.
Optionally, the determining whether a creation response message carrying the creation message attribute identifier is received further includes:
and if the establishment response message carrying the creation message attribute identifier is not received and the judgment times reach the set threshold value, determining that the establishment of the communication channel between the first page and the second page fails.
Optionally, when it is determined that the loading response message returned by the second page carries the loading message attribute identifier and the channel attribute identifier, after obtaining, through the communication channel, service data of the service to be presented loaded by the second page, the method further includes:
displaying the service data of the service to be presented in the first page; or,
and displaying the service data of the service to be presented in the first page, and feeding back the service data to a server.
Optionally, the method further comprises:
after receiving the loading response message, obtaining an origin attribute of the loading response message;
based on the origin attribute, it is determined that the load response message is returned by the second page.
Optionally, if a plurality of corresponding service requests are triggered for a plurality of services to be presented in the first page, a loading request message corresponding to the service request is generated in response to the service request triggered for the services to be presented in the first page, and the loading request message is sent to the second page through the communication channel, including:
responding to corresponding service requests triggered by a plurality of services to be presented in the first page, and correspondingly generating respective loading request messages of the service requests, wherein each loading request message at least comprises a service identifier of the corresponding service to be presented and a corresponding loading message attribute identifier;
Constructing a message set based on the plurality of loading request messages, and respectively sending the plurality of loading request messages to a plurality of second pages through the communication channel, so that the plurality of second pages load corresponding service data of the service to be presented based on the respective corresponding loading request messages;
removing a corresponding loading request message from the message set based on a loading message attribute identifier carried by the loading response message after receiving the loading response message returned by one second page;
and when the fact that all the plurality of loading request messages in the message set are removed is determined, releasing the space occupied by the message set.
Optionally, the loading message attribute identifier carried by each loading response message is uniquely set and fixed for the corresponding service to be presented.
In a second aspect, an apparatus for page communication includes:
the determining unit is used for establishing a communication channel between the first page and the second page when the preset triggering condition is determined to be met;
the response unit is used for responding to a service request triggered by a service to be presented in the first page, generating a loading request message corresponding to the service request, and sending the loading request message to the second page through the communication channel so that the second page loads the service data of the service to be presented based on the loading request message, wherein the loading request message at least comprises a service identifier of the service to be presented and a loading message attribute identifier;
The obtaining unit is used for obtaining the service data of the service to be presented, which is loaded by the second page, through the communication channel when the loading response message returned by the second page is determined to carry the loading message attribute identifier.
Optionally, when the determining meets a preset trigger condition, the determining unit is configured to:
when a communication request aiming at the second page, which is triggered in the first page, is received, a preset triggering condition is determined to be met; or,
when a communication request triggered by a preset thread is received, the preset triggering condition is determined to be met.
Optionally, the first page is a parent page, and the second page is a child page;
or,
the first page is a sub page, and the second page is a parent page.
Optionally, when the determining meets a preset trigger condition, a communication channel is established between the first page and the second page, and the determining unit is configured to:
when the preset triggering condition is determined to be met, the following operations are circularly executed until the fact that the creation response message returned by the second page is received and carrying the creation message attribute identifier is determined:
generating a creation channel message for establishing a communication channel between the first page and the second page, wherein the creation channel message at least comprises a creation message attribute identifier;
Sending the creation channel message to the second page through an asynchronous message delivery function postmessage application programming interface API;
judging whether a creation response message carrying the creation message attribute identifier is received or not;
and determining that the establishment of the communication channel between the first page and the second page is completed based on the received creation response message carrying the creation message attribute identifier.
Optionally, the determining unit is further configured to:
after receiving the create response message, looking up a source origin attribute of the create response message, and determining that the create response message is returned by the second page based on the origin attribute.
Optionally, the determining unit is further configured to determine whether a creation response message carrying the creation message attribute identifier is received, and the determining unit is further configured to:
if it is determined that the creation response message carrying the creation message attribute identifier is not received, a timer set for receiving the creation response message is overtime, and it is determined that the judgment number does not reach the set threshold, the creation message attribute identifier is updated.
Optionally, the determining unit is further configured to determine whether a creation response message carrying the creation message attribute identifier is received, and the determining unit is further configured to:
And if the establishment response message carrying the creation message attribute identifier is not received and the judgment times reach the set threshold value, determining that the establishment of the communication channel between the first page and the second page fails.
Optionally, when it is determined that the loading response message returned by the second page carries the loading message attribute identifier and the channel attribute identifier, after acquiring, by the communication channel, service data of the service to be presented loaded by the second page, the acquiring unit is further configured to:
displaying the service data of the service to be presented in the first page; or,
and displaying the service data of the service to be presented in the first page, and feeding back the service data to a server.
Optionally, the acquiring unit is further configured to:
after receiving the loading response message, obtaining an origin attribute of the loading response message;
based on the origin attribute, it is determined that the load response message is returned by the second page.
Optionally, if a plurality of corresponding service requests are triggered for a plurality of services to be presented in the first page, a loading request message corresponding to the service request is generated in response to the service request triggered for the services to be presented in the first page, and the services to be presented send the loading request message to the second page through the communication channel, where the second response unit is configured to:
Responding to corresponding service requests triggered by a plurality of services to be presented in the first page, and correspondingly generating respective loading request messages of the service requests, wherein each loading request message at least comprises a service identifier of the corresponding service to be presented and a corresponding loading message attribute identifier;
constructing a message set based on the plurality of loading request messages, and respectively sending the plurality of loading request messages to a plurality of second pages through the communication channel, so that the plurality of second pages load corresponding service data of the service to be presented based on the respective corresponding loading request messages;
removing a corresponding loading request message from the message set based on a loading message attribute identifier carried by the loading response message after receiving the loading response message returned by one second page;
and when the fact that all the plurality of loading request messages in the message set are removed is determined, releasing the space occupied by the message set.
Optionally, the loading message attribute identifier carried by each loading response message is uniquely set and fixed for the corresponding service to be presented.
In a third aspect, a computer apparatus includes:
A memory for storing executable instructions;
a processor for reading and executing executable instructions stored in the memory to implement the method of any one of the above first aspects.
In a fourth aspect, a computer readable storage medium, which when executed by a processor, causes the processor to perform the method of any of the first aspects.
A fifth aspect, a computer program product comprising executable instructions which, when executed by a processor, is capable of implementing the method of any of the first aspects.
In the embodiment of the disclosure, a terminal device determines that a preset trigger condition is met, a communication channel is established between a first page and a second page, then based on the communication channel, a loading request message corresponding to a service request is generated in response to the service request triggered by a service to be presented in the first page, the loading request message is sent to the second page, after a loading response message carrying a loading message attribute identifier returned by the second page is determined to be received, service data of the service to be presented loaded by the second page is obtained through the communication channel, wherein the loading request message at least comprises the loading message attribute identifier, so that the terminal device can improve the page communication efficiency by establishing the communication channel for the first page and the second page, and the first page or/and the second page can timely sense the abnormal condition of the other side, thereby guaranteeing the safety communication of an iframe technology; then, in response to the service request triggered by the service to be presented in the first page, the corresponding loading message attribute identifier is configured for the loading request message generated corresponding to the service request, and after the loading request message is sent to the second page, a corresponding monitoring server or device does not need to be specially configured, so that the safety of page communication is enhanced, the network architecture is optimized, and network resources are saved.
Drawings
FIG. 1 is a schematic diagram of a page communication system architecture in an embodiment of the disclosure;
fig. 2A is a schematic flow chart of page communication performed by a terminal device in an embodiment of the disclosure;
fig. 2B is a schematic flow chart of an application scenario one in an embodiment of the disclosure;
FIG. 3 is a schematic flow chart of establishing a page communication channel according to an embodiment of the disclosure;
fig. 4 is a schematic diagram of an application scenario for establishing a page communication channel in an embodiment of the disclosure;
fig. 5 is a schematic diagram of an application scenario for establishing a page communication channel in an embodiment of the disclosure;
fig. 6 is a schematic diagram of an application scenario two in an embodiment of the disclosure;
fig. 7 is a schematic diagram of an application scenario for implementing page communication in an embodiment of the disclosure;
fig. 8 is a schematic diagram of an application scenario for implementing page communication in an embodiment of the disclosure;
FIG. 9 is a schematic diagram of a logic architecture of a computer device in an embodiment of the disclosure;
fig. 10 is a schematic diagram of a physical architecture of a computer device according to an embodiment of the disclosure.
Detailed Description
In order to solve the problems that the page communication efficiency is low and the abnormal condition of a communication counterpart cannot be perceived in time in the prior art, in the embodiment of the present disclosure, when the terminal equipment determines that the preset triggering condition is met, a communication channel is established between a first page and a second page, the communication channel is multiplexed again, a loading request message corresponding to a service request is generated by responding to the service request triggered in the first page for the service to be presented, the loading request message is sent to the second page, and after the loading response message carrying the attribute identifier of the loading message returned by the second page is determined to be received, the service data of the service to be presented loaded by the second page is obtained; therefore, the terminal equipment can timely sense the abnormal condition of the second page and can improve the page communication efficiency based on the loading message attribute identification.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the foregoing figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the disclosure described herein may be capable of operation in sequences other than those illustrated or described herein. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present disclosure as detailed in the accompanying claims.
In the following, some terms in the embodiments of the present disclosure are explained for easy understanding by those skilled in the art.
(1) The term "and/or" in the embodiments of the present disclosure describes an association relationship of association objects, which indicates that three relationships may exist, for example, a and/or B may indicate: a exists alone, A and B exist together, and B exists alone. The character "/" generally indicates that the context-dependent object is an "or" relationship.
(2) The term "iframe" in the embodiments of the present disclosure is a tag on hypertext markup language (HTML), running on a browser, implementing embedding one page in another.
(3) The term "HTML" file in the embodiments of the present disclosure is a web page content description file, and describes web page content using HTML language.
(4) The term "ison" in the embodiments of the present disclosure is a lightweight text data exchange format, which is a JavaScript object notation.
(5) In the embodiment of the disclosure, the term "JavaScript code" is a script language code for loading a webpage, abbreviated as JS code, and the JavaScript code is executed by inserting into HTML, and can realize the output of HTML element content through JavaScript, respond to an event, change HTML content, image, style, verification input and other functions, and basically all interactions on the webpage are realized through JS functions.
Preferred embodiments of the present disclosure are described in further detail below with reference to the accompanying drawings.
With the complexity of the web page structure, the application scene of embedding another page in one page by adopting the iframe technology is more and more common, and the communication requirement between the parent page and the child page is generated.
Fig. 1 illustrates an application scenario of a page communication provided in an embodiment of the present disclosure, and referring to fig. 1, a terminal device 100 presents a parent page 101 and a plurality of sub-pages 102 that perform page communication with the parent page 101 in an operation interface of a browser, where a user may trigger page communication for the sub-pages 102 in the parent page 101.
Referring to fig. 2A, in the embodiment of the present disclosure, a specific flow of page communication performed by a terminal device is as follows:
step 200: and when the terminal equipment determines that the preset triggering condition is met, a communication channel is established between the first page and the second page.
In the embodiment of the present disclosure, the terminal device determines that the preset trigger condition is met, which may be, but is not limited to, two modes:
in mode 1, when the terminal device receives a communication request for a second page triggered in a first page, it is determined that a preset trigger condition is met.
In specific implementation, referring to fig. 1, if the first page is a parent page and the second page is a child page, when the terminal device receives a communication request for the child page triggered in the parent page, it is determined that a preset triggering condition is met; if the first page is a child page and the second page is a parent page, when the terminal equipment receives a communication request aiming at the parent page and triggered in the child page, the terminal equipment determines that a preset triggering condition is met. Thus, whether the initiator initiating the communication request is a parent page or a child page, a thread that establishes a communication channel between the parent page and the child page can be initiated to establish a reliable communication channel for the communication request between the parent page and the child page.
In the mode 2, when the terminal equipment receives a communication request triggered by a preset thread, the terminal equipment determines that a preset triggering condition is met.
In specific implementation, the terminal device may correspondingly establish a communication channel between the first page and the second page according to the received communication request triggered by the preset thread.
Thus, when the terminal equipment receives the trigger condition meeting the preset condition, a reliable communication channel can be established between the first page and the second page, so that the safety communication requirement between the first page and the second page can be met.
In the embodiment of the present disclosure, the following description will be given by taking only a scenario in which a communication channel is established between a first page and a second page when a terminal device receives a communication request for a child page triggered in a parent page as an example. Establishing a communication channel between a first page and a second page aiming at the terminal equipment receiving a communication request for a parent page triggered in a child page; the specific implementation of establishing a communication channel between the first page and the second page when the terminal device receives the communication request triggered by the preset thread is similar, and will not be described herein.
Referring to fig. 2B, the terminal device may present a parent page in a browser in an operation interface, where at least a navigation button is presented in the parent page, and when the user clicks the navigation button, the terminal device determines that a communication request for the second page is triggered by the user in the first page, and then the terminal device responds to the communication request to establish a communication channel between the first page and the second page.
Optionally, referring to fig. 3, in an embodiment of the present disclosure, the terminal device may set up a communication channel between the first page and the second page by adopting the following steps:
step 2001: the terminal device receives a communication request for a second page triggered in the first page.
In the embodiment of the disclosure, referring to fig. 2B, the terminal device receives a navigation button clicked by a user in a parent page, and correspondingly triggers a communication request for a child page.
Step 2002: the terminal equipment generates a creation channel message corresponding to the communication request, wherein the creation channel message at least comprises an attribute identifier of the creation message.
In the embodiment of the disclosure, referring to fig. 2B, according to a communication request triggered by a user on a parent page, a terminal device correspondingly generates a creation channel message carrying at least a creation message attribute identifier, where the creation message attribute identifier is used to make the terminal device verify a creation response message returned by a child page.
Alternatively, the create channel message may be a handshake (handshake) type message.
Alternatively, the handlegram type message may be compiled using a lightweight data exchange format (JavaScript Object Notation, json) structure, may be a type field in a custom json structure, and the carried create message attribute identifier may be a cid field.
For example, referring to fig. 4, taking a first page as a parent page and a second page as a child page as an example.
Assume that a terminal device receives a communication request for a child page triggered at a parent page.
Then, the terminal device generates a corresponding creation channel message based on the communication request, and the creation channel message at least contains the creation message attribute identifier.
Assuming that the create channel message (handleshake) is compiled by adopting a json structure, and the attribute identifier of the create message can be a cid field corresponding to a type field in the json structure, then the corresponding create channel message can be:
step 2003: the terminal device sends the create channel message to the second page through the postmessage API.
In the embodiment of the disclosure, the postmessage () method allows scripts from different sources to effectively communicate in an asynchronous manner, so that cross-text document, multi-window and cross-domain message passing can be realized, and therefore, the terminal device can send the generated creation channel message to a second page (such as a sub page) through a postmessage API.
Step 2004: the terminal device sets an initiator for the reception of the creation response message and starts a timer.
In the embodiment of the disclosure, the terminal device sets a timer for receiving the creation response message and starts the timer while sending the creation channel message to the second page, wherein the timer is used for reducing the resource of the terminal device and preventing program paralysis. In this way, when the terminal equipment establishes a communication channel between the first page and the second page, by setting the timer, normal operation of a thread for establishing the communication channel can be ensured, and program paralysis and waste of network resources caused by endless loop are avoided.
Step 2005: the terminal device determines whether a creation response message carrying the attribute identifier of the creation message is received, if yes, step 2009 is executed, otherwise step 2006 is executed.
In the embodiment of the disclosure, the terminal device monitors a creation response message returned by the second page, wherein the creation response message carries an attribute identifier of the creation message.
Optionally, the terminal device further determines whether the creation response message carries the creation message attribute identifier in the corresponding creation channel message by determining whether the creation response message is received, if the terminal device receives the creation response message, and when determining that the creation response message carrying the creation message attribute identifier is received, performs step 2009. Accordingly, if the terminal device does not receive the creation response message, step 2006 is performed.
Optionally, after receiving the creation response message, the terminal device may first search for a source (origin) attribute of the creation response message, and then determine, based on the origin attribute, that the creation response message is returned by the second page, so that by verifying the source of the creation response message, an abnormal situation of the second page can be timely perceived, and the second page is effectively prevented from being accidentally redirected to unsafe environments such as a forged page, thereby ensuring communication security between the first page and the second page.
For example, referring to fig. 5, the first page is still used as a parent page, and the second page is used as a child page.
It is assumed that the terminal device determines that a creation response message carrying the attribute identifier of the creation message is received, and that the creation response message is also compiled using a json structure.
Then, corresponding to the creation response message of the handle-ack type returned by the terminal device from the sub page received by the postmessage API, where the creation response message carries the attribute identifier of the creation message, and the corresponding creation response message may be:
step 2006: the terminal device determines whether the timer has timed out based on the initiator set for the reception creation response message, and if so, executes step 2007, otherwise, returns to execute step 2005.
In the embodiment of the present disclosure, the terminal device monitors the creation response message returned by the second page, and if the terminal device determines that the creation response message carrying the attribute identifier of the creation message is not received, and the timer set for receiving the creation response message has expired, step 2007 is executed.
Step 2007: the terminal device determines whether the number of times of judgment exceeds the set threshold, if so, performs step 2010, otherwise, performs step 2008.
In the embodiment of the disclosure, if the terminal device determines that the creation response message carrying the attribute identifier of the creation message is not received and the timer set for receiving the creation response message has timed out, determining whether the number of judgment exceeds a set threshold, wherein the set threshold can be customized according to the needs of a user.
In this way, when the terminal equipment establishes a communication channel between the first page and the second page, the normal operation of the thread for establishing the communication channel can be ensured by setting a set threshold value for the judgment times, so that program paralysis caused by endless loop is avoided;
step 2008: the terminal device updates the creation message attribute identifier, and returns to step 2002.
In the embodiment of the disclosure, the terminal device updates the created message attribute identifier, and then returns to execute step 2002 to restart a further flow of establishing a communication channel.
Therefore, when the terminal equipment establishes a communication channel between the first page and the second page, the timeliness of the established communication channel can be ensured by updating the established message attribute identifier, so that timely and efficient communication between the first page and the second page is ensured.
Step 2009: the terminal equipment determines that the establishment of the communication channel between the first page and the second page is completed.
In the embodiment of the disclosure, if the terminal device determines that the creation response message carrying the attribute identifier of the creation message is received, and that the timer set for receiving the creation response message is not overtime, and that the number of judgment times does not exceed the set threshold, it is determined that the establishment of the communication channel between the first page and the second page is completed.
Step 2010: the terminal device determines that the communication channel between the first page and the second page fails to be established.
In the embodiment of the disclosure, if the terminal device determines that the creation response message carrying the attribute identifier of the creation message is not received and determines that the number of judgment times exceeds the set threshold, it is determined that the establishment of the communication channel between the first page and the second page fails.
Step 210: the terminal equipment responds to a service request triggered by a service to be presented in a first page, generates a loading request message corresponding to the service request, and sends the loading request message to a second page through a communication channel, so that the second page loads service data of the service to be presented based on the loading request message, wherein the loading request message at least comprises a service identifier of the service to be presented and a loading message attribute identifier.
In the embodiment of the present disclosure, the terminal device establishes a communication channel between the first page and the second page by executing step 2001-step 2009.
In this disclosure embodiment, referring to fig. 6, a terminal device may present a parent page in a browser in an operation interface, where at least a to-be-presented service button is presented in the parent page, and when a user clicks the to-be-presented service button, the terminal device determines that a service request triggered for the to-be-presented service is triggered in a first page by the user, and then the terminal device responds to the service request, and generates a loading request message corresponding to the service request. And then, sending a loading request to a second page through a communication channel, wherein the loading request message at least comprises the service type of the service to be presented and the attribute identifier of the loading message.
Optionally, the service identifier of the service to be presented is used for enabling the second page to load service data of the service to be presented based on the loading request information, and the loading message attribute identifier is used for searching the corresponding loading request message based on the loading message attribute identifier carried by the loading response message when the terminal device receives the loading response message returned by the second page.
Optionally, the attribute identifier of the loading message contained in the loading request message is uniquely set and fixed for the corresponding service to be presented.
For example, referring to fig. 7, the first page is still taken as a parent page, and the second page is taken as a child page.
It is assumed that the terminal device responds to a service request for a child page triggered at a parent page.
And then, the terminal equipment generates a corresponding loading request message based on the service request of the service to be presented, wherein the loading request message at least comprises the service identifier of the service to be presented and the loading message attribute identifier.
And assuming that the loading request message is compiled by adopting a json structure, the type field in the corresponding json structure is message, the loading message attribute identifier can be mid field, meanwhile, the created message attribute identifier carrying the communication channel can be cid field, and the corresponding message load of the service to be presented is payload.
Then the corresponding load request message may be:
optionally, when executing step 210, if a plurality of corresponding service requests are triggered for a plurality of services to be presented in the first page, the terminal device executes the following steps:
A. the terminal equipment responds to corresponding service requests triggered by a plurality of services to be presented in a first page, and correspondingly generates respective loading request messages of the service requests, wherein each loading request message at least comprises a service identifier of the corresponding service to be presented and a corresponding loading message attribute identifier.
In the embodiment of the present disclosure, if service requests of the to-be-presented services of the plurality of second pages are triggered in the first page, the terminal device may respectively respond to the service requests of the plurality of to-be-presented services, and generate loading request messages corresponding to the plurality of service requests, where each loading request message at least includes a service identifier of the corresponding to-be-presented service and a corresponding loading message attribute identifier.
B. The terminal equipment constructs a message set based on the plurality of loading request messages, and sends the plurality of loading request messages to a plurality of second pages through communication channels respectively, so that the plurality of second pages load corresponding service data of the service to be presented based on the corresponding loading request messages respectively.
In the embodiment of the disclosure, after generating the corresponding loading request message, the terminal device constructs a corresponding message set, and sends the multiple loading request messages to the multiple second pages through communication channels, so that the multiple second pages load the corresponding service data of the service to be presented based on the corresponding loading request messages, respectively, wherein the message set is used for searching the corresponding loading request message based on the loading message attribute identifier carried by the loading response message when the terminal device receives the loading response message returned by the multiple second pages, so that the terminal device does not need to be specially allocated with a server or a device for monitoring, and further the purposes of saving resources and optimizing the network architecture can be achieved.
C. And each time the terminal equipment receives a loading response message returned by the second page, removing the corresponding loading request message from the message set based on the loading message attribute identifier carried by the loading response message.
In the embodiment of the disclosure, after a plurality of loading request messages are sent to a second page through a communication channel, the terminal device receives loading response messages returned by the second page one by one, and then the terminal device obtains carried loading message attribute identifiers from the loading response messages after receiving the loading response messages returned by one second page, and then searches for corresponding loading request messages in a message set based on the loading message attribute identifiers, and removes the corresponding loading request messages from the message set.
Optionally, when removing the message set from the corresponding loading request message, the terminal device may call a corresponding callback function (callback), and return a corresponding notification message to the first page, so as to implement an asynchronous calling method, where the notification message is used to notify the first page that the loading response message returned by the second page has been received for the service to be presented.
Optionally, the attribute identifier of the loading message carried by the loading response message is uniquely set and fixed for the corresponding service to be presented.
Optionally, the loading response message further carries a creation message attribute identifier of the corresponding communication channel, where the creation message attribute identifier is used for verifying, by the terminal device, that the second page is returned by the second page through the pre-established communication channel.
Optionally, after receiving the loading response message, the terminal device may perform message verification on the obtained loading response message by adopting the following operations:
in operation a, first, the terminal device obtains an origin attribute in the load response message, and then, based on the origin attribute, determines whether the load response message is returned by the second page. If the verification is passed, determining that the loading response message is returned by the second page, and determining that the second page is an iframe page conforming to the expectation, thereby avoiding the second page of the iframe from being tampered accidentally; if the verification is passed, the loading response message is determined not to be returned by the second page, the terminal equipment can timely sense the abnormal condition of the second page, so that further communication between the first page and the maliciously tampered second page is interrupted.
And b, because the loading response message returned by the second page received by the terminal equipment carries the corresponding creation message attribute identifier, the terminal equipment can acquire the creation message attribute identifier, and determine that the loading response message is returned by the second page through the communication channel based on the creation message attribute identifier, thereby ensuring the safety of communication between the first page and the second page.
For example, referring to fig. 8, the first page is still taken as a parent page, and the second page is taken as a child page.
The terminal equipment receives the loading response message returned from the sub-page, and the loading response message is also compiled by adopting a json structure, wherein the loading response message carries the loading message attribute identification.
Then, the loading response message that the terminal device receives the sub-page return may be:
optionally, if the loading response message also adopts the json programming format, the terminal device may further verify a message type of the loading response message, and determine, based on a type field in the json structure, that the loading response message is returned after the second page performs corresponding processing based on the loading request message.
D. And when the terminal equipment determines that the plurality of loading request messages in the message set are removed, releasing the space occupied by the message set.
In the embodiment of the disclosure, the loading response message carries the loading message attribute identifier, and the loading message attribute identifier is uniquely set and fixed for the corresponding service to be presented, so that after receiving the loading response message, the terminal device can accurately find the corresponding loading request message based on the loading message attribute identifier in the received loading response message, remove the corresponding loading request message from the message set, and release the space occupied by the message set after determining that the loading request message in the message set is removed, thereby achieving the purposes of saving network resources and optimizing network architecture.
Step 220: when the terminal equipment determines that the loading response message returned by the second page carries the loading message attribute identification, service data of the service to be presented loaded by the second page is obtained through the communication channel.
In the embodiment of the disclosure, after the terminal device determines the loading response message carrying the loading message attribute identifier returned by the second page through the verification operation, service data of the service to be presented loaded by the second page is obtained through the communication channel.
Optionally, after the terminal device obtains the service data of the service to be presented loaded on the second page, the service data of the service to be presented may be displayed in the first page; the service data of the service to be presented can also be presented in the first page, and the service data is fed back to the server.
When the terminal equipment determines that the preset trigger condition is met, creating channel creating information for creating a communication channel between the first page and the second page is generated, wherein the channel creating information at least comprises a created information attribute identifier, and the communication channel is established between the first page and the second page by judging that the received created response information carrying the created information attribute identifier; the communication channel may then be multiplexed while communication is being performed between the first page and the second page, thereby completing the remote invocation.
Based on the same inventive concept, referring to fig. 9, in an embodiment of the present disclosure, there is provided a computer apparatus (e.g., a computer device) including:
a determining unit 910, configured to establish a communication channel between the first page and the second page when a preset trigger condition is determined to be satisfied;
a response unit 920, configured to respond to a service request triggered by a service to be presented in the first page, generate a loading request message corresponding to the service request, and send the loading request message to the second page through the communication channel, so that the second page loads service data of the service to be presented based on the loading request message, where the loading request message at least includes a service identifier of the service to be presented and a loading message attribute identifier;
and an obtaining unit 930, configured to obtain, through the communication channel, service data of the service to be presented, which is loaded by the second page, when it is determined that the loading response message returned by the second page carries the attribute identifier of the loading message.
Optionally, when the determining meets a preset trigger condition, the determining unit 910 is configured to:
when a communication request aiming at the second page, which is triggered in the first page, is received, a preset triggering condition is determined to be met; or,
When a communication request triggered by a preset thread is received, the preset triggering condition is determined to be met.
Optionally, the first page is a parent page, and the second page is a child page;
or,
the first page is a sub page, and the second page is a parent page.
Optionally, when the determining meets the preset trigger condition, a communication channel is established between the first page and the second page, and the determining unit 910 is configured to:
when the preset triggering condition is determined to be met, the following operations are circularly executed until the fact that the creation response message returned by the second page is received and carrying the creation message attribute identifier is determined:
generating a creation channel message for establishing a communication channel between the first page and the second page, wherein the creation channel message at least comprises a creation message attribute identifier;
sending the creation channel message to the second page through an asynchronous message delivery function postmessage application programming interface API;
judging whether a creation response message carrying the creation message attribute identifier is received or not;
and determining that the establishment of the communication channel between the first page and the second page is completed based on the received creation response message carrying the creation message attribute identifier.
Optionally, the determining unit 910 is further configured to:
after receiving the create response message, looking up a source origin attribute of the create response message, and determining that the create response message is returned by the second page based on the origin attribute.
Optionally, the determining unit 910 is further configured to determine whether a create response message carrying the create message attribute identifier is received, where the create response message is further configured to:
if it is determined that the creation response message carrying the creation message attribute identifier is not received, a timer set for receiving the creation response message is overtime, and it is determined that the judgment number does not reach the set threshold, the creation message attribute identifier is updated.
Optionally, the determining unit 910 is further configured to determine whether a create response message carrying the create message attribute identifier is received, where the create response message is further configured to:
and if the establishment response message carrying the creation message attribute identifier is not received and the judgment times reach the set threshold value, determining that the establishment of the communication channel between the first page and the second page fails.
Optionally, when it is determined that the loading response message returned by the second page carries the loading message attribute identifier and the channel attribute identifier, after acquiring, by using the communication channel, service data of the service to be presented, which is loaded by the second page, the acquiring unit 930 is further configured to:
Displaying the service data of the service to be presented in the first page; or,
and displaying the service data of the service to be presented in the first page, and feeding back the service data to a server.
Optionally, the obtaining unit 930 is further configured to:
after receiving the loading response message, obtaining an origin attribute of the loading response message;
based on the origin attribute, it is determined that the load response message is returned by the second page.
Optionally, if a plurality of corresponding service requests are triggered for a plurality of services to be presented in the first page, a loading request message corresponding to the service request is generated in response to the service request triggered for the services to be presented in the first page, and the loading request message is sent to the second page through the communication channel, where the second response unit 920 is configured to:
responding to corresponding service requests triggered by a plurality of services to be presented in the first page, and correspondingly generating respective loading request messages of the service requests, wherein each loading request message at least comprises a service identifier of the corresponding service to be presented and a corresponding loading message attribute identifier;
Constructing a message set based on the plurality of loading request messages, and respectively sending the plurality of loading request messages to a plurality of second pages through the communication channel, so that the plurality of second pages load corresponding service data of the service to be presented based on the respective corresponding loading request messages;
removing a corresponding loading request message from the message set based on a loading message attribute identifier carried by the loading response message after receiving the loading response message returned by one second page;
and when the fact that all the plurality of loading request messages in the message set are removed is determined, releasing the space occupied by the message set.
Optionally, the loading message attribute identifier carried by each loading response message is uniquely set and fixed for the corresponding service to be presented.
Based on the same inventive concept, referring to fig. 10, an embodiment of the present application provides a computer device, for example, an electronic device 1000 may be a mobile phone, a computer, a digital broadcasting terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
Referring to fig. 10, an electronic device 1000 may include one or more of the following components: a processing component 1002, a memory 1004, a power component 1006, a multimedia component 1008, an audio component 1010, an input/output (I/O) interface 1012, a sensor component 1014, and a communication component 1016.
The processing component 1002 generally controls overall operation of the electronic device 1000, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 1002 can include one or more processors 1020 to execute instructions to perform all or part of the steps of the methods described above. Further, the processing component 1002 can include one or more modules that facilitate interaction between the processing component 1002 and other components. For example, the processing component 1002 can include a multimedia module to facilitate interaction between the multimedia component 1008 and the processing component 1002.
The memory 1004 is configured to store various types of data to support operations at the electronic device 1000. Examples of such data include instructions for any application or method operating on the electronic device 1000, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 1004 may be implemented by any type or combination of volatile or nonvolatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
The power supply component 1006 provides power to the various components of the electronic device 1000. The power components 1006 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 1000.
The multimedia component 1008 includes a screen between the electronic device 1000 and the user that provides an output interface. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may sense not only the boundary of a touch or slide action, but also the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia assembly 1008 includes a front-facing camera and/or a rear-facing camera. When the electronic device 1000 is in an operational mode, such as a shooting mode or a video mode, the front-facing camera and/or the rear-facing camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
The audio component 1010 is configured to output and/or input audio signals. For example, the audio component 1010 includes a Microphone (MIC) configured to receive external audio signals when the electronic device 1000 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may be further stored in memory 1004 or transmitted via communication component 1016. In some embodiments, the audio component 1010 further comprises a speaker for outputting audio signals.
The I/O interface 1012 provides an interface between the processing assembly 1002 and peripheral interface modules, which may be a keyboard, click wheel, buttons, and the like. These buttons may include, but are not limited to: homepage button, volume button, start button, and lock button.
The sensor assembly 1014 includes one or more sensors for providing status assessment of various aspects of the electronic device 1000. For example, the sensor assembly 1014 may detect an on/off state of the electronic device 1000, a relative positioning of components such as a display and keypad of the electronic device 1000, the sensor assembly 1014 may also detect a change in position of the electronic device 1000 or a component of the electronic device 1000, the presence or absence of a user's contact with the electronic device 1000, an orientation or acceleration/deceleration of the electronic device 1000, and a change in temperature of the electronic device 1000. The sensor assembly 1014 may include a proximity sensor configured to detect the presence of nearby objects in the absence of any physical contact. The sensor assembly 1014 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1014 can also include an acceleration sensor, a gyroscopic sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 1016 is configured to facilitate communication between the electronic device 1000 and other devices, either wired or wireless. The electronic device 1200 may access a wireless network based on a communication standard, such as WiFi, an operator network (e.g., 2G, 3G, 4G, or 5G), or a combination thereof. In one exemplary embodiment, the communication component 1016 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 1016 further includes a Near Field Communication (NFC) module to facilitate short range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the electronic device 1000 may be implemented by one or more Application Specific Integrated Circuits (ASICs), digital Signal Processors (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic elements for executing any one of the methods performed by the computer apparatus in the embodiments described above.
Based on the same inventive concept, the present disclosure provides a computer-readable storage medium, which when executed by a processor, is capable of performing any one of the methods performed by the computer apparatus in the above embodiments.
Based on the same inventive concept, the embodiments of the present disclosure provide a computer program product comprising executable instructions that, when executed by a processor, enable to implement any one of the methods performed by the computer device as in the embodiments described above.
In summary, in the embodiment of the present disclosure, when the terminal device determines that a preset trigger condition is met, a communication channel is established between a first page and a second page, and then, based on the communication channel, a loading request message corresponding to a service request is generated in response to the service request triggered in the first page for a service to be presented, and the loading request message is sent to the second page, and after it is determined that a loading response message carrying a loading message attribute identifier returned by the second page is received, service data of the service to be presented loaded by the second page is obtained through the communication channel, where the loading request message at least includes the loading message attribute identifier, so that the terminal device can improve page communication efficiency by establishing the communication channel for the first page and the second page, and also can enable the first page or/and the second page to timely sense an abnormal condition of the other party, thereby guaranteeing the security communication of the iframe technology; then, in response to the service request triggered by the service to be presented in the first page, the corresponding loading message attribute identifier is configured for the loading request message generated corresponding to the service request, and after the loading request message is sent to the second page, a corresponding monitoring server or device does not need to be specially configured, so that the safety of page communication is enhanced, the network architecture is optimized, and network resources are saved.
It will be apparent to those skilled in the art that embodiments of the present disclosure may be provided as a method, system, or computer program product. Accordingly, the present disclosure may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present disclosure may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
The present disclosure is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the disclosure. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While the preferred embodiments of the present disclosure have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the disclosure.
It will be apparent to those skilled in the art that various modifications and variations can be made to the disclosed embodiments without departing from the spirit and scope of the disclosed embodiments. Thus, given that such modifications and variations of the disclosed embodiments fall within the scope of the claims of the present disclosure and their equivalents, the present disclosure is also intended to encompass such modifications and variations.

Claims (23)

1. A method of page communication, comprising:
when the preset triggering condition is determined to be met, a communication channel is established between the first page and the second page;
responding to a service request triggered by a service to be presented in the first page, generating a loading request message corresponding to the service request, and sending the loading request message to the second page through the communication channel, so that the second page loads the service data of the service to be presented based on the loading request message, wherein the loading request message at least comprises a service identifier and a loading message attribute identifier of the service to be presented;
when the loading response message returned by the second page is determined to carry the loading message attribute identifier, acquiring service data of the service to be presented loaded by the second page through the communication channel;
When the determination meets the preset triggering condition, a communication channel is established between the first page and the second page, and the method comprises the following steps:
when the preset triggering condition is determined to be met, the following operations are circularly executed until the fact that the creation response message returned by the second page is received and carrying the creation message attribute identifier is determined:
generating a creation channel message for establishing a communication channel between the first page and the second page, wherein the creation channel message at least comprises a creation message attribute identifier;
sending the creation channel message to the second page through an asynchronous message delivery function application programming interface;
judging whether a creation response message carrying the creation message attribute identifier is received or not;
and determining that the establishment of the communication channel between the first page and the second page is completed based on the received creation response message carrying the creation message attribute identifier.
2. The method of claim 1, wherein the determining that the preset trigger condition is met comprises:
when a communication request aiming at the second page, which is triggered in the first page, is received, a preset triggering condition is determined to be met; or,
When a communication request triggered by a preset thread is received, the preset triggering condition is determined to be met.
3. The method of claim 2, wherein the first page is a parent page and the second page is a child page;
or,
the first page is a sub page, and the second page is a parent page.
4. The method as recited in claim 1, further comprising:
after receiving the creation response message, searching for a source attribute of the creation response message, and determining that the creation response message is returned by the second page based on the source attribute.
5. The method of claim 1, wherein the determining whether a create response message carrying the create message attribute identification is received further comprises:
if it is determined that the creation response message carrying the creation message attribute identifier is not received, a timer set for receiving the creation response message is overtime, and it is determined that the judgment number does not reach the set threshold, the creation message attribute identifier is updated.
6. The method of claim 5, wherein said determining whether a create response message carrying the create message attribute identification is received further comprises:
And if the establishment response message carrying the creation message attribute identifier is not received and the judgment times reach the set threshold value, determining that the establishment of the communication channel between the first page and the second page fails.
7. The method of claim 1, wherein when it is determined that the loading response message returned by the second page carries the loading message attribute identifier, after obtaining, through the communication channel, service data of the service to be presented loaded by the second page, further includes:
displaying the service data of the service to be presented in the first page; or,
and displaying the service data of the service to be presented in the first page, and feeding back the service data to a server.
8. The method of any one of claims 1-7, further comprising:
after receiving the loading response message, obtaining the source attribute of the loading response message;
based on the source attribute, it is determined that the load response message is returned by the second page.
9. The method according to any one of claims 1-7, wherein if a plurality of service requests are triggered in the first page for a plurality of services to be presented, generating a load request message corresponding to the service request in response to the service request triggered in the first page for the services to be presented, and sending the load request message to the second page through the communication channel, including:
Responding to corresponding service requests triggered by a plurality of services to be presented in the first page, and correspondingly generating respective loading request messages of the service requests, wherein each loading request message at least comprises a service identifier of the corresponding service to be presented and a corresponding loading message attribute identifier;
constructing a message set based on the plurality of loading request messages, and respectively sending the plurality of loading request messages to a plurality of second pages through the communication channel, so that the plurality of second pages load corresponding service data of the service to be presented based on the respective corresponding loading request messages;
removing a corresponding loading request message from the message set based on a loading message attribute identifier carried by the loading response message after receiving the loading response message returned by one second page;
and when the fact that all the plurality of loading request messages in the message set are removed is determined, releasing the space occupied by the message set.
10. The method of claim 9, wherein the loading message attribute identifier carried by each loading response message is uniquely set and fixed for the corresponding service to be presented.
11. An apparatus for page communication, comprising:
the determining unit is used for establishing a communication channel between the first page and the second page when the preset triggering condition is determined to be met;
the response unit is used for responding to a service request triggered by a service to be presented in the first page, generating a loading request message corresponding to the service request, and sending the loading request message to the second page through the communication channel so that the second page loads the service data of the service to be presented based on the loading request message, wherein the loading request message at least comprises a service identifier of the service to be presented and a loading message attribute identifier;
the acquiring unit is used for acquiring the service data of the service to be presented loaded by the second page through the communication channel when the loading response message returned by the second page is determined to carry the loading message attribute identifier;
when the determination meets a preset trigger condition, a communication channel is established between the first page and the second page, and the determination unit is used for:
when the preset triggering condition is determined to be met, the following operations are circularly executed until the fact that the creation response message returned by the second page is received and carrying the creation message attribute identifier is determined:
Generating a creation channel message for establishing a communication channel between the first page and the second page, wherein the creation channel message at least comprises a creation message attribute identifier;
the asynchronous message delivery function application programming interface is used for programming the message
Creating a channel message to the second page;
judging whether a creation response message carrying the creation message attribute identifier is received or not;
and determining that the establishment of the communication channel between the first page and the second page is completed based on the received creation response message carrying the creation message attribute identifier.
12. The apparatus of claim 11, wherein the determining unit is configured to, when the determination meets a preset trigger condition:
when a communication request aiming at the second page, which is triggered in the first page, is received, a preset triggering condition is determined to be met; or,
when a communication request triggered by a preset thread is received, the preset triggering condition is determined to be met.
13. The apparatus of claim 12, wherein the first page is a parent page and the second page is a child page;
or,
the first page is a sub page, and the second page is a parent page.
14. The apparatus of claim 11, wherein the determining unit is further to:
after receiving the creation response message, searching for a source attribute of the creation response message, and determining that the creation response message is returned by the second page based on the source attribute.
15. The apparatus of claim 11, wherein the determining whether a create response message is received that carries the create message attribute identification, the determining further to:
if it is determined that the creation response message carrying the creation message attribute identifier is not received, a timer set for receiving the creation response message is overtime, and it is determined that the judgment number does not reach the set threshold, the creation message attribute identifier is updated.
16. The apparatus of claim 15, wherein the determining whether a create response message carrying the create message attribute identification is received, the determining unit further to:
and if the establishment response message carrying the creation message attribute identifier is not received and the judgment times reach the set threshold value, determining that the establishment of the communication channel between the first page and the second page fails.
17. The apparatus of claim 11, wherein, when it is determined that the loading response message returned by the second page carries the loading message attribute identifier, after acquiring, through the communication channel, service data of the service to be presented loaded by the second page, the acquiring unit is further configured to:
displaying the service data of the service to be presented in the first page; or,
and displaying the service data of the service to be presented in the first page, and feeding back the service data to a server.
18. The apparatus of any one of claims 11-17, wherein the acquisition unit is further configured to:
after receiving the loading response message, obtaining the source attribute of the loading response message;
based on the source attribute, it is determined that the load response message is returned by the second page.
19. The apparatus according to any of claims 11-17, wherein if a respective plurality of service requests are triggered in the first page for a plurality of services to be presented, a load request message corresponding to the service request is generated in response to the service request triggered in the first page for the services to be presented, and the load request message is sent to the second page through the communication channel, and the response unit is configured to:
Responding to corresponding service requests triggered by a plurality of services to be presented in the first page, and correspondingly generating respective loading request messages of the service requests, wherein each loading request message at least comprises a service identifier of the corresponding service to be presented and a corresponding loading message attribute identifier;
constructing a message set based on the plurality of loading request messages, and respectively sending the plurality of loading request messages to a plurality of second pages through the communication channel, so that the plurality of second pages load corresponding service data of the service to be presented based on the respective corresponding loading request messages;
removing a corresponding loading request message from the message set based on a loading message attribute identifier carried by the loading response message after receiving the loading response message returned by one second page;
and when the fact that all the plurality of loading request messages in the message set are removed is determined, releasing the space occupied by the message set.
20. The apparatus of claim 19, wherein the loading message attribute identification carried by each loading response message is uniquely set and fixed for the corresponding service to be presented.
21. A computer apparatus, comprising:
a memory for storing executable instructions;
a processor for reading and executing executable instructions stored in said memory to implement the method of any one of claims 1-10.
22. A computer readable storage medium, characterized in that instructions in the computer readable storage medium, when executed by a processor, enable the processor to perform the method of any one of claims 1-10.
23. A computer program product comprising executable instructions which, when executed by a processor, are capable of implementing the method of any of claims 1-10.
CN202110593645.0A 2021-05-28 2021-05-28 Page communication method and device Active CN113238881B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110593645.0A CN113238881B (en) 2021-05-28 2021-05-28 Page communication method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110593645.0A CN113238881B (en) 2021-05-28 2021-05-28 Page communication method and device

Publications (2)

Publication Number Publication Date
CN113238881A CN113238881A (en) 2021-08-10
CN113238881B true CN113238881B (en) 2024-01-30

Family

ID=77135545

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110593645.0A Active CN113238881B (en) 2021-05-28 2021-05-28 Page communication method and device

Country Status (1)

Country Link
CN (1) CN113238881B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114827231B (en) * 2022-04-11 2023-09-26 杭州指令集智能科技有限公司 Method and system for realizing multi-window point-to-point communication based on browser local storage
CN115794634B (en) * 2022-11-29 2023-12-01 北京五八信息技术有限公司 Communication method and device of application program, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102307220A (en) * 2011-03-18 2012-01-04 北京神州数码思特奇信息技术股份有限公司 Cross-domain webpage information interaction method
CN104572263A (en) * 2014-12-30 2015-04-29 腾讯科技(深圳)有限公司 Page data interaction method, related device and system
CN107688570A (en) * 2016-08-03 2018-02-13 腾讯科技(深圳)有限公司 A kind of page info processing method and system
EP3429273A1 (en) * 2016-04-01 2019-01-16 Huawei Technologies Co., Ltd. Method of transmitting communication message, and device
CN112182442A (en) * 2020-09-28 2021-01-05 湖南亚信软件有限公司 Page processing method and device, electronic equipment and computer readable storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102307220A (en) * 2011-03-18 2012-01-04 北京神州数码思特奇信息技术股份有限公司 Cross-domain webpage information interaction method
CN104572263A (en) * 2014-12-30 2015-04-29 腾讯科技(深圳)有限公司 Page data interaction method, related device and system
EP3429273A1 (en) * 2016-04-01 2019-01-16 Huawei Technologies Co., Ltd. Method of transmitting communication message, and device
CN107688570A (en) * 2016-08-03 2018-02-13 腾讯科技(深圳)有限公司 A kind of page info processing method and system
CN112182442A (en) * 2020-09-28 2021-01-05 湖南亚信软件有限公司 Page processing method and device, electronic equipment and computer readable storage medium

Also Published As

Publication number Publication date
CN113238881A (en) 2021-08-10

Similar Documents

Publication Publication Date Title
US10216711B2 (en) Information collection method and apparatus
CN107229711B (en) Webpage display method and device
US9485358B2 (en) Information acquisition method, device, and system
CN113238881B (en) Page communication method and device
CN108153832B (en) Push information display method and device
CN109525652B (en) Information sharing method, device, equipment and storage medium
CN109034747B (en) Task reminding method and device
CN109117144B (en) Page processing method, device, terminal and storage medium
CN111639276A (en) Resource preloading method and device and storage medium
CN107402767B (en) Method and device for displaying push message
CN108933947B (en) Bullet screen display method and device
CN104572230B (en) Script file loading method and device and script file generating method and device
CN105808304B (en) Code deployment method, device and system
CN111695064B (en) Buried point loading method and device
CN115373763B (en) Plug-in loading method and device, electronic equipment and storage medium
CN114339320B (en) Virtual resource processing method, device, equipment and storage medium
CN105630948A (en) Web page display method and apparatus
CN111723353A (en) Identity authentication method, device, terminal and storage medium based on face recognition
CN112416707B (en) Link detection method and device
CN110457084B (en) Loading method and device
CN112883314A (en) Request processing method and device
CN107257384B (en) Service state monitoring method and device
CN112073818A (en) Information processing method and device
CN111724398A (en) Image display method and device
CN113486281B (en) Page display method and device, electronic equipment and storage medium

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