CN116016477A - Method, device, equipment and storage medium for connecting browser pages - Google Patents
Method, device, equipment and storage medium for connecting browser pages Download PDFInfo
- Publication number
- CN116016477A CN116016477A CN202211690464.0A CN202211690464A CN116016477A CN 116016477 A CN116016477 A CN 116016477A CN 202211690464 A CN202211690464 A CN 202211690464A CN 116016477 A CN116016477 A CN 116016477A
- Authority
- CN
- China
- Prior art keywords
- storage space
- local storage
- long connection
- browser page
- page
- 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.)
- Pending
Links
Images
Landscapes
- Information Transfer Between Computers (AREA)
Abstract
The application provides a method, a device, equipment and a storage medium for connecting browser pages, wherein the method comprises the steps of determining whether a long connection mark for a server to send an event exists in a local storage space when one browser page is opened; when the long connection mark for the server to send the event exists in the local storage space, storing the identity of the browser page into the local storage space, wherein the browser page and the opened browser page share long connection; and monitoring the stored data in the local storage space, and pushing the stored data to the browser page and the opened browser page. The method can achieve the effects of avoiding the plurality of long connections from occupying the connection number and improving the loading speed of the pages of the multi-open browser.
Description
Technical Field
The present invention relates to the field of browser page connection, and in particular, to a method, an apparatus, a device, and a storage medium for connecting browser pages.
Background
At present, when one browser application page is newly opened under the multi-page scene, the application can newly establish one long connection again, so that two application pages always occupy two hypertext transfer protocol connection numbers, and the number of the hypertext transfer protocol connection numbers can be increased every time one more application page is opened.
In addition, when a plurality of pages are opened, part of the pages are always in a loading state, so that the pages cannot be displayed normally.
Therefore, how to avoid the situation that a plurality of long connections occupy the number of connections and improve the loading speed of the pages of the multi-open browser is a technical problem to be solved.
Disclosure of Invention
An object of the embodiments of the present application is to provide a method for connecting a browser page, by which the effect of improving the number of connections between the browser page can be achieved.
In a first aspect, an embodiment of the present application provides a method for connecting browser pages, including determining, when a browser page is opened, whether a long connection flag for a server to send an event exists in a local storage space; when the long connection mark for the server to send the event exists in the local storage space, storing the identity of the browser page into the local storage space, wherein the browser page and the opened browser page share long connection; and monitoring the stored data in the local storage space, and pushing the stored data to the browser page and the opened browser page.
In the embodiment, the identity identifiers of the different browser pages are stored in the same local storage space, and the different browser pages can share one long connection, so that a plurality of browser pages can receive push data at the same time.
In some embodiments, after determining whether there is a long connection flag in the local storage space for the server send event, further comprising:
when the fact that the long connection mark for sending the event by the server does not exist in the local storage space is determined, establishing event long connection for connecting the browser page;
and storing the identity mark corresponding to the browser page in a local storage space, and pushing stored data to the browser page and the opened browser page.
In the above embodiment, when no long connection flag exists in the local storage space, a long connection may be established when a new browser page is opened, and the newly opened browser page may be connected through the established long connection.
In some embodiments, determining whether there is a long connection flag in the local storage space for the server to send the event includes:
determining whether a preset field for storing long connection exists in the local storage space;
when the preset field for storing long connection exists in the local storage space, determining whether the preset field is an identity of a browser page or not;
determining that there is a long connection flag in the local storage space for a server send event, comprising:
And determining that the preset field is not the identity of the browser page.
In the above embodiment, whether the long connection flag exists in the local storage space may be determined by whether the preset field in the local storage space is a browser page, so that a new long connection may be established or a long connection may be shared with the existing browser page when a new browser page is opened later.
In some embodiments, storing the identity of the browser page in the local storage space includes:
the method comprises the steps of storing the identity of a browser page into a preset identity in a local storage space, and monitoring the preset identity in the local storage space, wherein the identity in the local storage space is used for selecting one identity from the local storage space in a traversing mode when the established long connection is disconnected, and reestablishing the long connection through the browser page corresponding to the selected identity.
In the embodiment, the identity of the browser page is stored in the preset identity in the local storage space, so that a long connection can be reestablished through the browser page corresponding to the identity, and the transfer of the long connection is realized.
In some embodiments, before determining that there is a long connection flag in the local storage space for the server send event, further comprising:
and generating an identity identifier corresponding to the browser page, wherein the identity identifier is obtained by traversing all the identity identifiers stored in the local storage space, and each identity identifier in the identity identifier and all the identity identifiers is different.
In the embodiment of the application, whether the long connection mark exists in the local storage space can be accurately determined through the generated unique identity mark.
In some embodiments, monitoring stored data in a local storage space includes:
monitoring a long connection mark stored in a local storage space, and determining whether the long connection is disconnected or not through the current state of the long connection;
and when the long connection is determined to be disconnected, reconnecting the long connection through a preset function until the long connection is completely reconnected.
In the embodiment, the disconnected long connection can be reconnected, so that the message can be pushed to the browser page smoothly.
In some embodiments, after monitoring the stored data in the local storage space and pushing the stored data to the browser page and the opened browser page, further comprising:
When the browser page is closed, deleting the identity mark from the local storage space, and determining whether the browser page is a long connection page or not;
when the browser page is determined to be a long connection page, determining whether an opened browser page except the browser page exists;
when the open browser pages except the browser pages are determined to exist, the identity of one of the open browser pages is updated to a preset field in the local storage space.
In the embodiment, resources can be saved by deleting the unused long connection of the browser, and a new long connection can be established in time when only the long connection is closed, so that the smoothness of receiving the message by the browser can be ensured.
In a second aspect, an embodiment of the present application provides an apparatus for connecting a browser page, including:
the determining module is used for determining whether a long connection mark for a server to send an event exists in the local storage space when one browser page is opened;
the connection module is used for storing the identity of the browser page into the local storage space when the long connection mark for the server to send the event exists in the local storage space, wherein the browser page and the opened browser page share long connection;
And the pushing module is used for monitoring the stored data in the local storage space and pushing the stored data to the browser page and the opened browser page.
Optionally, the apparatus further includes:
the establishing module is used for establishing event long connection for connecting a browser page when the long connection mark for the server to send the event does not exist in the local storage space after the long connection mark for the server to send the event is determined to exist in the local storage space;
and storing the identity mark corresponding to the browser page in a local storage space, and pushing stored data to the browser page and the opened browser page.
Optionally, the determining module is specifically configured to:
determining whether a preset field for storing long connection exists in the local storage space;
when the preset field for storing long connection exists in the local storage space, determining whether the preset field is an identity of a browser page or not;
the determining module is specifically configured to:
and determining that the preset field is not the identity of the browser page.
Optionally, the connection module is specifically configured to:
the method comprises the steps of storing the identity of a browser page into a preset identity in a local storage space, and monitoring the preset identity in the local storage space, wherein the identity in the local storage space is used for selecting one identity from the local storage space in a traversing mode when the established long connection is disconnected, and reestablishing the long connection through the browser page corresponding to the selected identity.
Optionally, the apparatus further includes:
the generation module is used for generating the identity mark corresponding to the browser page before the determination module determines that the long connection mark for the event sent by the server exists in the local storage space, wherein the identity mark is obtained by traversing all the identity marks stored in the local storage space, and each identity mark in the identity mark and all the identity marks is different.
Optionally, the pushing module is specifically configured to:
monitoring a long connection mark stored in a local storage space, and determining whether the long connection is disconnected or not through the current state of the long connection;
and when the long connection is determined to be disconnected, reconnecting the long connection through a preset function until the long connection is completely reconnected.
Optionally, the apparatus further includes:
the updating module is used for deleting the identity mark from the local storage space and determining whether the browser page is a long connection page or not when the browser page is closed after the pushing module monitors the storage data in the local storage space and pushes the storage data to the browser page and the opened browser page;
when the browser page is determined to be a long connection page, determining whether an opened browser page except the browser page exists;
When the open browser pages except the browser pages are determined to exist, the identity of one of the open browser pages is updated to a preset field in the local storage space.
In a third aspect, embodiments of the present application provide an electronic device comprising a processor and a memory storing computer readable instructions that, when executed by the processor, perform the steps of the method as provided in the first aspect above.
In a fourth aspect, embodiments of the present application provide a readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of the method as provided in the first aspect above.
Additional features and advantages of the application will be set forth in the description which follows, and in part will be apparent from the description, or may be learned by practice of the embodiments of the application. The objectives and other advantages of the application will be realized and attained by the structure particularly pointed out in the written description and claims thereof as well as the appended drawings.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a method for connecting browser pages according to an embodiment of the present application;
FIG. 2 is a flowchart of an implementation method for connecting browser pages according to an embodiment of the present application;
FIG. 3 is a schematic block diagram of an apparatus for connecting browser pages according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a device for connecting a browser page according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. The components of the embodiments of the present application, as generally described and illustrated in the figures herein, may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, as provided in the accompanying drawings, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present application without making any inventive effort, are intended to be within the scope of the present application.
It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further description thereof is required in subsequent figures
Definition and interpretation. Meanwhile, in the description of the present application, the terms "first", "second", and the like are used only to distinguish 5 descriptions, and are not to be construed as indicating or implying relative importance.
Some of the terms referred to in the embodiments of the present application will be described first to facilitate understanding by those skilled in the art.
HTTP: the hypertext transfer protocol (Hyper Text Transfer Protocol, HTTP) is one
A simple request-response protocol, which typically runs on top of TCP. It specifies what messages the client might send 0 to the server and what responses get.
The SSE server sends an event (server-send event) that allows the web page to obtain updates from the server.
LocalStorage: for use as local storage, the problem of insufficient cookie storage space (the storage space of each cookie in the cookie is 4 k), and the general browser 5 in the localStorage supports 5M size, which is different in different browsers.
The method and the device are applied to the scene of browser page connection, and the specific scene is to improve the number of browser page connection in a mode that a plurality of browser pages share one long connection.
However, at present, when a browser application page is newly opened in the multi-page scenario, the application will newly create a long connection again, so that two application pages always occupy two hypertext transfer 0 protocol connection numbers, and thus it can be deduced that one hypertext transfer is increased every time an application page is opened
Protocol connection number. In addition, when a plurality of pages are opened, part of the pages are always in a loading state, so that the pages cannot be displayed normally.
For this purpose, when a browser page is opened, it is determined whether a local storage space exists
A long connection flag for a server to send an event; when the long connection mark for the event sent by the server 5 exists in the local storage space, the identity of the browser page is stored in the local storage space
Wherein the browser page and the opened browser page share a long connection; and monitoring the stored data in the local storage space, and pushing the stored data to the browser page and the opened browser page. The identity identifiers of the different browser pages are stored in the same local storage space, and the different browser pages can share one long connection, so that the different browsers can receive push data simultaneously.
In this embodiment of the present application, the execution body may be a connection browser page device in a connection browser page system, and in practical application, the connection browser page device may be electronic devices such as a terminal device and a server, which is not limited herein.
The method for connecting the browser page according to the embodiment of the present application is described in detail below with reference to fig. 1.
Referring to fig. 1, fig. 1 is a flowchart of a method for connecting browser pages according to an embodiment of the present application, where the method for connecting browser pages shown in fig. 1 includes:
step 110: when a browser page is opened, it is determined whether there is a long connection flag in the local storage space for the server to send an event.
The local storage space (LocalStorage) comprises a flag for a long connection connected with the browser page, wherein the long connection flag can be a preset field of the long connection, and the long connection is used for a server to send events to the browser page, and the events can be data messages requested by some users or messages automatically pushed by some servers.
In some embodiments of the present application, the method shown in fig. 1 further includes, prior to determining that there is a long connection flag in the local storage space for the server send event: and generating an identity identifier corresponding to the browser page, wherein the identity identifier is obtained by traversing all the identity identifiers stored in the local storage space, and each identity identifier in the identity identifier and all the identity identifiers is different.
In the process, whether the long connection mark exists in the local storage space can be accurately determined through the generated unique identity mark.
The Identity (ID) may be a name, number, code or the like representing the browser page, and when the browser application page starts to be loaded, an ID is generated for the current page, and the ID is stored in the LocalStorage, where the ID is used as a unique identifier of the current web page. Specifically, starting from the first browser page, when confirming the page ID, traversing whether an opened page ID exists in the LocalStorage, and if so, replacing the ID until the ID with the corresponding value does not exist in the LocalStorage, thereby obtaining a unique ID value.
In some embodiments of the present application, determining whether there is a long connection flag in the local storage space for a server send event includes: determining whether a preset field for storing long connection exists in the local storage space; when the preset field for storing long connection exists in the local storage space, determining whether the preset field is an identity of a browser page or not; determining that there is a long connection flag in the local storage space for a server send event, comprising: and determining that the preset field is not the identity of the browser page.
In the above process, whether a long connection mark exists in the local storage space can be determined by whether a preset field in the local storage space is a browser page, so that a new long connection can be established or a long connection can be shared with the existing browser page when a new browser page is opened later.
The preset field may be used to store a field corresponding to the long connection, where the field includes an identity of the browser page.
In some embodiments of the present application, after determining whether there is a long connection flag in the local storage space for the server send event, the method shown in fig. 1 further includes: when the fact that the long connection mark for sending the event by the server does not exist in the local storage space is determined, establishing event long connection for connecting the browser page; and storing the identity mark corresponding to the browser page in a local storage space, and pushing stored data to the browser page and the opened browser page.
In the above process, when no long connection mark exists in the local storage space, a long connection can be established when a new browser page is opened, and for this purpose, message data can be pushed to the browser page through the long connection.
The storage data may be a push message sent by the server to the browser page, and the push message may be a message notification that the user requests the server.
Step 120: and when the long connection mark for the server sending event exists in the local storage space, storing the identity mark of the browser page into the local storage space.
Wherein the browser page and the opened browser page share a long connection.
In some embodiments of the present application, storing the identity of the browser page in the local storage space includes: the method comprises the steps of storing the identity of a browser page into a preset identity in a local storage space, and monitoring the preset identity in the local storage space, wherein the identity in the local storage space is used for selecting one identity from the local storage space in a traversing mode when the established long connection is disconnected, and reestablishing the long connection through the browser page corresponding to the selected identity.
In the process, the identity of the browser page is stored in the preset identity in the local storage space, and the long connection can be reestablished through the browser page corresponding to the identity, so that the long connection is transferred.
Wherein monitoring the data in the local storage space includes detecting long connection flags and pushing data. When loading of the browser page is completed, judgment needs to be carried out before SSE long connection is established, the value of a specific field (e.g. sse_active) in the LocalStorage is queried, the meaning of the field is that the ID of the browser page with the established SSE long connection is recorded, if the fact that x (x is not the ID of the current page) of the field is queried, the page with the ID x has established SSE long connection, the current application page does not need to be established again, then the current page skips the step of establishing SSE long connection, and monitoring of the field representing push information and the SSE long connection in the LocalStorage is only needed to be added. If the value of the field is found to be null or not exist, it represents that no page has established an SSE long connection currently, the current page is required to establish the SSE long connection and store own ID in the field (sse_active), and after the SSE long connection is established, the message received and pushed needs to be stored in a specific field in the LocalStorage (for example, sse_message). Message sharing is achieved by listening to changes in the specific field (sse_message) value in the LocalStorage without the need to establish additional connection channels.
Step 130: and monitoring the stored data in the local storage space, and pushing the stored data to the browser page and the opened browser page.
Wherein the stored data comprises a number of push messages.
In some embodiments of the present application, monitoring stored data in a local storage space includes:
monitoring a long connection mark stored in a local storage space, and determining whether the long connection is disconnected or not through the current state of the long connection; and when the long connection is determined to be disconnected, reconnecting the long connection through a preset function until the long connection is completely reconnected.
In the process, the disconnected long connection can be reconnected, so that smooth message pushing to the browser page is ensured.
In some embodiments of the present application, after monitoring the stored data in the local storage space and pushing the stored data to the browser page and the opened browser page, the method shown in fig. 1 further includes: when the browser page is closed, deleting the identity mark from the local storage space, and determining whether the browser page is a long connection page or not; when the browser page is determined to be a long connection page, determining whether an opened browser page except the browser page exists; when the open browser pages except the browser pages are determined to exist, the identity of one of the open browser pages is updated to a preset field in the local storage space.
In the process, resources can be saved by deleting the unused long connection of the browser, and a new long connection can be established in time when only the long connection is closed, so that the smoothness of receiving the message by the browser can be ensured.
For example: when the current page is closed, firstly deleting the ID of the current page from a LocalStorage, if the current page is the page for establishing SSE long connection, finding out the IDs of other pages by a method for traversing the LocalStorage, if the ID of any one of the other pages is found to be y (the first conforming condition is found by a traversing method), updating y into a field sse_active, comparing the ID of the other pages with y after the other pages monitor that the change of the sse_active value is y, and if the value of the page with the ID of y finds that the value in sse_active is consistent with the ID of the other pages, the page y is used for establishing SSE connection, and the other pages do not do any operation; if not, the application only opens the current page and does not have multiple pages, so that the next page for establishing SSE long connection is not required to be designated, and the value of the sse_active field in the LocalStorage is directly cleared.
Fig. 1 illustrates an application scenario: the first browser page is started, at this time, no other page ID exists in the LocalStorage, so the unique ID value generated by this page is 1. Data with a field name of sse_id_1 and a value of 1 is stored in the LocalStorage, at this time, the value of the sse_active field is read from the LocalStorage to be null, which means that no page establishes an SSE long connection at this time, so that the current page with the ID of 1 updates the self ID "1" into the sse_active field and establishes the SSE long connection, and an anomaly monitoring function is set. And opening a second page, wherein the ID 1 of the page exists in the LocalStorage, so that the generated ID is 2, the field name is sse_id_2, the data with the value of 2 is stored in the LocalStorage, the value of the sse_active field is 1 in the LocalStorage, the page with the ID of 1 at this time has established SSE long connection, the current page is not required to be established any more, and monitoring of the two fields of sse_active and sse_message in the LocalStorage is only required to be added. The third page is opened, at this time, pages ID 1 and 2 already exist in the LocalStorage, so the generated ID is 3, and the subsequent operation is the same as the page with ID 2. At this time, the background pushes the message x, and the page 1 can directly receive the push message x because of the establishment of the SSE long connection, and after receiving the message, the page 1 places the message x under the sse_message field in the LocalStorage, and at this time, the page 2 and the page 3 monitor that the value of the sse_message field changes to x, and the push message x is fetched from the field. In this case, the network jitter abnormal condition causes a poor network state, the SSE long connection is accidentally disconnected, the abnormal monitoring function set by the original page 1 when the SSE long connection is established is triggered, the value of the sse_active field is 1 and is the ID of the current page, so that the SSE long connection is continuously attempted to be reestablished until the SSE long connection is successfully established, and the maintenance and pushing function can be kept normal after the abnormal condition is encountered. At this time, page 1 is closed, page 1 deletes its own sse_id_1 field from the LocalStorage, and at this time, the value of the sse_active field read from the LocalStorage is 1, which is the ID of the current page itself, so it is necessary to specify the next page to be connected with the SSE long after the current page is closed, at this time, page 1 finds the first field beginning with sse_id_by traversing the fields in the LocalStorage (the field beginning with sse_id represents that this field is other page IDs), assuming that the first found is the sse_id_3 field, page 1 updates the value of the sse_active field to 3, and then page 1 is closed. After the page 1 is closed, both the page 2 and the page 3 monitor the change of the sse_active field in the LocalStorage, both the two pages take the value in the sse_active to judge, the page 2 judges that the value of the sse_active is 3 and the ID of the page is not equal to the ID of the page itself, no operation is performed, the page 3 finds that the value of the sse_active is 3 and the ID of the page itself is equal to the ID of the page 3, and therefore the page 3 needs to execute the operation of establishing a new SSE long connection. At this time, an application page is newly opened, and when the unique ID is generated, the current page finds that the LocalStorage has no ssejd_1 field, which represents that ID 1 can be used, so that the ID of the newly opened page is 1 (new page 1), and the subsequent operations are the same as those of page 2. And closing the page 1 and the page 2, wherein only the page 3 with the SSE long connection is left, closing the page 3, deleting the self ID from the LocalStorage by the page 3, and at the moment, because the value in the sse_active field is 3, the page 3 is required to specify the next page with the SSE long connection, but the field at the beginning of the sse_id is not found when the page 3 traverses the field in the LocalStorage, and at the moment, directly closing after the value of the sse_active field is cleared by the page 3.
In the process shown in fig. 1, when a browser page is opened, it is determined whether a long connection flag for a server transmission event exists in the local storage space; when the long connection mark for the server to send the event exists in the local storage space, storing the identity of the browser page into the local storage space, wherein the browser page and the opened browser page share long connection; and monitoring the stored data in the local storage space, and pushing the stored data to the browser page and the opened browser page. The identity identifiers of the different browser pages are stored in the same local storage space, and the different browser pages can share one long connection, so that the different browsers can receive push data simultaneously.
The following describes in detail the implementation method of connecting the browser page according to the embodiment of the present application with reference to fig. 2.
Referring to fig. 2, fig. 2 is a flowchart of an implementation method for connecting a browser page according to an embodiment of the present application, where the implementation method for connecting a browser page shown in fig. 2 includes:
Step 210: and generating an identity corresponding to the browser page.
Specific: and generating the identity of the current browser page.
Step 220: it is determined whether a long connection exists.
Specific: when a browser page is opened, it is determined whether there is a long connection flag in the local storage space for the server to send an event. Step 230 is entered when it is determined that there is a presence, and step 240 is entered when it is not.
Step 230: and storing the identity of the browser page into a local storage space.
Specific: and storing the identity of the current browser page into a local storage space.
Step 240: a long connection is established.
Specific: establishing an event long connection for connecting to a browser page when it is determined that there is no long connection flag in the local storage space for the server to send the event
Step 250: pushing messages to browser pages.
Specific: and monitoring the stored data in the local storage space, and pushing the stored data to the browser page and the opened browser page.
The method of connecting the browser page is described above through fig. 1 to 2, and the apparatus for connecting the browser page is described below with reference to fig. 3 to 4.
Referring to fig. 3, a schematic block diagram of an apparatus 300 for connecting a browser page according to an embodiment of the present application is provided, where the apparatus 300 may be a module, a program segment, or a code on an electronic device. The apparatus 300 corresponds to the embodiment of the method of fig. 1 described above, and is capable of performing the steps involved in the embodiment of the method of fig. 1. Specific functions of the apparatus 300 will be described below, and detailed descriptions thereof will be omitted herein as appropriate to avoid redundancy.
Optionally, the apparatus 300 includes:
a determining module 310, configured to determine whether a long connection flag for a server sending event exists in the local storage space when a browser page is opened;
a connection module 320, configured to store, when it is determined that a long connection flag for a server to send an event exists in the local storage space, an identity of a browser page in the local storage space, where the browser page and the opened browser page share a long connection;
the pushing module 330 is configured to monitor the stored data in the local storage space, and push the stored data to the browser page and the opened browser page.
Optionally, the apparatus further includes:
the establishing module is used for establishing event long connection for connecting a browser page when the long connection mark for the server to send the event does not exist in the local storage space after the long connection mark for the server to send the event is determined to exist in the local storage space; and storing the identity mark corresponding to the browser page in a local storage space, and pushing stored data to the browser page and the opened browser page.
Optionally, the determining module is specifically configured to:
Determining whether a preset field for storing long connection exists in the local storage space; when the preset field for storing long connection exists in the local storage space, determining whether the preset field is an identity of a browser page or not; the determining module is specifically configured to:
and determining that the preset field is not the identity of the browser page.
Optionally, the connection module is specifically configured to:
the method comprises the steps of storing the identity of a browser page into a preset identity in a local storage space, and monitoring the preset identity in the local storage space, wherein the identity in the local storage space is used for selecting one identity from the local storage space in a traversing mode when the established long connection is disconnected, and reestablishing the long connection through the browser page corresponding to the selected identity.
Optionally, the apparatus further includes:
the generation module is used for generating the identity mark corresponding to the browser page before the determination module determines that the long connection mark for the event sent by the server exists in the local storage space, wherein the identity mark is obtained by traversing all the identity marks stored in the local storage space, and each identity mark in the identity mark and all the identity marks is different.
Optionally, the pushing module is specifically configured to:
monitoring a long connection mark stored in a local storage space, and determining whether the long connection is disconnected or not through the current state of the long connection; and when the long connection is determined to be disconnected, reconnecting the long connection through a preset function until the long connection is completely reconnected.
Optionally, the apparatus further includes:
the updating module is used for deleting the identity mark from the local storage space and determining whether the browser page is a long connection page or not when the browser page is closed after the pushing module monitors the storage data in the local storage space and pushes the storage data to the browser page and the opened browser page; when the browser page is determined to be a long connection page, determining whether an opened browser page except the browser page exists; when the open browser pages except the browser pages are determined to exist, the identity of one of the open browser pages is updated to a preset field in the local storage space.
Referring to fig. 4, a schematic block diagram of an apparatus for connecting browser pages according to an embodiment of the present application may include a memory 410 and a processor 420. Optionally, the apparatus may further include: a communication interface 430 and a communication bus 440. The apparatus corresponds to the embodiment of the method of fig. 1 described above, and is capable of performing the steps involved in the embodiment of the method of fig. 1, and specific functions of the apparatus may be found in the following description.
In particular, the memory 410 is used to store computer readable instructions.
The processor 420, which processes the readable instructions stored in the memory, is capable of performing the various steps in the method of fig. 1.
A communication bus 440 for enabling direct connection communication of the above-described components.
The communication interface 430 of the device in the embodiment of the present application is used for performing signaling or data communication with other node devices. The memory 410 may be a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one disk memory. Memory 410 may also optionally be at least one storage device located remotely from the aforementioned processor. The memory 410 has stored therein computer readable instructions which, when executed by the processor 420, perform the method process described above in fig. 1. Processor 420 may be used on apparatus 300 and to perform the functions herein. By way of example, the processor 420 described above may be a general purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), an off-the-shelf programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, and the embodiments are not limited in this regard.
Embodiments of the present application also provide a readable storage medium, which when executed by a processor, performs a method process performed by an electronic device in the method embodiment shown in fig. 1.
It will be clear to those skilled in the art that, for convenience and brevity of description, reference may be made to the corresponding procedure in the foregoing method for the specific working procedure of the apparatus described above, and this will not be repeated here.
In summary, the embodiments of the present application provide a method, an apparatus, an electronic device, and a storage medium for connecting browser pages, where the method includes determining whether a long connection flag for a server to send an event exists in a local storage space when one browser page is opened; when the long connection mark for the server to send the event exists in the local storage space, storing the identity of the browser page into the local storage space, wherein the browser page and the opened browser page share long connection; and monitoring the stored data in the local storage space, and pushing the stored data to the browser page and the opened browser page. The method can achieve the effects of avoiding the plurality of long connections from occupying the connection number and improving the loading speed of the pages of the multi-open browser.
In the several embodiments provided in this application, it should be understood that the disclosed apparatus and method may be implemented in other manners as well. The apparatus embodiments described above are merely illustrative, for example, flow diagrams and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present application may be integrated together to form a single part, or each module may exist alone, or two or more modules may be integrated to form a single part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely exemplary embodiments of the present application and is not intended to limit the scope of the present application, and various modifications and variations may be suggested to one skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application. It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures.
The foregoing is merely specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily think about changes or substitutions within the technical scope of the present application, and the changes and substitutions are intended to be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
Claims (10)
1. A method for connecting browser pages, comprising:
when a browser page is opened, determining whether a long connection flag for a server sending event exists in a local storage space;
when the long connection mark for the server to send an event exists in the local storage space, storing the identity of the browser page into the local storage space, wherein the long connection is shared by the browser page and the opened browser page;
and monitoring the stored data in the local storage space, and pushing the stored data to the browser page and the opened browser page.
2. The method of claim 1, wherein after said determining whether a long connection flag for a server send event exists in the local storage space, the method further comprises:
when the long connection mark for the server to send the event does not exist in the local storage space, establishing event long connection for connecting the browser page;
and storing the identity mark corresponding to the browser page in the local storage space, and pushing the stored data to the browser page and the opened browser page.
3. The method according to claim 1 or 2, wherein determining whether there is a long connection flag in the local storage space for the server to send the event comprises:
determining whether a preset field for storing the long connection exists in the local storage space;
when the preset field for storing the long connection exists in the local storage space, determining whether the preset field is an identity of the browser page or not;
the determining that the long connection flag exists in the local storage space for the server to send an event includes:
and determining that the preset field is not the identity of the browser page.
4. The method according to claim 1 or 2, wherein storing the identity of the browser page in the local storage space comprises:
and storing the identity of the browser page into a preset identity in the local storage space, and monitoring the preset identity in the local storage space, wherein the identity in the local storage space is used for selecting one identity from the local storage space in a traversing manner when the established long connection is disconnected, and reestablishing a long connection through the browser page corresponding to the selected identity.
5. The method according to claim 1 or 2, wherein before said determining that there is said long connection flag in said local storage space for said server send event, said method further comprises:
and generating the identity corresponding to the browser page, wherein the identity is obtained by traversing all the identities stored in the local storage space, and each identity in the identity and all the identities is different.
6. The method of claim 1 or 2, wherein the monitoring of stored data in the local storage space comprises:
monitoring the long connection mark stored in the local storage space, and determining whether the long connection is disconnected or not according to the current state of the long connection;
and when the long connection is determined to be disconnected, reconnecting the long connection through a preset function until the long connection is completed.
7. The method of claim 1 or 2, wherein after the monitoring of the stored data in the local storage space and pushing the stored data to the browser page and the opened browser page, the method further comprises:
When the browser page is closed, deleting the identity mark from the local storage space, and determining whether the browser page is a long connection page or not;
when the browser page is determined to be the long connection page, determining whether an opened browser page except the browser page exists;
and when the open browser pages except the browser pages are determined to exist, updating the identity of one browser page in the open browser pages into a preset field in the local storage space.
8. An apparatus for connecting browser pages, comprising:
the determining module is used for determining whether a long connection mark for a server to send an event exists in the local storage space when one browser page is opened;
the connection module is used for storing the identity of the browser page into the local storage space when the long connection mark for the server to send the event exists in the local storage space, wherein the long connection is shared by the browser page and the opened browser page;
and the pushing module is used for monitoring the stored data in the local storage space and pushing the stored data to the browser page and the opened browser page.
9. An electronic device, comprising:
a memory and a processor, the memory storing computer readable instructions that, when executed by the processor, perform the steps in the method of any of claims 1-7.
10. A computer-readable storage medium, comprising:
computer program which, when run on a computer, causes the computer to perform the method according to any of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211690464.0A CN116016477A (en) | 2022-12-27 | 2022-12-27 | Method, device, equipment and storage medium for connecting browser pages |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211690464.0A CN116016477A (en) | 2022-12-27 | 2022-12-27 | Method, device, equipment and storage medium for connecting browser pages |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116016477A true CN116016477A (en) | 2023-04-25 |
Family
ID=86035057
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211690464.0A Pending CN116016477A (en) | 2022-12-27 | 2022-12-27 | Method, device, equipment and storage medium for connecting browser pages |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116016477A (en) |
-
2022
- 2022-12-27 CN CN202211690464.0A patent/CN116016477A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7739391B2 (en) | Gateway for wireless mobile clients | |
US10579595B2 (en) | Method and device for calling a distributed file system | |
KR101150146B1 (en) | System and method for managing cached objects using notification bonds | |
US20120198268A1 (en) | Re-establishing push notification channels via user identifiers | |
CN101317370B (en) | Method and management agent for event notifications correlation | |
CN109614439B (en) | Data synchronization method, device, electronic equipment and storage medium | |
CN111064626B (en) | Configuration updating method, device, server and readable storage medium | |
WO2019001562A1 (en) | Model loading method and apparatus, storage medium, and computer device | |
CN110881055A (en) | Micro-service processing method and device based on Redis | |
CN111092934A (en) | Method for updating client routing and storage medium | |
CN111885103B (en) | Resource processing method, server, electronic device and storage medium | |
CN116097691A (en) | Service request handling | |
US20240244414A1 (en) | Session binding relationship processing method and apparatus, electronic device, and readable medium | |
CN116016477A (en) | Method, device, equipment and storage medium for connecting browser pages | |
CN113612811B (en) | Method, system, equipment and medium for client mounting in multiple channels | |
US11301488B2 (en) | Method, electronic device and computer program product for data processing | |
CN115687168B (en) | File operation notification system and method | |
CN111240933B (en) | Method, system, device and medium for monitoring performance data of multiple data centers | |
CN115190168B (en) | Edge server management system and server cluster | |
CN115102854B (en) | Remote procedure call route management control method, system and equipment for micro-service | |
CN114945023B (en) | Network connection multiplexing method, device, equipment and medium | |
CN114285863B (en) | System and method for judging device operation status by updating execution status | |
US20230229539A1 (en) | Methods, systems, and computer readable media for health checking involving common application programming interface framework | |
CN107645415B (en) | Method and device for keeping data consistency between OpenStack server and equipment | |
CN117033830A (en) | Method and terminal for receiving message by tag page, 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 |