Message pushing method, system and device and computer readable storage medium
By establishing a TCP connection between the client and the push server only when push messages are needed, the high operation and maintenance cost problem caused by low push frequency in the prior art is solved, and more efficient resource utilization and scalability are achieved.
Patent Information
- Application Number
- CN202411793057.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-03-07
AI Technical Summary
The existing message push method, when the push frequency is low, causes the connection server to maintain multiple TCP connections, increasing the development, operation and maintenance costs.
The client and the push server only establish a TCP connection when the message needs to be pushed, and disconnect after the message push is completed, avoiding the establishment and maintenance of multiple TCP connections in advance.
It reduces the development, operation and maintenance costs of the server, improves scalability, and avoids the need to increase server nodes when the number of clients increases.
Smart Images

Figure CN119583635A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure generally relates to the field of Internet technology. More specifically, the present disclosure relates to a message push method, system, device and computer-readable storage medium. Background Art
[0002] With the development of the Internet, message push has become an indispensable part of the Internet. The current message push method is generally that a connection server maintains the TCP connection between each client and the connection server. When the push server needs to push messages to each client, it finds the TCP connection between each client and the connection server and pushes the message to the connection server through each TCP connection. The message is then pushed to each client by the connection server. However, for message pushes with a low push frequency, such as message pushes on the negative one screen of a mobile phone, the method in which the connection server maintains multiple TCP connections for message push will result in high development and operation costs for the connection server. In view of this, it is urgent to provide a message push method, system, device, and computer-readable storage medium to reduce the development and operation costs of the server when the message push frequency is low. Summary of the invention
[0003] In order to at least solve one or more of the technical problems mentioned above, the present disclosure proposes a message push method, system, device and computer-readable storage medium in multiple aspects.
[0004] In a first aspect, the present disclosure provides a message push method, which is applied to a client, and includes: in response to monitoring a TCP connection request sent by a push server, establishing a TCP connection with the push server based on the TCP connection request; the TCP connection request is sent by the push server when it is determined that a message needs to be pushed to the client; receiving a push message from the push server based on the TCP connection; in response to receiving the push message, sending a feedback message to the push server so that the push server disconnects the TCP connection with the client, wherein the feedback message is used to identify that the client has received the push message.
[0005] In some embodiments, before responding to the TCP connection request sent by the push server, the method further includes: monitoring the TCP connection request sent by the push server through a target communication port; the target communication port is used for message push by the client.
[0006] In some embodiments, before the response to the TCP connection request sent by the push server, the method also includes: on the premise that the client accepts the message push, sending the IP address and target communication port of the client to the storage server for storage; the storage server is used to store the IP address and target communication port of the client; the TCP connection request carries the IP address and target communication port of the client, and the TCP connection request is sent by the push server after obtaining the IP address and target communication port of the client from the storage server.
[0007] In some embodiments, the method further includes: when the IP address and / or target communication port of the client changes, sending the new IP address and / or target communication port to the storage server for storage.
[0008] In some embodiments, the client accepts the message push by the following steps: displaying a pop-up window on the client asking whether to accept the message push; in response to clicking on the pop-up window to agree to accept the message push, determining that the client accepts the message push.
[0009] In a second aspect, the present disclosure provides a message push method, which is applied to a push server, and the method includes: when it is determined that a message needs to be pushed to a client, sending a TCP connection request to the client, so that the client establishes a TCP connection with the push server based on the TCP connection request; sending the push message to the client based on the established TCP connection; in response to receiving a feedback message sent by the client based on the push message, disconnecting the TCP connection with the client; the feedback message is used to identify that the client has received the push message.
[0010] In some embodiments, before sending the TCP connection request to the client, the method also includes: sending an information query request to a storage server, the information query request is used to query the IP address and target communication port of the client; the storage server is used to store the IP address and target communication port of the client, and the target communication port is used for message push; receiving the IP address and target communication port of the client sent by the storage server based on the information query request; sending the TCP connection request to the client includes: sending a TCP connection request to the client based on the IP address of the client and the target communication port.
[0011] In some embodiments, the need to push a message to the client is determined by: upon receiving a message push instruction, determining that a message needs to be pushed to the client; and / or, upon reaching a preset time point, determining that a message needs to be pushed to the client.
[0012] In some embodiments, before sending an information query request to the storage server, the method also includes: determining the client that needs to push the message based on the message push instruction and / or the preset time point and the pre-stored portraits of each client; the information query request is used to query the IP address and target communication port of the client that needs to push the message.
[0013] In a third aspect, the present disclosure provides a message push method, which is applied to a message push system, the message push system comprising: a client and a push server, the method comprising: at the push server: when determining that a message needs to be pushed to the client, sending a TCP connection request to the client, so that the client establishes a TCP connection with the push server based on the TCP connection request; at the client: in response to monitoring the TCP connection request sent by the push server, establishing a TCP connection with the push server based on the TCP connection request; at the push server: sending a push message to the client based on the established TCP connection; at the client: receiving a push message from the push server based on the TCP connection; in response to receiving the push message, sending a feedback message to the push server so that the push server disconnects the TCP connection with the client, wherein the feedback message is used to identify that the client has received the push message; at the push server: in response to receiving the feedback message sent by the client based on the push message, disconnecting the TCP connection with the client.
[0014] In a fourth aspect, the present disclosure provides a message push system, the system comprising: a client and a push server; wherein the client is configured to: in response to monitoring a TCP connection request sent by the push server, establish a TCP connection with the push server based on the TCP connection request; the TCP connection request is sent by the push server when it is determined that a message needs to be pushed to the client; receive a push message from the push server based on the TCP connection; in response to receiving the push message, send a feedback message to the push server so that the push server disconnects the TCP connection with the client, wherein the feedback message is used to identify that the client has received the push message; the push server is configured to: when determining that a message needs to be pushed to the client, send a TCP connection request to the client so that the client establishes a TCP connection with the push server based on the TCP connection request; send the push message to the client based on the established TCP connection; in response to receiving a feedback message sent by the client based on the push message, disconnect the TCP connection with the client.
[0015] In the fifth aspect, the present disclosure provides a message push device, which is applied to a client, and the device includes: a TCP connection request monitoring module, which is used to establish a TCP connection with the push server based on the TCP connection request in response to monitoring the TCP connection request sent by the push server; the TCP connection request is sent by the push server when it determines that a message needs to be pushed to the client; a push message receiving module, which is used to receive a push message from the push server based on the TCP connection; a feedback message sending module, which is used to send a feedback message to the push server in response to receiving the push message so that the push server disconnects the TCP connection with the client, wherein the feedback message is used to identify that the client has received the push message.
[0016] In the sixth aspect, the present disclosure provides a message push device, which is applied to a push server, and the device includes: a TCP connection request sending module, which is used to send a TCP connection request to the client when it is determined that a message needs to be pushed to the client, so that the client establishes a TCP connection with the push server based on the TCP connection request; a push message sending module, which is used to send a push message to the client based on the established TCP connection; a TCP connection disconnection module, which is used to disconnect the TCP connection with the client in response to receiving a feedback message sent by the client based on the push message; the feedback message is used to identify that the client has received the push message.
[0017] In a seventh aspect, the present disclosure provides a computer-readable storage medium storing a program or instruction on the computer-readable storage medium, which, when executed by a processor, implements the steps of a method as described in the first aspect or any one of some embodiments of the first aspect, or implements the steps of a method as described in the second aspect or any one of some embodiments of the second aspect.
[0018] Through the message push method provided above, in the disclosed embodiment, for the case where the frequency of message push is low, the push server will only establish a TCP connection with the client when it needs to push a message to the client, and disconnect the TCP connection with the client after completing the message push. Compared with the prior art, there is no need to establish a TCP connection between each client and the server in advance, nor is there a need to maintain multiple TCP connections through the heartbeat detection method, thereby reducing the development and operation costs of the server. Furthermore, the conventional method of maintaining multiple TCP connections for message push also requires adding nodes to the server as the number of clients increases, while the method disclosed herein only establishes a TCP connection with the client when it needs to push a message to the client, and the server's nodes can be reused, further reducing the maintenance cost of the server; further, the push server only establishes a TCP connection with the client when it needs to push a message to the client, and there is no need to establish and maintain a TCP connection between each client and the server in advance, which has better scalability. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] By reading the detailed description below with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present disclosure will become readily understood. In the accompanying drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0020] Figure 1 A schematic diagram of a system for executing a message push method according to an embodiment of the present disclosure is shown;
[0021] Figure 2 A schematic diagram showing a flow chart of a message push method in a system according to an embodiment of the present disclosure;
[0022] Figure 3 A schematic diagram showing the overall interaction flow of a message push method according to an embodiment of the present disclosure is shown;
[0023] Figure 4 A schematic diagram showing a flow chart of a message push method according to an embodiment of the present disclosure;
[0024] Figure 5 A schematic diagram showing a flow chart of another message push method according to an embodiment of the present disclosure;
[0025] Figure 6 A schematic diagram of a message push device according to an embodiment of the present disclosure is shown;
[0026] Figure 7 A schematic diagram of another message pushing device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0027] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0028] It should be understood that the terms "include" and "comprising" used in the specification and claims of the present disclosure indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or collections thereof.
[0029] It should also be understood that the terms used in this disclosure are only for the purpose of describing specific embodiments and are not intended to limit the disclosure. As used in this disclosure and claims, the singular forms of "a", "an", and "the" are intended to include the plural forms unless the context clearly indicates otherwise. It should also be further understood that the term "and / or" used in this disclosure and claims refers to any combination of one or more of the associated listed items and all possible combinations, including these combinations.
[0030] As used in this specification and claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0031] The specific implementation of the present disclosure is described in detail below with reference to the accompanying drawings.
[0032] As mentioned in the background technology section, for message push with low push frequency, for example, message push on the negative one screen of a mobile phone, the conventional method of connecting the server to maintain multiple TCP connections for message push will result in high development and operation costs for the connection server. Therefore, a message push method is required to reduce the development and operation costs of the server when the message push frequency is low.
[0033] Figure 1 A schematic diagram of a system for executing a message push method according to an embodiment of the present disclosure is shown. Figure 1 As shown, the system 100 for the message push method includes a client 110 and a push server 120 that can communicate with each other. It can be understood by those skilled in the art that Figure 1 The system shown is illustrative rather than restrictive, and other systems capable of executing the method disclosed in the present disclosure may be applied to the present disclosure.
[0034] like Figure 1 As shown, interactive communication and data transmission can be performed between the client 110 and the push server 120. In this embodiment, the push server 120 can push messages to one or more clients 110.
[0035] Among them, the client 110 can be a mobile phone, tablet computer or other device capable of running an application or system. Here, the program or system can be a script (program) file or a collection of script (program) files written in a commonly used programming language to implement a certain function or complex function.
[0036] The push server 120 may be a server used only for push. Of course, the push server 120 may also be configured to implement other functions, such as data storage, etc. The embodiment of the present disclosure does not specifically limit the push server.
[0037] In this embodiment, the client 110 is configured to: in response to monitoring a TCP connection request sent by the push server, establish a TCP connection with the push server based on the TCP connection request; the TCP connection request is sent by the push server when it determines that a message needs to be pushed to the client; receive a push message from the push server based on the TCP connection; in response to receiving the push message, send a feedback message to the push server so that the push server disconnects the TCP connection with the client, wherein the feedback message is used to identify that the client has received the push message; the push server 120 is configured to: when determining that a message needs to be pushed to the client, send a TCP connection request to the client, so that the client establishes a TCP connection with the push server based on the TCP connection request; send the push message to the client based on the established TCP connection; in response to receiving a feedback message sent by the client based on the push message, disconnect the TCP connection with the client.
[0038] As for the specific implementation of the steps executed by the client 110 and the push server 120, the following embodiments provide detailed descriptions and will not be repeated here.
[0039] So far, the Figure 1 A schematic diagram of the system is shown.
[0040] Below through Figure 2 The flowchart shown describes in detail the message push method in the system. Figure 2 The flowchart of a message push method in a system of the present disclosure embodiment is shown. It can be understood that, Figure 2 The method 200 shown may be performed by Figure 1 The system shown performs; Figure 2 The client 210 and the push server 220 in the embodiment may also be Figure 1 The client 110 and the push server 120 in.
[0041] like Figure 2 As shown:
[0042] In step S221, when the push server determines that a message needs to be pushed to the client, it sends a TCP connection request to the client.
[0043] For example, in this embodiment, the push server can determine that a message needs to be pushed to the client by the following method: upon receiving a message push instruction, determine that a message needs to be pushed to the client. Here, the message push instruction can be issued by relevant personnel when a major event occurs suddenly (for example, an earthquake occurs in a certain area), or other triggering events, which are not specifically limited in this disclosed embodiment.
[0044] Specifically, the message push instruction can be issued by relevant personnel through other smart terminals connected to the push server, or it can be issued by relevant personnel performing relevant operations in the background of the push server. The embodiment of the present disclosure does not specifically limit the way of issuing the message push instruction, which can be determined according to actual conditions.
[0045] As a specific embodiment of the present disclosure, the push server can also determine that a message needs to be pushed to the client by the following method: when a preset time point is reached, it is determined that a message needs to be pushed to the client. Here, the preset time point can be various festivals (for example, Children's Day, Spring Festival, Dragon Boat Festival, etc.) or anniversaries of some important events (for example, the anniversary of the founding of a school); the preset time point can also be a fixed time point every day, for example, 8 o'clock in the morning. The present disclosure embodiment does not specifically limit the preset time point, and it can be determined according to actual conditions.
[0046] As a specific embodiment, on the day of the Dragon Boat Festival, the push server is triggered to push a message to the client. Here, the push message is a message related to the Dragon Boat Festival, for example, the origin of the Dragon Boat Festival, the holiday arrangement of the Dragon Boat Festival, short stories related to the Dragon Boat Festival, etc.
[0047] In this embodiment, when the push server determines that a message needs to be pushed to the client, it sends a TCP connection request to the client. Here, the TCP connection request can carry the IP address of the client and the target communication port. The target communication port is used by the push server to push messages to the client.
[0048] In this embodiment, the IP address and target communication port of the client may be stored locally on the push server in advance, and the push server may directly obtain them locally when it needs to send a TCP connection request to the client.
[0049] As an optional implementation of the present disclosure, the client's IP address and target communication port may also be stored in advance in other devices that are different from the push server but connected to the push server (for example, other servers, the cloud, etc.). Before the push server sends a TCP connection request to the client, it first obtains the client's IP address and target communication port from the other device, and then sends a TCP connection request to the client based on the obtained client's IP address and target communication port.
[0050] In step S211 , in response to monitoring the TCP connection request sent by the push server, the client establishes a TCP connection with the push server based on the TCP connection request.
[0051] Illustratively, in this embodiment, before executing this step, the message push method further includes: the client monitors the target communication port to monitor the TCP connection request sent by the push server.
[0052] There may be many times when the client starts monitoring the target communication port. For example, the client starts monitoring the target communication port when it logs in for the first time. For another example, after the client logs in for the first time, it sends its IP address and target communication port to the storage end for storage and then starts monitoring the target communication port. For another example, the client may start monitoring the target communication port when it determines that it wants to accept a message push from the push server. The disclosed embodiments do not specifically limit the timing when the client starts monitoring the target communication port.
[0053] Of course, the timing for the client to start monitoring the target communication port can also be a combination of the above methods. For example, when the client logs in for the first time, it can first determine whether to accept the message push. On the premise of determining to accept the message push, its IP address and target communication port can be sent to the storage end (that is, the above push server or other devices different from the push server but connected to the push server) for storage. When the storage end receives a message of successful storage feedback, it starts monitoring the target communication port.
[0054] As an optional embodiment of the present disclosure, when the IP address and / or target communication port of the client changes, the client can send the new IP address and / or target communication port to the storage end for storage. After the storage end receives the new IP address and / or target communication port sent by the client, it can replace the stored IP address and / or target communication port.
[0055] In this embodiment, the client can determine whether to accept the message push from the push server by the following steps: display a pop-up window on the client asking whether to accept the message push; in response to clicking on the pop-up window to agree to accept the message push, determine that the client accepts the message push.
[0056] Here, the pop-up window displayed on the client to ask whether to accept the message push can be displayed when the client logs in for the first time, or each time the client logs in. The disclosed embodiment does not specifically limit this.
[0057] The client establishes a TCP connection with the push server based on the received TCP connection request, which is a conventional TCP connection establishment method, which will not be described in detail here. After the client successfully establishes a TCP connection with the push server, a message of successful establishment is sent to the push server.
[0058] In step S222, the push server sends the push message to the client based on the established TCP connection.
[0059] In step S212, the client receives a push message from the push server based on the established TCP connection.
[0060] Exemplarily, in this embodiment, after receiving the message of successful establishment of the TCP connection request sent by the client, the push server may send the push message to the client based on the established TCP connection when determining that a message needs to be pushed to the client.
[0061] Here, the push server can send the push message to all clients that have stored the sent IP address and target communication port, or it can push the message to some clients that have stored the sent IP address and target communication port according to the specific content of the push message. The disclosed embodiment does not specifically limit this.
[0062] For example, during the Dragon Boat Festival, if the push message is about the origin of the Dragon Boat Festival and some short stories, it can be pushed to all clients. For another example, for entertainment events, the push message can be sent only to clients that are interested in the entertainment events.
[0063] For the above-mentioned situation of pushing messages to some clients, if the clients allow, the push server can store the portraits of each client, match the content of the push message and the client portraits, and then determine the clients to which the message needs to be pushed.
[0064] Specifically, the content of the push message can be carried by the message push instruction, and the content of the push message can also be content related to a preset time point. Based on this, when determining the client to which the message needs to be pushed, the message push instruction and / or the preset time point can be matched with the client's portrait to further determine the client to which the message needs to be pushed.
[0065] In step S213, in response to receiving the push message, the client sends a feedback message to the push server.
[0066] Exemplarily, in this embodiment, after successfully receiving the push message from the push server, the client sends a feedback message of successful push message reception to the push server, so that the push server disconnects from the client based on the feedback message.
[0067] In step S223, the push server disconnects the TCP connection with the client in response to receiving the feedback message sent by the client based on the push message.
[0068] Exemplarily, in this embodiment, after receiving the feedback message sent by the client, the push server disconnects the TCP connection with the client and does not need to maintain the TCP connection.
[0069] As an optional implementation of the present disclosure, the push server can also actively disconnect the TCP connection with the client if it does not receive a feedback message sent by the client within a preset time interval (for example, 5 hours) after the TCP connection is established or within a preset time interval after the push message is sent. That is, regardless of whether the message push is successful, the push server will disconnect the TCP connection with the client, avoiding the situation where the TCP connection is not disconnected with the client when no feedback message from the client is received, thereby needing to always detect whether the TCP connection is normal through heartbeat detection, further solving the problem of high server operation and maintenance costs.
[0070] Through the message push method provided above, in the disclosed embodiment, for the case where the frequency of message push is low, the push server will only establish a TCP connection with the client when it needs to push a message to the client, and disconnect the TCP connection with the client after completing the message push. Compared with the prior art, there is no need to establish a TCP connection between each client and the server in advance, nor is there a need to maintain multiple TCP connections through the heartbeat detection method, thereby reducing the development and operation costs of the server. Furthermore, the conventional method of maintaining multiple TCP connections for message push also requires adding nodes to the server as the number of clients increases, while the method disclosed herein only establishes a TCP connection with the client when it needs to push a message to the client, and the server's nodes can be reused, further reducing the maintenance cost of the server; further, the push server only establishes a TCP connection with the client when it needs to push a message to the client, and there is no need to establish and maintain a TCP connection between each client and the server in advance, which has better scalability.
[0071] So far, the Figure 2 Description of the flow chart shown.
[0072] Figure 3 The figure shows a flow chart of the overall interaction of a message push method according to an embodiment of the present disclosure. It can be understood that: Figure 3 The client and push server in the message push method 300 may be Figure 1 The client 110 and the push server 120 in FIG. Figure 4 The storage end in the method may be integrated in the push server, or may be integrated in other devices that are different from the push server but connected to the push server, which is not specifically limited in the embodiments of the present disclosure.
[0073] like Figure 3 As shown, when the client logs in for the first time, a pop-up window asking whether to accept the message push is displayed on the client. In response to the operation of clicking on the pop-up window to agree to accept the message push, it is determined that the client accepts the message push; after it is determined that the client accepts the message push, the client's IP address and target communication port are sent to the storage end, and the storage end stores the client's IP address and target communication port. After the storage end successfully stores the client's IP address and target communication port, it sends a message indicating successful storage to the client. After the client receives the above-mentioned message indicating successful storage sent by the storage end, it starts monitoring the target communication port to monitor the TCP connection request sent by the push server.
[0074] When the push server receives a message push instruction or reaches a preset time point, it determines the client that needs to push messages based on the stored portraits of each client and the message push instruction and / or the preset time point. After determining the client that needs to push messages, an information query request is sent to the storage end to query the IP address and target communication port of the client that needs to push messages. The information query request can carry the identification information of the client that needs to push messages (for example, a universal unique identifier, etc.), so that the storage end feeds back the IP address and target communication port of the client to the push server based on the identification information of the client. After receiving the IP address and target communication port of the client fed back by the storage end, a TCP connection request can be sent to the client based on the IP address and target communication port of the client.
[0075] The client establishes a TCP connection with the push server based on the received TCP connection request, and sends a feedback message to the server indicating that the TCP connection request is successfully established. After receiving the feedback message sent by the client indicating that the TCP connection request is successfully established, the push server pushes the message to the client. After receiving the feedback message sent by the client indicating that the push message is received, the push server disconnects the TCP connection with the client and completes the message push.
[0076] So far, the Figure 3 Description of the flow chart shown.
[0077] Figure 4 A schematic diagram showing a flow chart of a message push method according to an embodiment of the present disclosure is shown. Figure 4 The method 400 is performed by a client. It is understood that the client referred to herein may be Figure 1 The following will be combined with the client 110 Figure 4 The method described in the embodiments of the present disclosure is further described.
[0078] like Figure 4 As shown, the message push method includes:
[0079] Step S410: In response to monitoring a TCP connection request sent by a push server, establishing a TCP connection with the push server based on the TCP connection request; Step S420: receiving a push message from the push server based on the TCP connection; Step S430: in response to receiving the push message, sending a feedback message to the push server to cause the push server to disconnect the TCP connection with the client.
[0080] Through the message push method provided above, in the disclosed embodiment, for the case where the frequency of message push is low, the push server will only establish a TCP connection with the client when it needs to push a message to the client, and disconnect the TCP connection with the client after completing the message push. Compared with the prior art, there is no need to establish a TCP connection between each client and the server in advance, nor is there a need to maintain multiple TCP connections through the heartbeat detection method, thereby reducing the development and operation costs of the server. Furthermore, the conventional method of maintaining multiple TCP connections for message push also requires adding nodes to the server as the number of clients increases, while the method disclosed herein only establishes a TCP connection with the client when it needs to push a message to the client, and the server's nodes can be reused, further reducing the maintenance cost of the server; further, the push server only establishes a TCP connection with the client when it needs to push a message to the client, and there is no need to establish and maintain a TCP connection between each client and the server in advance, which has better scalability.
[0081] As an optional embodiment of the present disclosure, before responding to the TCP connection request sent by the push server, the message push method further includes: monitoring the TCP connection request sent by the push server through the target communication port; the target communication port is used for message push of the client.
[0082] As an optional embodiment of the present disclosure, before responding to the TCP connection request sent by the push server, the message push method also includes: on the premise that the client accepts the message push, sending the client's IP address and target communication port to the storage server for storage; the storage server is used to store the client's IP address and target communication port; the TCP connection request carries the client's IP address and target communication port, and the TCP connection request is sent by the push server after obtaining the client's IP address and target communication port from the storage server.
[0083] As an optional embodiment of the present disclosure, the message push method further includes: when the IP address and / or target communication port of the client changes, sending the new IP address and / or target communication port to the storage server for storage.
[0084] As an optional embodiment of the present disclosure, the client accepts the message push through the following steps: displaying a pop-up window on the client asking whether to accept the message push; in response to clicking on the pop-up window to agree to accept the message push, determining that the client accepts the message push.
[0085] The specific implementation methods and technical effects can be found in the description of the above embodiments, which will not be repeated here.
[0086] So far, the Figure 4 Description of the flow chart shown.
[0087] Figure 5 A schematic diagram showing a flow chart of a message push method according to an embodiment of the present disclosure is shown. Figure 5 The method 500 is performed by a push server. It is understood that the push server referred to herein may be Figure 1 The push server 120 in FIG. Figure 5 The method described in the embodiments of the present disclosure is further described.
[0088] like Figure 5 As shown, the message push method includes:
[0089] S510: When it is determined that a message needs to be pushed to the client, a TCP connection request is sent to the client to enable the client; S520: A TCP connection is established with the push server based on the TCP connection request; S530: A message is used to identify that the client has received the push message.
[0090] Through the message push method provided above, in the disclosed embodiment, for the case where the frequency of message push is low, the push server will only establish a TCP connection with the client when it needs to push a message to the client, and disconnect the TCP connection with the client after completing the message push. Compared with the prior art, there is no need to establish a TCP connection between each client and the server in advance, nor is there a need to maintain multiple TCP connections through the heartbeat detection method, thereby reducing the development and operation costs of the server. Furthermore, the conventional method of maintaining multiple TCP connections for message push also requires adding nodes to the server as the number of clients increases, while the method disclosed herein only establishes a TCP connection with the client when it needs to push a message to the client, and the server's nodes can be reused, further reducing the maintenance cost of the server; further, the push server only establishes a TCP connection with the client when it needs to push a message to the client, and there is no need to establish and maintain a TCP connection between each client and the server in advance, which has better scalability.
[0091] As an optional embodiment of the present disclosure, before sending a TCP connection request to the client, the message push method also includes: sending an information query request to a storage server, the information query request is used to query the IP address and target communication port of the client; the storage server is used to store the IP address and target communication port of the client, and the target communication port is used for message push; receiving the IP address and target communication port of the client sent by the storage server based on the information query request; sending a TCP connection request to the client, including: sending a TCP connection request to the client based on the IP address and target communication port of the client.
[0092] As an optional embodiment of the present disclosure, the need to push a message to the client is determined in the following manner: when a message push instruction is received, it is determined that a message needs to be pushed to the client; and / or when a preset time point is reached, it is determined that a message needs to be pushed to the client.
[0093] As an optional embodiment of the present disclosure, before sending an information query request to the storage server, the message push method also includes: determining the client that needs to push the message based on the message push instruction and / or the preset time point and the pre-stored portraits of each client; the information query request is used to query the IP address and target communication port of the client that needs to push the message.
[0094] The description of the specific implementation methods and technical effects can be found in the description of the above embodiments, which will not be repeated here.
[0095] So far, the Figure 5 Description of the flow chart shown.
[0096] Below Figure 6 The schematic diagram shown is used to describe Figure 6 FIG. 6 is a schematic diagram of a message push device according to an embodiment of the present disclosure, wherein the message push device 600 is applied to a client. It is understood that the client referred to herein may be Figure 1 The push server 120 in.
[0097] like Figure 6 As shown, the message push device 600 includes:
[0098] The TCP connection request monitoring module 610 is used to establish a TCP connection with the push server based on the TCP connection request in response to monitoring the TCP connection request sent by the push server; the TCP connection request is sent by the push server when it determines that a message needs to be pushed to the client; the push message receiving module 620 is used to receive push messages from the push server based on the TCP connection; the feedback message sending module 630 is used to send a feedback message to the push server in response to receiving the push message so that the push server disconnects the TCP connection with the client, wherein the feedback message is used to identify that the client has received the push message.
[0099] As an optional implementation of the disclosed embodiment, the message disclosure device also includes: a target port monitoring module, which is used to monitor the TCP connection request sent by the push server through the target communication port; the target communication port is used for message push of the client.
[0100] As an optional implementation of the disclosed embodiment, the message disclosure device also includes: an address port storage module, which is used to send the client's IP address and target communication port to the storage server for storage on the premise that the client accepts the message push; the storage server is used to store the client's IP address and target communication port; the TCP connection request carries the client's IP address and target communication port, and the TCP connection request is sent by the push server after obtaining the client's IP address and target communication port from the storage server.
[0101] As an optional implementation of the disclosed embodiment, the message disclosure device also includes: a change storage module, which is used to send the new IP address and / or target communication port to the storage server for storage when the client's IP address and / or target communication port changes.
[0102] As an optional implementation of the disclosed embodiment, the client accepts the message push through the following modules: a pop-up display module, which is used to display a pop-up window on the client asking whether to accept the message push; a determination module, which is used to determine that the client accepts the message push in response to the operation of clicking on the pop-up window to agree to accept the message push.
[0103] The specific implementation methods and effects can be found in the description of the method embodiment in which the execution subject is the client, and will not be repeated here.
[0104] So far, the Figure 6 Description of the schematic shown.
[0105] Below Figure 7 The schematic diagram shown is used to describe Figure 7 FIG. 1 is a schematic diagram of a message push device according to an embodiment of the present disclosure, and the message push device is applied to a push server. It can be understood that the push server referred to here can be Figure 1 The push server 120 in.
[0106] like Figure 7 As shown, the message push device 700 includes:
[0107] The TCP connection request sending module 710 is used to send a TCP connection request to the client when it is determined that a message needs to be pushed to the client, so that the client establishes a TCP connection with the push server based on the TCP connection request; the push message sending module 720 is used to send the push message to the client based on the established TCP connection; the TCP connection disconnection module 730 is used to disconnect the TCP connection with the client in response to receiving a feedback message sent by the client based on the push message; the feedback message is used to identify that the client has received the push message.
[0108] As an optional implementation of the disclosed embodiment, the message push device also includes: a query request sending module, used to send an information query request to the storage server, the information query request is used to query the client's IP address and target communication port; the storage server is used to store the client's IP address and target communication port, and the target communication port is used for message push; an address port receiving module, used to receive the client's IP address and target communication port sent by the storage server based on the information query request; the TCP connection request sending module 710 is specifically used to: send a TCP connection request to the client based on the client's IP address and target communication port.
[0109] As an optional implementation of the disclosed embodiment, the need to push a message to the client is determined by the following modules: a first determination module, used to determine that a message needs to be pushed to the client when a message push instruction is received; and / or, a second determination module, used to determine that a message needs to be pushed to the client when a preset time point is reached.
[0110] As an optional implementation of the disclosed embodiment, the message push device method also includes: a client determination module, used to determine the client that needs to push the message based on the message push instruction and / or the preset time point and the pre-stored portrait of each client; the information query request is used to query the IP address and target communication port of the client that needs to push the message.
[0111] The specific implementation methods and effects can be found in the description of the method embodiment in which the execution subject is a push server, which will not be repeated here.
[0112] So far, the Figure 7 Description of the schematic shown.
[0113] The disclosed embodiment also provides a computer-readable storage medium, when the instructions in the storage medium are executed by the processor of the server, the server can execute the message push method provided in the above embodiment. For example, the computer-readable storage medium can be ROM, RAM, CD-ROM, tape, floppy disk and optical data storage device, etc. It is worth noting that the computer-readable storage medium mentioned in the disclosed embodiment can be a non-volatile storage medium, in other words, it can be a non-transient storage medium.
[0114] Although multiple embodiments of the present disclosure have been shown and described herein, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art may think of many changes, modifications, and alternatives without departing from the thought and spirit of the present disclosure. It should be understood that in the process of practicing the present disclosure, various alternatives to the embodiments of the present disclosure described herein may be adopted. The attached claims are intended to define the scope of protection of the present disclosure, and therefore cover equivalents or alternatives within the scope of these claims.
Claims
1. A message push method, characterized in that: The method is applied to a client, and the method comprises: In response to monitoring a TCP connection request sent by the push server, establishing a TCP connection with the push server based on the TCP connection request; the TCP connection request is sent by the push server when determining that a message needs to be pushed to the client; Receiving a push message from the push server based on the TCP connection; In response to receiving the push message, a feedback message is sent to the push server so that the push server disconnects the TCP connection with the client, wherein the feedback message is used to identify that the client has received the push message.
2. The method according to claim 1, characterized in that Before responding to the TCP connection request sent by the push server, the method further includes: The TCP connection request sent by the push server is monitored through the target communication port; the target communication port is used for message push of the client.
3. The method according to claim 1, characterized in that Before responding to the TCP connection request sent by the push server, the method further includes: On the premise that the client accepts the message push, the IP address and target communication port of the client are sent to the storage server for storage; the storage server is used to store the IP address and target communication port of the client; The TCP connection request carries the IP address and target communication port of the client, and the TCP connection request is sent by the push server after acquiring the IP address and target communication port of the client from the storage server.
4. The method according to claim 3, characterized in that The method further comprises: When the IP address and / or target communication port of the client changes, the new IP address and / or target communication port is sent to the storage server for storage.
5. The method according to claim 3, characterized in that: The client accepts the message push through the following steps: Displaying a pop-up window on the client to ask whether to accept the message push; In response to an operation of clicking on the pop-up window to agree to accept the message push, it is determined that the client accepts the message push.
6. A message push method, characterized in that: The method is applied to a push server, and the method comprises: When it is determined that a message needs to be pushed to the client, a TCP connection request is sent to the client, so that the client establishes a TCP connection with the push server based on the TCP connection request; Sending a push message to the client based on the established TCP connection; In response to receiving a feedback message sent by the client based on the push message, disconnecting the TCP connection with the client; the feedback message is used to identify that the client has received the push message.
7. The method according to claim 6, characterized in that Before sending the TCP connection request to the client, the method further includes: Sending an information query request to a storage server, wherein the information query request is used to query the IP address and target communication port of the client; the storage server is used to store the IP address and target communication port of the client, and the target communication port is used for message push; Receiving the IP address and target communication port of the client sent by the storage server based on the information query request; The sending of a TCP connection request to the client comprises: A TCP connection request is sent to the client based on the IP address of the client and the target communication port.
8. The method according to claim 6 or 7, characterized in that: The need to push a message to the client is determined in the following way: Upon receiving the message push instruction, determining that a message needs to be pushed to the client; and / or, When the preset time point is reached, it is determined that a message needs to be pushed to the client.
9. The method according to claim 8, characterized in that Before sending the information query request to the storage server, the method further includes: The client to which the message is to be pushed is determined based on the message push instruction and / or the preset time point and the pre-stored portraits of each client; the information query request is used to query the IP address and target communication port of the client to which the message is to be pushed.
10. A message push method, characterized in that: The method is applied to a message push system, the message push system includes: a client and a push server, and the method includes: On the push server: When it is determined that a message needs to be pushed to the client, a TCP connection request is sent to the client, so that the client establishes a TCP connection with the push server based on the TCP connection request; On the client side: In response to monitoring a TCP connection request sent by a push server, establishing a TCP connection with the push server based on the TCP connection request; On the push server: Sending a push message to the client based on the established TCP connection; On the client side: Receiving a push message from the push server based on the TCP connection; In response to receiving the push message, sending a feedback message to the push server so that the push server disconnects the TCP connection with the client, wherein the feedback message is used to identify that the client has received the push message; On the push server: In response to receiving a feedback message sent by the client based on the push message, disconnecting the TCP connection with the client.
11. A message push system, characterized in that: The system comprises: a client and a push server; Wherein, the client is configured as: In response to monitoring a TCP connection request sent by the push server, establishing a TCP connection with the push server based on the TCP connection request; the TCP connection request is sent by the push server when determining that a message needs to be pushed to the client; Receiving a push message from the push server based on the TCP connection; In response to receiving the push message, sending a feedback message to the push server so that the push server disconnects the TCP connection with the client, wherein the feedback message is used to identify that the client has received the push message; The push server is configured as follows: When it is determined that a message needs to be pushed to the client, a TCP connection request is sent to the client, so that the client establishes a TCP connection with the push server based on the TCP connection request; Sending a push message to the client based on the established TCP connection; In response to receiving a feedback message sent by the client based on the push message, disconnecting the TCP connection with the client.
12. A message push device, characterized in that: The device is applied to a client, and comprises: A TCP connection request monitoring module, configured to establish a TCP connection with the push server based on the TCP connection request in response to monitoring the TCP connection request sent by the push server; the TCP connection request is sent by the push server when determining that a message needs to be pushed to the client; A push message receiving module, used for receiving a push message from the push server based on the TCP connection; A feedback message sending module is used to send a feedback message to the push server in response to receiving the push message so that the push server disconnects the TCP connection with the client, wherein the feedback message is used to identify that the client has received the push message.
13. A message push device, characterized in that: The device is applied to a push server, and the device includes: A TCP connection request sending module, used for sending a TCP connection request to the client when it is determined that a message needs to be pushed to the client, so that the client establishes a TCP connection with the push server based on the TCP connection request; A push message sending module, used to send a push message to the client based on the established TCP connection; The TCP connection disconnection module is used to disconnect the TCP connection with the client in response to receiving a feedback message sent by the client based on the push message; the feedback message is used to identify that the client has received the push message.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program or an instruction, and when the program or the instruction is executed by a processor, the steps of the method according to any one of claims 1 to 5 or the steps of the method according to any one of claims 6 to 9 are implemented.
