Communication Method, Device, Electronic Device and Storage Medium between Client Pages

By detecting communication requirements between client pages and recording messages in storage areas, the communication speed and throughput restriction caused by Websocket server performance and bandwidth limitations is solved, and communication effects with low latency and high throughput are achieved.

CN114201312BActive Publication Date: 2025-06-10GUANGDONG SANWEIJIA INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111372160.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-18
Publication Date
2025-06-10
Estimated Expiration
2041-11-18

AI Technical Summary

Technical Problem

In the prior art, due to the performance and network bandwidth limitation of Websocket servers, the communication speed and throughput between client pages are limited, resulting in high instant delay, low throughput, unstable communication quality, and it is difficult to take into account the requirements of low latency and high throughput.

Method used

By detecting whether the client page has communication needs, obtain the sender and receiver identifiers, create message identifiers, encapsulate the data into messages and record them in the client's storage area, so that other client pages can access the storage area to obtain data.

Benefits of technology

Real-time communication between client pages based on the shared client storage area is realized, and the problem of limited communication speed and throughput in the prior art is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114201312B_ABST
    Figure CN114201312B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention provides a communication method, device, electronic device, and storage medium for client pages. The method includes: detecting whether a client page has a need to communicate with other client pages, where the client page and other client pages belong to the same client and are under the same domain name; if so, obtaining the identifier corresponding to the client page as the sender identifier, the data to be sent corresponding to the client page, and the identifier of other client pages as the receiver identifier; creating a message identifier, encapsulating the message identifier, sender identifier, receiver identifier, and data to be sent into a message, and adding the message identifier to the message list; recording the message in the storage area of the client, so that other client pages can access the storage area to obtain the data to be sent carried in the message. In this way, instant communication between different client pages with low latency and high throughput can be achieved based on the shared client storage area.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of communication technologies, and in particular, to a communication method, device, electronic device, and storage medium between client pages. Background Art

[0002] With the continuous development of Internet technologies and web applications, the scope of Internet applications has been continuously expanding, and people's demands for the Internet have become increasingly advanced and complex. For example, in browser applications, people hope that web applications can meet the need for multi-screen operations. To achieve this need, it is necessary to enable communication between multiple client pages.

[0003] In related technologies, communication between different client pages is usually forwarded through a Websocket server. However, due to the performance of the Websocket server and network bandwidth limitations, the communication speed and throughput are restricted, that is, the latency is relatively high and the throughput is relatively low, and the communication quality is unstable, making it difficult to meet the requirements of low latency and high throughput. Summary of the Invention

[0004] To solve the above technical problems that due to the performance of the Websocket server and network bandwidth limitations, the communication speed and throughput are restricted, that is, the latency is relatively high and the throughput is relatively low, and the communication quality is unstable, making it difficult to meet the requirements of low latency and high throughput, embodiments of the present invention provide a communication method, device, electronic device, and storage medium between client pages.

[0005] In the first aspect of the embodiments of the present invention, a communication method between client pages is first provided, and the method includes:

[0006] Detect whether the client page has a need to communicate with other client pages, where the client page and the other client pages belong to the same client and are under the same domain name;

[0007] If so, obtain the identifier corresponding to the client page as the sender identifier, the data to be sent corresponding to the client page, and the identifier of the other client page as the receiver identifier;

[0008] Create a message identifier, encapsulate the message identifier, the sender identifier, the receiver identifier, and the data to be sent into a message, and add the message identifier to the message list;

[0009] Record the message in the storage area of the client so that the other client pages can access the storage area to obtain the data to be sent carried in the message.

[0010] In an alternative embodiment, before executing the method, it further includes:

[0011] Detect whether the client page is logged in to the client's storage area;

[0012] If logged in, create an identifier for the client page and add the identifier to the active list;

[0013] Detect whether there are any other identifiers in the active list except the said identifier;

[0014] If there are, broadcast the login message of the client page to all online client pages;

[0015] If not, assign a token to the client page, determine the client page as the main client page, and broadcast the login message of the client page to all online client pages.

[0016] In an optional embodiment, before creating the message identifier, it further includes:

[0017] Judge whether the data volume of the data to be sent exceeds a preset threshold. If the data volume of the data to be sent does not exceed the preset threshold, execute the step of creating the message identifier.

[0018] In an optional embodiment, the method further includes:

[0019] If the data volume of the data to be sent exceeds the preset threshold, split the data to be sent into N sub-data to be sent;

[0020] For the first sub-data to be sent, create a corresponding message identifier, and for N - 1 sub-data to be sent, create corresponding N - 1 subsequent message identifiers;

[0021] Package the message identifier, the sender identifier, the subsequent message identifier connected to the message identifier, the receiver identifier, and the first sub-data to be sent into a message;

[0022] For any subsequent message identifier, package the subsequent message identifier, the sender identifier, the subsequent message identifier connected to the subsequent message identifier, the receiver identifier, and the sub-data to be sent corresponding to the subsequent message identifier into a subsequent message;

[0023] Wherein, the subsequent message identifier connected to the last subsequent message identifier is empty;

[0024] Add the message identifier to the message list, and record the message and the subsequent messages in the client's storage area, so that other client pages can access the storage area to obtain the message and the subsequent messages.

[0025] In an alternative embodiment, the method further includes:

[0026] Poll and access the storage area of the client to query all unread messages recorded in the storage area;

[0027] Filter target unread messages from all unread messages, wherein the recipient identifier in the target unread messages is consistent with the identifier corresponding to the client page;

[0028] Read the data carried in the target unread messages.

[0029] In an alternative embodiment, the reading of the data carried in the target unread messages includes:

[0030] Read the target subsequent message identifier carried in the target unread message, and determine whether the target subsequent message identifier is empty;

[0031] If the target subsequent message identifier is empty, read the data carried in the target unread message.

[0032] In an alternative embodiment, the method further includes:

[0033] If the target subsequent message identifier is not empty, read the target subsequent message identifier carried in the target unread message;

[0034] According to the target subsequent message identifier, find all target unread subsequent messages of the target unread message;

[0035] Read the first target sub-data carried in the target unread message, and read the target sub-data carried in all target unread subsequent messages;

[0036] According to the connection order of the target unread message and the target unread subsequent messages, splice the first target sub-data and the target sub-data into complete data.

[0037] In an alternative embodiment, the method further includes:

[0038] Detect whether the client page exits the storage area of the client;

[0039] If it exits, broadcast the exit message of the client page to all other online client pages;

[0040] Wherein, when the main client page receives the exit message, remove the identifier of the client page from the activity list; and,

[0041] Remove the identifier of the client page from the heartbeat list and remove the message identifier of the message recorded by the client page in the memory from the message list.

[0042] In an optional embodiment, the method further includes:

[0043] Detect whether the client page is the main client page. If the client page is the main client page, detect whether there is no heartbeat for other client pages;

[0044] If there is no heartbeat for other client pages, count the number of times without heartbeat and determine whether the number exceeds a preset number threshold;

[0045] If the number exceeds the preset number threshold, determine that other client pages have exited abnormally;

[0046] Broadcast the abnormal exit message of other client pages to all online client pages, and remove the identifiers of other client pages from both the activity list and the heartbeat list.

[0047] In the second aspect of the embodiments of the present invention, a communication device between client pages is provided. The device includes:

[0048] A requirement detection module, configured to detect whether a client page has a requirement to communicate with other client pages, where the client page and the other client pages belong to the same client and are under the same domain name;

[0049] A data acquisition module, configured to, if so, acquire the identifier corresponding to the client page as the sender identifier, the data to be sent corresponding to the client page, and the identifier of the other client page as the receiver identifier;

[0050] A message encapsulation module, configured to create a message identifier, encapsulate the message identifier, the sender identifier, the receiver identifier, and the data to be sent into a message, and add the message identifier to the message list;

[0051] A message recording module, configured to record the message in the storage area of the client, so that the other client pages can access the storage area to obtain the data to be sent carried in the message.

[0052] In the third aspect of the embodiments of the present invention, an electronic device is further provided, including a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0053] The memory is used to store a computer program;

[0054] A processor, when executing a program stored in a memory, implements the communication method between client pages described in the first aspect above.

[0055] In a fourth aspect of the embodiments of the present invention, a storage medium is further provided. Instructions are stored in the storage medium, and when it runs on a computer, the computer is made to execute the communication method between client pages described in the first aspect above.

[0056] In a fifth aspect of the embodiments of the present invention, a computer program product containing instructions is further provided. When it runs on a computer, the computer is made to execute the communication method between client pages described in the first aspect above.

[0057] The technical solution provided by the embodiments of the present invention detects whether a client page has a need to communicate with other client pages. Among them, the client page and other client pages belong to the same client and are under the same domain name. If so, the identifier corresponding to the client page is obtained as the sender identifier, the data to be sent corresponding to the client page, the identifier of the other client page is used as the receiver identifier, a message identifier is created, the message identifier, sender identifier, receiver identifier, and data to be sent are encapsulated into a message, and the message identifier is added to the message list, and the message is recorded in the storage area of the client, so that other client pages can access the storage area and obtain the data to be sent carried in the message. In this way, instant communication between different client pages with low latency and high throughput can be realized based on the shared client storage area. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] The accompanying drawings here are incorporated into the specification and form a part of this specification, showing embodiments consistent with the present invention, and are used together with the specification to explain the principles of the present invention.

[0059] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the accompanying drawings required for use in the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0060] Figure 1 It is a schematic flowchart of the implementation process of a communication method between client pages shown in the embodiments of the present invention;

[0061] Figure 2 It is a schematic diagram of the data format of a message record shown in the embodiments of the present invention;

[0062] Figure 3 It is another schematic diagram of the data format of a message record shown in the embodiments of the present invention;

[0063] Figure 4 Schematic diagram of the data format of data records in localstorage shown in an embodiment of the present invention;

[0064] Figure 5 Schematic diagram of the implementation process of message reading shown in an embodiment of the present invention;

[0065] Figure 6 Schematic diagram of the implementation process of client page login shown in an embodiment of the present invention;

[0066] Figure 7 Schematic diagram of the data format of the heartbeat queue record of the client page shown in an embodiment of the present invention;

[0067] Figure 8 Schematic diagram of the structure of a communication device between client pages shown in an embodiment of the present invention;

[0068] Figure 9 Schematic diagram of the structure of an electronic device shown in an embodiment of the present invention. Detailed implementation manners

[0069] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0070] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above drawings are used to distinguish similar objects and do not necessarily need to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described herein can be implemented in an order different from those illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily need to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.

[0071] As Figure 1 shown, it is a schematic diagram of the implementation process of a communication method between client pages provided by an embodiment of the present invention. This method can be applied to client pages (here, the client page can be regarded as a client), and specifically may include the following steps:

[0072] S101, Detect whether there is a need for a client page to communicate with other client pages, where the client page and the other client pages belong to the same client and are under the same domain name.

[0073] In an embodiment of the present invention, for a client page (such as a certain browser client page A), there is usually a need to communicate with other client pages. For example, if browser client page A displays a red image and at the same time browser client page B also needs to display the same red image, this means there is a communication need between different browser client pages.

[0074] Based on this, in an embodiment of the present invention, it is detected whether there is a need for a client page to communicate with other client pages, where the client page and the other client pages belong to the same client and are under the same domain name. For example, browser client page A and browser client page B belong to the same browser client and are under the same domain name.

[0075] It should be noted that for the method of detecting whether there is a need for a client page to communicate with other client pages, for example, when a synchronization operation is required between a client page and other client pages, it can be detected that there is a need for the client page to communicate with other client pages. The embodiments of the present invention do not limit this.

[0076] For example, if browser client page A displays a red image and at the same time browser client page B also needs to display the same red image, it means that a synchronization operation is required between browser client page A and browser client page B. At this time, it can be detected that there is a need for browser client page A to communicate with browser client page B.

[0077] S102, If there is such a need, obtain the identifier corresponding to the client page as the sender identifier, the data to be sent corresponding to the client page, and the identifier of the other client page as the receiver identifier.

[0078] In an embodiment of the present invention, for a client page, if this client page has a need to communicate with other client pages, the following contents are obtained at this time: the identifier corresponding to the client page as the sender identifier, the data to be sent corresponding to the client page, and the identifier of the other client page as the receiver identifier.

[0079] For example, for browser client page A, if there is a need for browser client page A to communicate with browser client page B, the following contents are obtained at this time: the ID of browser client page A as the (message) sender ID, the data to be sent corresponding to browser client page A (i.e., the message content), and the ID of browser client page B as the (message) receiver ID.

[0080] It should be noted that for the above identifiers, it usually refers to the ID, and of course it can also be a name, a number, etc. The embodiments of the present invention do not limit this.

[0081] S103, create a message identifier, encapsulate the message identifier, the sender identifier, the receiver identifier, and the data to be sent into a message, and add the message identifier to the message list.

[0082] In the embodiments of the present invention, a unique message identifier can be created by traversing the message list, so as to encapsulate the message identifier, the sender identifier, the receiver identifier, and the data to be sent into a message, and add the message identifier to the message list.

[0083] For example, as Figure 2 shown in the message list, the message list name is #MsgList. In addition, the number of message IDs is represented by 4 bytes and consists of a message ID list. Create a unique message ID by traversing #MsgList.

[0084] Then encapsulate the (message) sender ID, the (message) receiver ID, and the data to be sent (i.e., the message content) into a message, and this message can be called a Msg record. The format of the Msg record is as Figure 3 shown. In addition, the above message ID can be added to #MsgList.

[0085] Among them, in the embodiments of the present invention, if the amount of data to be transmitted is large, such as files such as pictures, music, and videos, if it is split, it can be divided into multiple subsequent messages, and the content of these subsequent messages needs to be connected together to form a complete message content.

[0086] Based on this, in the embodiments of the present invention, it is judged whether the data volume of the data to be sent exceeds a preset threshold. If the data volume of the data to be sent does not exceed the preset threshold, a message identifier is created, and the message identifier, the sender identifier, the receiver identifier, and the data to be sent are encapsulated into a message.

[0087] For example, in the embodiments of the present invention, it is judged whether the data volume of the data to be sent (i.e., the message content) exceeds the limit of the global setting PCPSetting_Msg_size_Limit. If not, a message identifier is created, and the message identifier, the sender identifier, the receiver identifier, and the data to be sent are encapsulated into a message.

[0088] S104, record the message in the storage area of the client, so that other client pages can access the storage area to obtain the data to be sent carried in the message.

[0089] For an encapsulated message, in the embodiments of the present invention, the message is recorded in the storage area of the client. Subsequently, when other client pages access the storage area of the client, they can obtain the data to be sent carried in the message, thereby completing the communication between the client page and other client pages.

[0090] It should be noted that the storage area of the client generally refers to localstorage. Of course, it can also be other communication channels, such as cookies or indexedDB. The embodiments of the present invention do not limit this.

[0091] In addition, for the case where the amount of data to be sent is large, that is, if the amount of data to be sent exceeds a preset threshold, the data to be sent is split into N sub-data to be sent. For the first sub-data to be sent, a corresponding message identifier is created. For the N - 1 sub-data to be sent, N - 1 corresponding subsequent message identifiers are created. The message identifier, the sender identifier, the subsequent message identifier connected to the message identifier, the receiver identifier, and the first sub-data to be sent are encapsulated into a message. For any subsequent message identifier, the subsequent message identifier, the sender identifier, the subsequent message identifier connected to the subsequent message identifier, the receiver identifier, and the sub-data to be sent corresponding to the subsequent message identifier are encapsulated into a subsequent message. Among them, the subsequent message identifier connected to the last subsequent message identifier is empty. The message identifier is added to the message list, and the message and subsequent messages are recorded in the storage area of the client, so that other client pages can access the storage area to obtain the message and subsequent messages.

[0092] For example, the data to be sent, that is, the message content, is 0123456789abcd3fghijklmnopqr. Assume that the current global setting is PCPSetting_Msg_size_Limit = 10. It can be seen that the amount of data to be sent exceeds the preset threshold. The message content is split according to the global setting PCPSetting_Msg_size_Limit = 10, and 3 sub-data to be sent are obtained: 0123456789, abcd3fghij, klmnopqr. For the first sub-data to be sent, 0123456789, a corresponding message id: 1007 is created. For the remaining 2 sub-data to be sent, 2 corresponding subsequent message ids: 1008, 1009 are created.

[0093] Package the message ID 1007, sender ID (ABC), the subsequent message ID 1008 connected to the message ID 1007, receiver IDs (DEF, GHI), and the first sub-data to be sent 0123456789 into a message; for the subsequent message ID 1008, package the subsequent message ID 1008, sender ID (ABC), the subsequent message ID 1009 connected to the subsequent message ID 1008, receiver IDs (DEF, GHI), and the sub-data to be sent abcd3fghij corresponding to the subsequent message ID 1008 into a subsequent message; for the subsequent message ID 1009, package the subsequent message ID 1009, sender ID (ABC), the subsequent message ID (empty) connected to the subsequent message ID 1009, receiver IDs (DEF, GHI), and the sub-data to be sent klmnopqr corresponding to the subsequent message ID 1009 into a subsequent message. Among them, both 1008 / 1009 are subsequent messages of 1007, and the subsequent message ID in 1009 is empty, indicating that there is no subsequent message. Add a sequence number for the message with ID 1007 to MsgList, and the other two subsequent messages do not need to be added to MsgList. Subsequently, record the message and subsequent messages in the localstorage of the client. In this way, three records will appear in the localstorage data, as Figure 4 shown. In this way, when other client pages access the storage area to obtain the message and subsequent messages, a complete message content can be formed.

[0094] Through the above description of the technical solution provided by the embodiment of the present invention, detect whether the client page has a need to communicate with other client pages. Among them, the client page and other client pages belong to the same client and are under the same domain name. If so, obtain the identifier corresponding to the client page as the sender identifier, the data to be sent corresponding to the client page, the identifier of the other client page as the receiver identifier, create a message identifier, package the message identifier, sender identifier, receiver identifier, and data to be sent into a message, and add the message identifier to the message list, and record the message in the storage area of the client, so that other client pages can access the storage area to obtain the data to be sent carried in the message. In this way, instant communication between different client pages with low latency and high throughput can be achieved based on the shared client storage area.

[0095] As Figure 5 shown, it is a schematic flowchart of the implementation process of another communication method between client pages provided by the embodiment of the present invention. This method can be applied to client pages (here the client page can be regarded as a client), and specifically can include the following steps:

[0096] S501, poll and access the storage area of the client to query all unread messages recorded in the storage area.

[0097] In the embodiment of the present invention, the storage area of the client can be polled to query all unread messages recorded in the storage area. Among them, the read messages are deleted by the main client page, and the unread messages are changed to read after being read by the corresponding client page.

[0098] For example, for a certain browser client page A, the localstorage of the client is polled, and all records starting with #Msg are queried to query all unread messages recorded in the localstorage.

[0099] S502, screen target unread messages from all unread messages, where the recipient identifier in the target unread messages is consistent with the identifier corresponding to the client page.

[0100] For all unread messages, in the embodiment of the present invention, screening is performed, that is, target unread messages are screened from all unread messages, where the recipient identifier in the target unread messages is consistent with the identifier corresponding to the client page.

[0101] For example, for all unread messages, in the embodiment of the present invention, unread messages with the recipient id consistent with the id of the present client are screened from all unread messages as target unread messages, that is, unread messages containing the id of the present client are screened as target unread messages.

[0102] S503, read the data carried in the target unread messages.

[0103] In the embodiment of the present invention, the data carried in the target unread messages is read, so that the reading of the complete message can be completed. For example, the message content part carried in the target unread message is read, so that the reading of the message can be completed.

[0104] Among them, in the embodiment of the present invention, for the target unread message, there may be target subsequent messages. Based on this, it is necessary to continuously read out the target subsequent messages and synthesize them into a complete piece of data. Among them, to determine whether there are subsequent messages for a message, specifically, it is necessary to check whether the subsequent message parameter in the record is empty.

[0105] Specifically, in the embodiment of the present invention, the target subsequent message identifier carried in the target unread message is read, and it is determined whether the target subsequent message identifier is empty. If the target subsequent message identifier is empty, the data carried in the target unread message is read.

[0106] For example, the target subsequent message id carried in the target unread message is read, and it is determined whether the target subsequent message id is empty. If the target subsequent message id is empty, it means that there are no subsequent messages for the target unread message. At this time, the message content part carried in the target unread message can be read.

[0107] In addition, if the target subsequent message identifier is not empty, read the target subsequent message identifier carried in the target unread message; according to the target subsequent message identifier, find all target unread subsequent messages of the target unread message; read the first target sub-data carried in the target unread message, and read the target sub-data carried in all target unread subsequent messages; according to the connection order of the target unread message and the target unread subsequent message, splice the first target sub-data and the target sub-data into complete data.

[0108] For example, for the target unread message #Msg1007, as Figure 4 shown, the target subsequent message identifier is not empty, that is, there is a target subsequent message id1008. At this time, read the target subsequent message id1008 carried in the target unread message #Msg1007, and according to the target subsequent message id1008, find the target unread subsequent message #Msg1008 of the target unread message #Msg1007;

[0109] Then read the target subsequent message id1009 carried in the target unread subsequent message #Msg1008, and according to the target subsequent message id1009, find the target unread subsequent message #Msg1009 of the target unread message #Msg1007. Since the target subsequent message id in the target unread subsequent message #Msg1009 is empty, it means that there are no more target unread subsequent messages;

[0110] Then read the first target sub-data 0123456789 carried in the target unread message #Msg1007, read the target sub-data abcd3fghij carried in the target unread subsequent message #Msg1008, and read the target sub-data klmnopqr carried in the target unread subsequent message #Msg1009;

[0111] According to the connection order of the target unread message #Msg1007, the target unread subsequent message #Msg1008, and the target unread subsequent message #Msg1009, that is, 1007-1008-1009, splice the first target sub-data 0123456789, the target sub-data abcd3fghij, and the target sub-data klmnopqr into complete data, that is, 0123456789abcd3fghijklmnopqr.

[0112] As Figure 6 shown, it is a schematic diagram of the implementation process of a client page management method provided by an embodiment of the present invention. This method can be applied to a client page (here the client page can be regarded as a client), and specifically may include the following steps:

[0113] S601, detect whether the client page logs in to the storage area of the client.

[0114] In an embodiment of the present invention, when a user opens a client page, the client page is recorded in the storage area of the client, for example, it is recorded in localstorage. At this time, it can be regarded that the client page logs in to the storage area of the client.

[0115] Based on this, in an embodiment of the present invention, it is possible to detect whether the client page logs in to the storage area of the client. For example, for the browser client page A, the embodiment of the present invention can detect whether the browser client page A logs in to the localstorage of the browser client.

[0116] S602, if logged in, create an identifier for the client page and add the identifier to the activity list.

[0117] If it is detected that the client page logs in to the storage area of the client, the embodiment of the present invention creates an identifier for the client page by traversing the activity list, which means creating a new identifier and adding the identifier to the activity list.

[0118] S603, detect whether there are other identifiers in the activity list except the identifier.

[0119] S604, if there are, broadcast the login message of the client page to all online client pages.

[0120] S605, if not, assign a token to the client page, determine that the client page is the main client page, and broadcast the login message of the client page to all online client pages.

[0121] In an embodiment of the present invention, it is detected whether there are other identifiers in the activity list except the above identifier. If there are no other identifiers in the activity list except the above identifier, the client page logged in this time will obtain a token, the token is assigned to the client page, and it is determined that the client page is the main client page, and the login message of the client page is broadcast to all online client pages.

[0122] If there are other identifiers in the activity list except the above identifier, it means that there is already a main client page. At this time, the login message of the client page can be broadcast to all online client pages. Among them, the main client page "holds" the token and is responsible for managing messages and maintaining the login / logout status of other clients.

[0123] In addition, in the embodiments of the present invention, for the client page, it is possible to actively exit the storage area of the client, that is, the storage area of the client no longer records the client page. Based on this, the embodiments of the present invention detect whether the client page exits the storage area of the client. If it is detected that the client page exits the storage area of the client, the exit message of the client page (for example, RAL: log out the client id) is broadcast to all other online client pages.

[0124] Wherein, in the case that the main client page receives the exit message (for example, RAL message), the identifier of the client page is removed from the active list; and the identifier of the client page is removed from the heartbeat list, and the message identifier of the message recorded by the client page in the memory is removed from the message list.

[0125] In the embodiments of the present invention, for the client page, it is possible to exit abnormally. This generally occurs when the client exits abnormally, such as the browser page process being killed or the browser page crashing, etc., where it is impossible to send RAL messages to other clients. Here, a "client heartbeat" check mechanism is introduced. A normally working client will record the heartbeat time in the HeartbeatList at a certain interval (this interval is set globally in #PCPSetting_Heartbeat_Frequency), as Figure 7 shown.

[0126] Based on this, it is detected whether the client page is the main client page. If the client page is the main client page, it is detected whether other client pages have no heartbeat; if other client pages have no heartbeat, the number of times without heartbeat is counted, and it is determined whether the number exceeds a preset number threshold; if the number exceeds the preset number threshold, it is determined that other client pages have exited abnormally; the abnormal exit message of other client pages is broadcast to all online client pages, and the identifiers of other client pages are removed from both the active list and the heartbeat list.

[0127] For example, when the main client page detects that a client page has not had a heartbeat for more than 10 heartbeat cycles, it is considered that the client has logged out abnormally. At this time, the main client will send an RAL message to notify all other clients that a client has logged out, and will remove its id from the ActiveList and HeartbeatList.

[0128] Corresponding to the above method embodiments, the embodiments of the present invention also provide a communication device between client pages, as Figure 8 shown, the device may include: a requirement detection module 810, a data acquisition module 820, a message encapsulation module 830, and a message recording module 840.

[0129] A requirement detection module 810 is configured to detect whether there is a requirement for a client page to communicate with other client pages. Herein, the client page and the other client pages belong to the same client and are under the same domain name;

[0130] A data acquisition module 820 is configured to, if so, acquire the identifier corresponding to the client page as the sender identifier, the data to be sent corresponding to the client page, and the identifier of the other client page as the receiver identifier;

[0131] A message encapsulation module 830 is configured to create a message identifier, encapsulate the message identifier, the sender identifier, the receiver identifier, and the data to be sent into a message, and add the message identifier to the message list;

[0132] A message recording module 840 is configured to record the message in the storage area of the client, so that the other client pages can access the storage area to obtain the data to be sent carried in the message.

[0133] An embodiment of the present invention further provides an electronic device, as Figure 9 shown, including a processor 91, a communication interface 92, a memory 93, and a communication bus 94. Among them, the processor 91, the communication interface 92, and the memory 93 complete mutual communication through the communication bus 94,

[0134] The memory 93 is used for storing a computer program;

[0135] When the processor 91 is configured to execute the program stored in the memory 93, the following steps are implemented:

[0136] Detect whether there is a requirement for a client page to communicate with other client pages. Herein, the client page and the other client pages belong to the same client and are under the same domain name; if so, acquire the identifier corresponding to the client page as the sender identifier, the data to be sent corresponding to the client page, and the identifier of the other client page as the receiver identifier; create a message identifier, encapsulate the message identifier, the sender identifier, the receiver identifier, and the data to be sent into a message, and add the message identifier to the message list; record the message in the storage area of the client, so that the other client pages can access the storage area to obtain the data to be sent carried in the message.

[0137] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0138] The communication interface is used for communication between the above electronic device and other devices.

[0139] The memory can include a Random Access Memory (RAM), and can also include a non-volatile memory, such as at least one disk memory. Optionally, the memory can also be at least one storage device located far from the aforementioned processor.

[0140] The above-mentioned processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0141] In another embodiment provided by the present invention, a storage medium is also provided. Instructions are stored in this storage medium. When it runs on a computer, it causes the computer to execute the communication method between client pages described in any one of the above embodiments.

[0142] In another embodiment provided by the present invention, a computer program product containing instructions is also provided. When it runs on a computer, it causes the computer to execute the communication method between client pages described in any one of the above embodiments.

[0143] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a storage medium or transmitted from one storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) means. The storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)).

[0144] It should be noted that, in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising a..." does not exclude the existence of additional identical elements in the process, method, article or device comprising the element.

[0145] Each embodiment in this specification is described in a related manner. The same or similar parts among the embodiments can be referred to each other, and the differences between each embodiment and other embodiments are emphasized. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment.

[0146] The above is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A communication method between client pages, characterized in that, the method includes: Detect whether there is a need for a client page to communicate with other client pages, where the client page and the other client pages belong to the same client and are under the same domain name; If so, obtain the identifier corresponding to the client page as the sender identifier, the data to be sent corresponding to the client page, and the identifier of the other client page as the receiver identifier; Create a message identifier, encapsulate the message identifier, the sender identifier, the receiver identifier, and the data to be sent into a message, and add the message identifier to the message list; Record the message in the storage area of the client so that the other client pages can access the storage area to obtain the data to be sent carried in the message; Before creating the message identifier, the method further includes: Judge whether the data volume of the data to be sent exceeds a preset threshold. If the data volume of the data to be sent does not exceed the preset threshold, then execute the step of creating the message identifier; If the data volume of the data to be sent exceeds the preset threshold, split the data to be sent into N sub-data to be sent; For the first sub-data to be sent, create a corresponding message identifier, and for N-1 sub-data to be sent, create corresponding N-1 subsequent message identifiers; Encapsulate the message identifier, the sender identifier, the subsequent message identifier connected to the message identifier, the receiver identifier, and the first sub-data to be sent into a message; For any subsequent message identifier, encapsulate the subsequent message identifier, the sender identifier, the subsequent message identifier connected to the subsequent message identifier, the receiver identifier, and the sub-data to be sent corresponding to the subsequent message identifier into a subsequent message; Among them, the subsequent message identifier connected to the last subsequent message identifier is empty; Add the message identifier to the message list, and record the message and the subsequent messages in the storage area of the client so that the other client pages can access the storage area to obtain the message and the subsequent messages.

2. The method according to claim 1, characterized in that, Before executing the method, it further includes: Detect whether the client page logs in to the storage area of the client; If logged in, create an identifier for the client page and add the identifier to the activity list; Detect whether there are other identifiers in the activity list except the identifier; If so, broadcast the login message of the client page to all online client pages; If not, assign a token to the client page, determine that the client page is the main client page, and broadcast the login message of the client page to all online client pages.

3. The method according to claim 1, characterized in that, the method further includes: Poll and access the storage area of the client to query all unread messages recorded in the storage area; Filter target unread messages from all unread messages, where the recipient identifier in the target unread messages is consistent with the identifier corresponding to the client page; Read the data carried in the target unread messages.

4. The method according to claim 3, characterized in that, The reading of the data carried in the target unread messages includes: Read the target subsequent message identifier carried in the target unread message, and determine whether the target subsequent message identifier is empty; If the target subsequent message identifier is empty, read the data carried in the target unread message.

5. The method according to claim 4, characterized in that, The method further includes: If the target subsequent message identifier is not empty, read the target subsequent message identifier carried in the target unread message; According to the target subsequent message identifier, find all target unread subsequent messages of the target unread message; Read the first target sub-data carried in the target unread message, and read the target sub-data carried in all target unread subsequent messages; According to the connection order of the target unread message and the target unread subsequent messages, splice the first target sub-data and the target sub-data into complete data.

6. The method according to claim 2, characterized in that, The method further includes: Detect whether the client page exits the storage area of the client; If it exits, broadcast the exit message of the client page to all other online client pages; Wherein, when the main client page receives the exit message, remove the identifier of the client page from the activity list; and, Remove the identifier of the client page from the heartbeat list, and remove the message identifier of the message recorded by the client page in the memory from the message list.

7. The method according to claim 2, characterized in that, The method further includes: Detect whether the client page is the main client page. If the client page is the main client page, detect whether other client pages have no heartbeat; If other client pages have no heartbeat, count the number of times without heartbeat, and determine whether the number exceeds a preset number threshold; If the number exceeds the preset number threshold, determine that other client pages have exited abnormally; Broadcast the abnormal exit message of other client pages to all online client pages, and remove the identifiers of other client pages from both the activity list and the heartbeat list.

8. A communication device between client pages, characterized in that, The device includes: A requirement detection module, configured to detect whether a client page has a requirement to communicate with other client pages, where the client page and the other client pages belong to the same client and are under the same domain name; A data acquisition module, configured to, if so, acquire the identifier corresponding to the client page as the sender identifier, the data to be sent corresponding to the client page, and the identifier of the other client page as the recipient identifier; A message encapsulation module, which is used to create a message identifier, encapsulate the message identifier, the sender identifier, the receiver identifier, and the data to be sent into a message, and add the message identifier to the message list; A message recording module, which is used to record the message in the storage area of the client, so that other client pages can access the storage area to obtain the data to be sent carried in the message; Among them, it is judged whether the data volume of the data to be sent exceeds a preset threshold. If the data volume of the data to be sent does not exceed the preset threshold, the step of creating a message identifier is executed; If the data volume of the data to be sent exceeds the preset threshold, the data to be sent is split into N sub-data to be sent; For the first sub-data to be sent, a corresponding message identifier is created, and for N - 1 sub-data to be sent, N - 1 corresponding subsequent message identifiers are created; The message identifier, the sender identifier, the subsequent message identifier connected to the message identifier, the receiver identifier, and the first sub-data to be sent are encapsulated into a message; For any subsequent message identifier, the subsequent message identifier, the sender identifier, the subsequent message identifier connected to the subsequent message identifier, the receiver identifier, and the sub-data to be sent corresponding to the subsequent message identifier are encapsulated into a subsequent message; Among them, the subsequent message identifier connected to the last subsequent message identifier is empty; The message identifier is added to the message list, and the message and the subsequent messages are recorded in the storage area of the client, so that other client pages can access the storage area to obtain the message and the subsequent messages.

9. An electronic device, characterized in that, it includes a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete mutual communication through the communication bus; The memory is used to store a computer program; The processor is used to implement the method steps described in any one of claims 1 to 7 when executing the program stored on the memory.

10. A storage medium, on which a computer program is stored, characterized in that, when the program is executed by a processor, it implements the method described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Access method and device of shared resources

    CN105069081A

  • Cross-domain communication method and device

    CN108932238A