A method and device for pushing page messages

By using a single linked list structure in the socket service to record the socket connection relationship of multiple target pages, the high maintenance cost and redundant connection problems caused by the separate registration of socket services for each page in the existing technology are solved, and the message is pushed to multiple The efficient way to pages.

CN114553949BActive Publication Date: 2025-01-07BEIJING JINGDONG QIANSHITECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210137732.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-15
Publication Date
2025-01-07
Estimated Expiration
2042-02-15

AI Technical Summary

Technical Problem

In the prior art, message push of front-end pages requires the registration of socket services for each page separately, resulting in high maintenance costs and increasing useless connections and interaction frequency when users browse multiple web pages.

Method used

By setting a socket connection relationship between a single linked list structure record and multiple target pages in the socket service, it is possible to push messages to multiple target pages only if one socket service is needed.

Benefits of technology

Reduces service maintenance costs, reduces useless connections and interaction frequency, and improves the efficiency of message push.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114553949B_ABST
    Figure CN114553949B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for pushing page messages, and relates to the field of computer technology. A specific implementation of the method includes: using a socket service to receive messages pushed by a server; the socket service maintains a socket connection with multiple target pages in an active state, and the socket service records the socket connection relationship with multiple target pages through a single linked list structure; the message is escaped to generate a message to be pushed; according to the single linked list structure, the message to be pushed is pushed to multiple target pages. This implementation method realizes the function of pushing the message to be pushed to multiple target pages by setting a single linked list structure in the socket service to record the socket connection relationship with multiple target pages, thereby reducing the maintenance cost of the service and reducing useless connections and interaction frequency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for pushing page messages. Background Art

[0002] Currently, the message push of the front-end page usually requires registering a socket service for each page separately. Although the implementation is simple, each page corresponds to a separate socket service, which has high maintenance costs. Moreover, when users browse multiple web pages, they need to repeatedly open multiple socket services, which increases useless connections and interaction frequency. Summary of the invention

[0003] In view of this, an embodiment of the present invention provides a method and device for pushing page messages. By setting a single linked list structure in the socket service to record the socket connection relationship with multiple target pages, only one socket service is needed to realize the function of pushing the message to be pushed to multiple target pages, thereby reducing the maintenance cost of the service and reducing the useless connections and interaction frequency.

[0004] To achieve the above objective, according to one aspect of an embodiment of the present invention, a method for pushing a page message is provided.

[0005] A page message pushing method according to an embodiment of the present invention includes: using a socket service to receive messages pushed by a server; the socket service maintains a socket connection with multiple target pages in an active state, and the socket service records the socket connection relationship with the multiple target pages through a single linked list structure; escaping the message to generate a message to be pushed; and according to the single linked list structure, pushing the message to be pushed to the multiple target pages.

[0006] Optionally, the method also includes: determining, based on the heartbeat information of the page, multiple target pages whose heartbeat information is in an active state; registering the multiple target pages respectively according to the key names and key values ​​corresponding to the multiple target pages; using a set structure to save the key names of the multiple target pages, and using the single linked list structure to save the key values ​​of the multiple target pages.

[0007] Optionally, multiple target pages are registered respectively according to the key names and key values ​​corresponding to the multiple target pages, including: for the current target page to be registered: determine whether the key name corresponding to the current target page exists in the set structure; if so, update the key value corresponding to the key name in the single linked list structure; otherwise, create a corresponding key name and key value for the current target page, store the created key name in the set structure, and store the created key value at the end of the single linked list structure.

[0008] Optionally, the method further includes: in response to the case where the heartbeat information is converted from an active state to an inactive state: deleting the key name corresponding to the target page in the inactive state from the set structure, and deleting the key value of the target page from the single linked list structure.

[0009] Optionally, escaping the message to generate a message to be pushed includes: converting the message in json string format into the message to be pushed in Mobj format.

[0010] Optionally, the method also includes: receiving consumption results returned by each of the target pages based on the messages to be pushed, wherein the consumption results are obtained by executing a message processing method in the page; and determining whether to continue pushing new messages of the same type to be pushed to the target page based on whether the consumption results are successful.

[0011] To achieve the above objective, according to another aspect of an embodiment of the present invention, a device for pushing page messages is provided.

[0012] A device for pushing a page message according to an embodiment of the present invention includes:

[0013] A receiving module, used to receive messages pushed by a server by using a socket service; the socket service maintains a socket connection with multiple target pages in an active state, and the socket service records the socket connection relationship with the multiple target pages through a single linked list structure;

[0014] An escape module, used for escaping the message to generate a message to be pushed;

[0015] A push module is used to push the message to be pushed to the multiple target pages according to the single linked list structure.

[0016] Optionally, the device also includes: a registration module, used to determine, based on the heartbeat information of the page, multiple target pages whose heartbeat information is in an active state; register the multiple target pages respectively according to the key names and key values ​​corresponding to the multiple target pages; use a set structure to save the key names of the multiple target pages, and use the single linked list structure to save the key values ​​of the multiple target pages.

[0017] Optionally, the registration module is also used to, for the current target page to be registered: determine whether the key name corresponding to the current target page exists in the set structure; if so, update the key value corresponding to the key name in the single linked list structure; otherwise, create a corresponding key name and key value for the current target page, and store the created key name in the set structure, and store the created key value at the end of the single linked list structure.

[0018] Optionally, the device also includes: a deletion module, which is used to delete the key name corresponding to the target page in the inactive state from the set structure and the key value of the target page from the single linked list structure when the heartbeat information is converted from an active state to an inactive state.

[0019] Optionally, the escape module is further used to convert the message in json string format into a message to be pushed in Mobj format.

[0020] Optionally, the receiving module is also used to receive consumption results returned by each target page based on the message to be pushed, and the consumption results are obtained by executing the message processing method in the page; the pushing module is also used to determine whether to continue pushing new messages to be pushed of the same type to the target page based on whether the consumption results are successful.

[0021] To achieve the above objective, according to another aspect of an embodiment of the present invention, a system for pushing page messages is provided.

[0022] A page message push system according to an embodiment of the present invention includes a page message push device, a client and a server; wherein the push device includes a socket service; the server is used to push messages to the push device; the client is used to receive messages pushed by the push device, display pages according to the messages; and convert the active state of the page in response to user triggers.

[0023] To achieve the above objective, according to another aspect of an embodiment of the present invention, an electronic device for page message push is provided.

[0024] An electronic device for page message push according to an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement a page message push method according to an embodiment of the present invention.

[0025] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided.

[0026] A computer-readable storage medium according to an embodiment of the present invention stores a computer program, and when the program is executed by a processor, a page message pushing method according to an embodiment of the present invention is implemented.

[0027] An embodiment of the above invention has the following advantages or beneficial effects: by setting a single linked list structure in the socket service to record the socket connection relationship with multiple target pages, the function of pushing the message to be pushed to multiple target pages is realized with only one socket service, thereby reducing the maintenance cost of the service and reducing useless connections and interaction frequency.

[0028] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific implementation examples. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0030] Figure 1 is a schematic diagram of a method for pushing page messages according to an embodiment of the present invention;

[0031] Figure 2 is a schematic diagram of a main process of registering multiple target pages according to an embodiment of the present invention;

[0032] Figure 3 is a schematic diagram of a storage structure according to an embodiment of the present invention;

[0033] Figure 4 is a schematic diagram of another main process of registering multiple target pages according to an embodiment of the present invention;

[0034] Figure 5 is a schematic diagram of the main process after the message to be pushed is pushed to the target page according to an embodiment of the present invention;

[0035] Figure 6 is a schematic diagram of a specific process of a method for pushing a page message according to an embodiment of the present invention;

[0036] Figure 7 is a schematic diagram of main modules of a device for pushing page messages according to an embodiment of the present invention;

[0037] Figure 8 is a schematic diagram of a system for pushing page messages according to an embodiment of the present invention;

[0038] Fig. 9 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0039] Fig.10It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0040] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0041] It should be pointed out that the embodiments of the present invention and the technical features therein may be combined with each other without conflict.

[0042] Figure 1 It is a schematic diagram of a method for pushing page messages according to an embodiment of the present invention.

[0043] like Figure 1 As shown, the method for pushing a page message in an embodiment of the present invention mainly includes:

[0044] Step S101: using a socket service to receive a message pushed by a server; the socket service maintains a socket connection with multiple target pages in an active state, and the socket service records the socket connection relationship with the multiple target pages through a single linked list structure;

[0045] Step S102: Translate the message to generate a message to be pushed;

[0046] Step S103: according to the single linked list structure, the message to be pushed is pushed to multiple target pages.

[0047] At present, the push mode for page messages mostly adopts the WebSocket mode. As a two-way communication protocol, it can maintain the communication mode of TCP long connection compared with the http mode, has less overhead and lighter real-time performance than http. In the WebSocket mode, it can be specifically divided into two types, MVVM (Model-View-ViewModel) mode and page separate registration mode. The present invention optimizes the page separate registration mode, modifies the one-to-one page registration mode into a one-to-many page registration mode, and further reduces the maintenance cost of the service while ensuring the normal push of page messages.

[0048] Among them, the server will push multiple messages. In the embodiment of the present invention, the pushed messages refer to consumption messages that need to be pushed to the target page, and do not include messages such as heartbeat information that only indicate the status of the server.

[0049] It should be noted that the back-end server and the front-end display interface usually have a fixed format (i.e., the same data structure) for the message content. However, before the server pushes the content to the front-end display interface through the network, it is necessary to convert the data structure sequence of the content into a json string. After the front-end display interface receives the json string data, it performs a deserialization operation to convert it into the data structure sequence before the server sends it, and then provides it to the registration page for use. The conversion process of the above format is usually called escaping. Therefore, in an optional embodiment, the message is escaped to generate a message to be pushed, including: converting the message in the json string format into the message to be pushed in the mobj format.

[0050] In an optional embodiment, the front-end display interface can use any one of the vue framework, wpf framework, and native http page framework in the JavaScript framework, and it only needs to ensure that the protocol version is higher than http1.1.

[0051] In step S103, the single linked list structure is a chain access data structure, which uses a group of storage units with arbitrary addresses to store data elements in the linear list. The data in the linked list is represented by nodes, and each node is composed of: element (image of data element) + pointer (indicating the storage location of the subsequent element). The element is the storage unit for storing data, and the pointer is the address data connecting each node. By recording the socket connection relationship between a socket service and multiple target pages through the single linked list structure, linear storage can be realized to facilitate the extraction of data from multiple target pages.

[0052] Furthermore, through the single linked list structure, a first-in-first-out push effect can be achieved in the process of message push, that is, push is performed from front to back in sequence according to the storage order of the single linked list structure.

[0053] In an optional embodiment, the single linked list structure only stores the key value of the target page that has completed registration, and the key name of the target page that has completed registration is stored through the set structure, such as Figure 2 As shown, including:

[0054] Step S201: determining multiple target pages whose heartbeat information is active according to the heartbeat information of the page;

[0055] Step S202: registering the multiple target pages respectively according to the key names and key values ​​corresponding to the multiple target pages;

[0056] Step S203: using a set structure to save the key names of multiple target pages, and using a single linked list structure to save the key values ​​of multiple target pages.

[0057] Among them, the heartbeat information refers to the very small data sent by the Socket service at regular intervals (usually 3 seconds) in the process of maintaining a persistent connection. The Socket service can determine whether the target page is still in an active state of maintaining the connection (page open) based on the returned response.

[0058] It is worth mentioning that when a user opens multiple target pages through a client, multiple target pages whose heartbeat information is active can be determined through the state of the heartbeat information. At this time, multiple target pages in the active state need to be registered to obtain the key name and key value corresponding to each target page. In an optional embodiment, the registration of the target page can be completed through the register method in the registration configuration class method.

[0059] The set structure is a storage structure similar to an array. The values ​​of the elements stored in the structure are unique and there are no duplicate values. In the embodiment of the present invention, the key name corresponding to the target page is a unique identifier used to distinguish other pages, and the key name and the key value are one-to-one corresponding. Figure 3 As shown, it is suitable to use a set structure to store the key name. Further, in the embodiment of the present invention, by using a set structure to store the key name, fast search and deletion can be achieved according to the key name, and by using a single linked list structure to store the key value, fast push can be achieved one by one during the message push process.

[0060] In a further optional embodiment, for the registration step in step S202, as Figure 4 As shown, for the current target page to be registered, it may specifically include:

[0061] Step S401: determine whether the key name corresponding to the current target page exists in the set structure;

[0062] If yes, then execute step S402: update the key value corresponding to the key name in the single linked list structure;

[0063] Otherwise, execute step S403: create a corresponding key name and key value for the current target page, store the created key name in the set structure, and store the created key value at the end of the single linked list structure.

[0064] In actual application, users may open the same page repeatedly. In order to avoid repeated registration steps, the key name corresponding to the current target page can be judged in advance. If it has been stored in the set structure, there is no need for secondary registration. If it is not stored in the set structure, register and store it again.

[0065] When the user uses the vue framework as the front-end display page framework, the store module in the vue framework can be used to complete the setting of the set structure and the single linked list structure. The embodiment of the present invention can ensure that the latest registered key name always exists at the end of the single linked list structure through the storage method of the single linked list structure, and further ensure that in the process of message push, the push traversal can be performed one by one from front to back according to the order of the registered key names.

[0066] When the user closes the page, the target page will no longer return the heartbeat information, and the corresponding active state will also change immediately. In an optional embodiment, when the user closes the page, it also includes: in the case where the heartbeat information is converted from an active state to an inactive state: the key name corresponding to the target page in the inactive state is deleted from the set structure, and the key value of the target page is deleted from the single linked list structure. In this way, the key name and key value in the set structure and the single linked list structure can always be the target page in the active state. In the process of pushing messages according to the key values ​​in the single linked list results, the message will not be pushed to the closed page, thereby improving resource utilization. In a further optional embodiment, the above-mentioned deletion process can be implemented through the unregister method in the event class method.

[0067] After step S103, in an optional embodiment, as Figure 5 As shown, it also includes:

[0068] Step S501: receiving consumption results returned by each target page according to the message to be pushed, where the consumption results are obtained by executing the message processing method in the page;

[0069] Step S502: Determine whether to continue pushing new messages of the same type to be pushed to the target page according to whether the consumption result is successful.

[0070] In an optional embodiment, the message processing method in the page may use the handlerMsg method, and the present invention does not limit other methods that can complete the message processing.

[0071] The socket service is only responsible for pushing the messages pushed by the server to multiple target pages. Whether the messages are consumed by the target pages is determined by the target pages themselves. When the pushed messages are of the same type as the messages consumed by the target pages, the target pages will consume the pushed messages. When the pushed messages are of different types from the messages consumed by the target pages, the target pages will not consume the pushed messages. After the target pages decide whether to consume the messages, the consumption results will be returned to the socket service. According to the consumption results, the message types that can be consumed by each target page can be determined, and in the subsequent message push process, a more accurate effect can be achieved. For example, the message types that can be consumed by the three opened target pages (target page 1, target page 2, and target page 3) are order messages, inventory messages, and advertising messages. When the pushed message is an order message, target page 1 can consume it, while target pages 2 and 3 cannot consume it. Then the consumption result returned by target page 1 is consumption success, and the consumption results returned by target pages 2 and 3 are consumption failure. Then, when the server sends a new push message that is also an order message, it can choose to push it only to target page 1, saving the push process to target pages 2 and 3 to reduce resource consumption.

[0072] Figure 6 FIG. 1 is a schematic diagram of a specific process of a method for pushing a page message according to an embodiment of the present invention. Figure 6 As shown, the specific steps include:

[0073] Step S601: The socket service receives the message pushed by the server;

[0074] Step S602: Translate the received message to generate a message to be pushed;

[0075] Step S603: determine whether there is an active target page in the set structure;

[0076] If yes, then execute step S604 to step S606; if no, then directly execute step S607;

[0077] S604: Send the messages to be pushed to the target pages in the set structure one by one according to the storage order in the singly linked list structure;

[0078] Step S605: receiving the consumption result of the target page;

[0079] Step S606: Determine whether to continue pushing new messages of the same type to be pushed to the target page according to whether the consumption result is successful;

[0080] Step S607: End the process.

[0081] Through the above steps, the function of pushing messages to be pushed to multiple target pages is realized by setting a single linked list structure in the socket service to record the socket connection relationship with multiple target pages on the basis of setting only one socket service, thereby reducing the maintenance cost of the service and reducing useless connections and interaction frequency.

[0082] Figure 7 Schematic diagram of the main modules of the device for pushing page messages according to an embodiment of the present invention. Figure 7 As shown, the apparatus for pushing page messages provided by the embodiment of the present invention includes:

[0083] The receiving module 701 is used to receive the message pushed by the server by using the socket service; the socket service maintains a socket connection with multiple target pages in an active state, and the socket service records the socket connection relationship with the multiple target pages through a single linked list structure;

[0084] The translation module 702 is used to translate the message to generate a message to be pushed;

[0085] The push module 703 is used to push the message to be pushed to the multiple target pages according to the single linked list structure.

[0086] In an optional embodiment of the present invention, the device also includes: a registration module, used to determine, based on the heartbeat information of the page, multiple target pages whose heartbeat information is in an active state; register the multiple target pages respectively according to the key names and key values ​​corresponding to the multiple target pages; use a set structure to save the key names of the multiple target pages, and use the single linked list structure to save the key values ​​of the multiple target pages.

[0087] In an optional embodiment of the present invention, the registration module is also used to, for the current target page to be registered: determine whether the key name corresponding to the current target page exists in the set structure; if so, update the key value corresponding to the key name in the single linked list structure; otherwise, create a corresponding key name and key value for the current target page, and store the created key name in the set structure, and store the created key value at the end of the single linked list structure.

[0088] In an optional embodiment of the present invention, the device also includes: a deletion module, which is used to, in the case where the heartbeat information is converted from an active state to an inactive state: delete the key name corresponding to the target page in the inactive state from the set structure, and delete the key value of the target page from the single linked list structure.

[0089] In an optional embodiment of the present invention, the escape module 702 is further used to convert the message in the json string format into a message to be pushed in the Mobj format.

[0090] In an optional embodiment of the present invention, the receiving module 701 is also used to receive consumption results returned by each of the target pages based on the message to be pushed, and the consumption results are obtained by executing the message processing method in the page; the pushing module 703 is also used to determine whether to continue pushing new messages of the same type to be pushed to the target page based on whether the consumption results are successful.

[0091] According to the page message push device of the embodiment of the present invention, by setting a single linked list structure in the socket service to record the socket connection relationship with multiple target pages, only one socket service is needed to realize the function of pushing the message to be pushed to multiple target pages, thereby reducing the maintenance cost of the service and reducing useless connections and interaction frequency.

[0092] Figure 8 A page message push system to which the present invention can be applied is shown, comprising a client 801, a page message push device 700 and a server 802; wherein,

[0093] The server 802 is used to push messages to the push device 700;

[0094] The client 801 is used to receive the message pushed by the push device 700, display the page according to the message, and convert the active state of the page in response to the user trigger.

[0095] Fig. 9 An exemplary system architecture 900 is shown to which a method for pushing a page message or a system for pushing a page message according to an embodiment of the present invention can be applied.

[0096] like Fig. 9 As shown, system architecture 900 may include terminal devices 901, 902, 903, network 904 and server 905. Network 904 is used to provide a medium for communication links between terminal devices 901, 902, 903 and server 905. Network 904 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0097] Users can use terminal devices 901, 902, 903 to interact with server 905 through network 904 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 901, 902, 903, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0098] The terminal devices 901 , 902 , and 903 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.

[0099] Server 905 can send the pushed message to the socket service; it can also analyze and process the consumption results and other data sent by terminal devices 901, 902, and 903 in response to the user's trigger operation, and determine whether to continue pushing new messages of the same type to be pushed to the target page based on whether the consumption result is successful.

[0100] It should be noted that the method for pushing a page message provided in the embodiment of the present invention is generally executed by the server 905 , and accordingly, the device for pushing a page message provided in the embodiment of the present invention is generally disposed in the server 905 .

[0101] It should be understood that Fig. 9 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.

[0102] Reference below Fig.10 , which shows a schematic diagram of the structure of a computer system 1000 of a terminal device suitable for implementing an embodiment of the present invention. Fig.10 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0103] like Fig.10 As shown, the computer system 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the system 1000 are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0104] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.

[0105] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1009, and / or installed from the removable medium 1011. When the computer program is executed by the central processing unit (CPU) 1001, the above-mentioned functions defined in the system of the present invention are executed.

[0106] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0107] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0108] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: using a socket service to receive messages pushed by a server; the socket service maintains a socket connection with multiple target pages in an active state, and the socket service records the socket connection relationship with the multiple target pages through a single linked list structure; the message is escaped to generate a message to be pushed; according to the single linked list structure, the message to be pushed is pushed to the multiple target pages.

[0109] According to the technical solution of an embodiment of the present invention, by setting a single linked list structure in the socket service to record the socket connection relationship with multiple target pages, the function of pushing the message to be pushed to multiple target pages is realized with only one socket service, thereby reducing the maintenance cost of the service and reducing the frequency of useless connections and interactions.

[0110] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for pushing a page message, characterized in that: The page registration method used in the WebSocket method includes: Utilize a socket service to receive messages pushed by a server; the socket service maintains a socket connection with multiple target pages in an active state, and the socket service records the socket connection relationship with the multiple target pages through a single linked list structure; Translating the message to generate a message to be pushed; According to the single linked list structure, the message to be pushed is pushed to the multiple target pages; It also includes: determining multiple target pages whose heartbeat information is active according to the heartbeat information of the page; registering the multiple target pages respectively according to the key names and key values ​​corresponding to the multiple target pages; using a set structure to save the key names of the multiple target pages, and using the single linked list structure to save the key values ​​of the multiple target pages.

2. The method according to claim 1, characterized in that The registering the plurality of target pages respectively according to the key names and key values ​​corresponding to the plurality of target pages comprises: For the current target page to be registered: determine whether the key name corresponding to the current target page exists in the set structure; If yes, then updating the key value corresponding to the key name in the single linked list structure; Otherwise, a corresponding key name and key value are created for the current target page, and the created key name is stored in the set structure, and the created key value is stored at the end of the single linked list structure.

3. The method according to claim 1, characterized in that Also includes: In the case where the heartbeat information is converted from an active state to an inactive state: The key name corresponding to the target page in an inactive state is deleted from the set structure, and the key value of the target page is deleted from the single linked list structure.

4. The method according to claim 1, characterized in that: The step of escaping the message to generate a message to be pushed includes: Convert the message in json string format into the message to be pushed in Mobj format.

5. The method according to claim 1, characterized in that: Also includes: Receiving consumption results returned by each target page according to the message to be pushed, wherein the consumption results are obtained by executing a message processing method in the page; According to whether the consumption result is successful, it is determined whether to continue pushing new messages of the same type to be pushed to the target page.

6. A device for pushing page messages, characterized in that: The page registration method used in the WebSocket method includes: A receiving module, used to receive messages pushed by a server by using a socket service; the socket service maintains a socket connection with multiple target pages in an active state, and the socket service records the socket connection relationship with the multiple target pages through a single linked list structure; An escape module, used for escaping the message to generate a message to be pushed; A push module, used for pushing the message to be pushed to the multiple target pages according to the single linked list structure; A registration module is used to determine, based on the heartbeat information of the page, multiple target pages whose heartbeat information is in an active state; register the multiple target pages respectively according to the key names and key values ​​corresponding to the multiple target pages; use a set structure to save the key names of the multiple target pages, and use the single linked list structure to save the key values ​​of the multiple target pages.

7. A page message push system, comprising the page message push device, client and server according to claim 6; wherein: The push device includes a socket service; The server is used to push messages to the push device; The client is used to receive the message pushed by the push device and display the page according to the message; And in response to a user trigger, the active state of the page is converted.

8. An electronic device for pushing page messages, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.

9. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Message pushing method and device, electronic equipment and storage medium

    CN112866391A