[go: up one dir, main page]

CN115514809B - Message pushing method and device, electronic equipment and storage medium - Google Patents

Message pushing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115514809B
CN115514809B CN202211269247.4A CN202211269247A CN115514809B CN 115514809 B CN115514809 B CN 115514809B CN 202211269247 A CN202211269247 A CN 202211269247A CN 115514809 B CN115514809 B CN 115514809B
Authority
CN
China
Prior art keywords
routing
target
websocket
node
state
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202211269247.4A
Other languages
Chinese (zh)
Other versions
CN115514809A (en
Inventor
葛明曦
张倩
陈佳锋
孔祥瑞
刘思彦
许璐
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202211269247.4A priority Critical patent/CN115514809B/en
Publication of CN115514809A publication Critical patent/CN115514809A/en
Application granted granted Critical
Publication of CN115514809B publication Critical patent/CN115514809B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/02Topology update or discovery
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/143Termination or inactivation of sessions, e.g. event-controlled end of session
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The application provides a message pushing method, a message pushing device, electronic equipment and a storage medium, wherein the method comprises the steps of obtaining a routing state of a target user side; then determining a target Websocket node with a connection relation with the target user side from the plurality of Websocket nodes based on the routing state; and finally, pushing the message to be pushed to the target Websocket node, so that the target Websocket node sends the message to be pushed to the target user terminal, and the Websocket node only receives the message of the user terminal which establishes connection with the Websocket node, so that the waste of network flow and node computing power does not exist, and the efficiency of pushing the message is improved.

Description

Message pushing method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of message pushing technologies, and in particular, to a message pushing method, a device, an electronic device, and a storage medium.
Background
This section is intended to provide a background or context to the embodiments of the application that are recited in the claims. The description herein is not admitted to be prior art by inclusion in this section.
Websocket is a protocol for full duplex communication over a single TCP connection, and with Websocket, a browser and a server can directly create a persistent connection and perform bidirectional data transmission by only one handshake. A Websocket distributed cluster is typically used to serve tasks from the server side to the front end (user side), and a user may have established a connection with one or more nodes in the Websocket distributed cluster. In the related art, the message is mainly pushed by message broadcasting, in this way, a Websocket node which does not establish connection with a designated user terminal can also receive the message pushed to the user terminal, but only can discard the message, do idle work, and waste a great amount of network traffic and node computing resources.
Disclosure of Invention
In view of the above, the present application aims to provide a message pushing method, a device, an electronic apparatus and a storage medium.
Based on the above purpose, the application provides a message pushing method, which is applied to a message pushing system based on Websocket, wherein the message pushing system comprises a plurality of Websocket nodes; the method comprises the following steps:
Acquiring a routing state of a target user terminal;
Determining a target Websocket node with a connection relation with the target user terminal from the plurality of Websocket nodes based on the routing state;
And pushing the message to be pushed to the target Websocket node so that the target Websocket node sends the message to be pushed to the target user terminal.
Based on the same inventive concept, an exemplary embodiment of the present application further provides a message pushing apparatus, including:
the acquisition module acquires the routing state of the target user terminal;
The determining module is used for determining a target Websocket node with a connection relation with the target user side from the plurality of Websocket nodes based on the routing state;
and the pushing module pushes the message to be pushed to the target Websocket node so that the target Websocket node sends the message to be pushed to the target user terminal.
Based on the same inventive concept, the exemplary embodiments of the present application also provide an electronic device including a memory, a processor, and a computer program stored on the memory and executable by the processor, the processor implementing the message pushing method as described above when executing the program.
Based on the same inventive concept, exemplary embodiments of the present application also provide a non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the message pushing method as described above.
From the above, it can be seen that the message pushing method, device, electronic equipment and storage medium provided by the application acquire the routing state of the target user side; determining a target Websocket node with a connection relation with the target user terminal from the plurality of Websocket nodes based on the routing state; and pushing the message to be pushed to the target Websocket node so that the target Websocket node sends the message to be pushed to the target user terminal, and therefore the Websocket node only receives the message of the user terminal which establishes connection with the Websocket node, waste of network flow and node calculation force does not exist, and the efficiency of pushing the message is improved.
Drawings
In order to more clearly illustrate the technical solutions of the present application or related art, the drawings that are required to be used in the description of the embodiments or related art will be briefly described below, and it is apparent that the drawings in the following description are only embodiments of the present application, and other drawings may be obtained according to the drawings without inventive effort to those of ordinary skill in the art.
Fig. 1 is a schematic structural diagram of a message pushing system based on Websocket in the related art;
fig. 2 is a schematic structural diagram of a message pushing system based on Websocket according to an embodiment of the present application;
Fig. 3 is a flow chart of a message pushing method according to an embodiment of the present application;
Fig. 4 is a schematic structural diagram of another message pushing device according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of a specific electronic device according to an embodiment of the present application.
Detailed Description
The principles and spirit of the present application will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are presented merely to enable those skilled in the art to better understand and practice the application and are not intended to limit the scope of the application in any way. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the application to those skilled in the art.
According to the embodiment of the application, a message pushing method, a message pushing device, electronic equipment and a storage medium are provided.
In this document, it should be understood that any number of elements in the drawings is for illustration and not limitation, and that any naming is used only for distinction and not for any limitation.
The principles and spirit of the present application are explained in detail below with reference to several representative embodiments thereof.
Summary of The Invention
At present, in the related art, the message is mainly pushed by message broadcasting, in this way, a Websocket node which does not establish connection with a designated user terminal can also receive the message pushed to the user terminal, but only can discard the message, do idle work, and waste a large amount of network traffic and node computing resources. Referring to fig. 1, in the related art, when a server sends a push message to a certain client, the push message is sent to all Websocket nodes (Websocket nodes 1-4), but the current client has a connection relationship with Websocket node 1 only, so that the push message can only be sent to the client through Websocket node 1. And meanwhile, the push message is sent to the Websocket node 2-4, so that the message can only be discarded, and a large amount of network traffic and node computing resources are wasted.
In order to solve the above problems, the present application provides a message pushing method, which specifically includes:
Acquiring a routing state of a target user terminal; determining a target Websocket node with a connection relation with the target user terminal from the plurality of Websocket nodes based on the routing state; and pushing the message to be pushed to the target Websocket node so that the target Websocket node sends the message to be pushed to the target user terminal, and therefore the Websocket node only receives the message of the user terminal which establishes connection with the Websocket node, waste of network flow and node calculation force does not exist, and the efficiency of pushing the message is improved. Referring to fig. 2, when a server sends a push message to a certain user terminal (target user terminal), it will first determine which Websocket nodes have a connection relationship with the target user terminal through the routing state of the target user terminal, and when it is determined that only Websocket node 1 has a connection relationship with the target user terminal, only the push message needs to be sent to Websocket node 1, and no push message needs to be sent to Websocket nodes 2-4, thereby avoiding waste of network traffic and node computing power and improving efficiency of message pushing.
Having described the basic principles of the present application, various non-limiting embodiments of the application are described in detail below.
Application scene overview
In some specific application scenarios, the message pushing method of the present application may be applied to various platforms or systems involving message pushing.
The message pushing method according to the exemplary embodiment of the present application is described below in connection with a specific application scenario. It should be noted that the above application scenario is only shown for the convenience of understanding the spirit and principle of the present application, and the embodiments of the present application are not limited in any way. Rather, embodiments of the application may be applied to any scenario where applicable.
Exemplary method
Referring to fig. 3, an embodiment of the present application provides a message pushing method, where the method is applied to a Websocket-based message pushing system, and the message pushing system includes a plurality of Websocket nodes; the method comprises the following steps:
S101, obtaining the routing state of the target user terminal.
In the implementation, the routing state of the target user end is used for indicating which Websocket nodes the target user end establishes connection with. Alternatively, the routing states of the plurality of clients may be stored in a database, and then the routing states of the target clients are obtained from the database. Optionally, the target ue may be any ue, and the target ue is mainly used to represent a ue that is currently about to receive a message to be pushed, and may be set according to needs, which is not limited.
In some embodiments, the routing state is stored by redis.
In the implementation, redis (Remote Dictionary Server), i.e. remote dictionary service, is an open-source log-type and Key-Value database written in ANSI C language, supporting network, and capable of being based on memory and persistent, and provides APIs in multiple languages. Alternatively, the routing state may be stored in other databases in the prior art, which is not limited thereto.
S102, determining a target Websocket node with a connection relation with the target user side from the plurality of Websocket nodes based on the routing state.
In the implementation, after the routing state of the target user terminal is obtained, a target Websocket node having a connection relationship with the target user terminal can be determined from the Websocket nodes according to the routing state.
And S103, pushing the message to be pushed to the target Websocket node so that the target Websocket node sends the message to be pushed to the target user terminal.
In implementation, after determining a target Websocket node having a connection relationship with the target user terminal, the message to be pushed can be pushed to the target Websocket node, so that the target Websocket node sends the message to be pushed to the target user terminal.
It should be noted that, there may be multiple target Websocket nodes having a connection relationship with the target client, and then each target Websocket node will receive the message to be pushed at this time, so that each target Websocket node sends the message to be pushed to the target client. Optionally, the target ue may establish a connection with different Websocket nodes in different states, for example, the same ue may establish a connection with different Websocket nodes in different geographical areas, and all the connections may be recorded in the routing state of the ue, so as to ensure that the ue may receive the message to be pushed in each geographical area.
It should be noted that, in some embodiments, the pushing of the message to be pushed to the target Websocket node may be implemented by Rabbitmq (which is a set of open-source message queue service software), where the corresponding pushed message may be sent to a message queue on Rabbitmq corresponding to the target Websocket node, and in addition, those skilled in the art may select other manners as needed to implement the pushing of the message to be pushed to the target Websocket node, which is not limited thereto.
In some embodiments, determining, from the plurality of Websocket nodes, a target Websocket node having a connection relationship with the target client based on the routing state specifically includes:
Acquiring a first routing key of each Websocket node in the plurality of Websocket nodes;
Determining a second routing key of the target user terminal based on the routing state, and determining a target first routing key corresponding to the second routing key;
and determining the Websocket node corresponding to the target first routing key as the target Websocket node.
In the implementation, each Websocket node has a unique first routing key, and when a target Websocket node having a connection relationship with the target user terminal is determined from the Websocket nodes, a second routing key of the target user terminal is determined according to the routing state of the target user terminal, and optionally, the second routing key may be multiple or one, which is not limited herein. Each first routing key corresponds to a second routing key, and a connection relationship is established between the two routing keys, and optionally, a corresponding group of second routing keys and the first routing keys can be identical routing keys, namely, when the first routing keys are identical to the second routing keys, the two routing keys are indicated to be corresponding to each other. Alternatively, the corresponding relationship between the first routing key and the second routing key may be determined through a preset relationship list, which is not limited.
In some embodiments, determining the second routing key of the target ue based on the routing state specifically includes:
Acquiring a first target value with a value of 1 in the routing state and a first position of the first target value; wherein the routing state is represented by a binary number;
Determining the second routing key based on the first target value and the first location; wherein the second routing key passes through a binary number.
In particular, the routing state is represented by a binary number, wherein the first target values at different positions in the routing state determine the second routing key of the target user terminal. For example, routing state 101 may translate to second routing key 1.0.1 and routing state 1000 may translate to second routing key 1.0.0.0.
It should be noted that, in order to facilitate matching between the first routing key and the second routing key, the first routing key of each Websocket node may be represented by a wild card, for example, when the second routing key is 1.0.1, the first routing key corresponding to the second routing key 1.0.1 is: #.1 and #.1, wherein, "#" indicates that there is a number of words greater than or equal to 0 and "×" indicates that there is one word. When the first routing keys of the Websocket nodes are represented by wild cards and the second routing keys of the target user side are one value, all the first routing keys corresponding to the second routing keys of the current target user side can be determined directly by fuzzy matching.
In some embodiments, the second routing key is a plurality of; determining a target first routing key corresponding to the second routing key specifically comprises:
for each of a plurality of the second routing keys, determining the first routing key corresponding to the second routing key; wherein the first routing key is represented by a binary number and has only one value of 1;
And determining all the first routing keys corresponding to the second routing keys as the target first routing keys.
In particular, the first routing keys are represented by binary numbers and have only one value of 1, for example, there are currently three first routing keys: 1. 1.0, 1.0.0. The current routing state of the target user terminal is: 101, a second routing key obtained according to the routing state of the target user terminal is: 1 and 1.0.0. Two first routing keys of 1 and 1.0.0 among the above three first routing keys may be determined as the target first routing key. It should be noted that, when the number of the second routing keys at the target user end is plural, each second routing key is represented by a binary number, and only one value is 1.
In some embodiments, determining, from the plurality of Websocket nodes, a target Websocket node having a connection relationship with the target client based on the routing state specifically includes:
Acquiring a first routing key of each Websocket node in the plurality of Websocket nodes; wherein the first routing key is represented by a binary number and has only one value of 1;
determining a second position of a second target value with a value of 1 in the first routing key;
acquiring a first position of a first target value with a value of 1 in the routing state; wherein the routing state is represented by a binary number;
and determining the target Websocket node based on the first position and the second position.
In particular, when the routing state of the target ue is 101, two corresponding second positions of the second target value are the first bit and the third bit from right to left, respectively. The target Websocket node can be determined only by determining which two first routing keys have the first positions from right to left, namely the first position and the third position. Alternatively, each Websocket node first routing key may be represented by a wild card, such as the commonly used "#" and "×" two wild cards, where "#" represents that there is a number of words greater than or equal to 0 and "×" represents that there is a word, the words are separated by ".", then the first routing keys with the first position being the first and third positions from right to left, respectively, may be represented as: #.1 and #.1.
In some embodiments, before obtaining the routing state of the target ue, the method further includes:
responding to the establishment of connection between the target user and the target Websocket node, and updating the routing state based on the connection establishment response and the routing node state of the target Websocket node;
And in response to determining that the target user is disconnected from the target Websocket node, updating the routing state based on the response of the disconnection and the routing node state of the target Websocket node.
In the implementation, when determining the routing state of the target ue, optionally, the initial routing state of the target ue may be set to 0, that is, no connection is established with any Websocket node. And then, when the target user establishes connection with the target Websocket node, updating the routing state according to the routing node state of the target Websocket node, namely adding a first routing key into the routing state before updating. When the target user is disconnected with the target Websocket node, the routing state is updated according to the routing node state of the target Websocket node, namely a first routing key is subtracted from the routing state before updating. Therefore, the routing state of the target user terminal can be guaranteed to be always in the latest state, so that the push message can be accurately sent to the target Websocket node, and the target user terminal can be further guaranteed to receive the push message.
In some embodiments, updating the routing state based on the response to establish the connection and the routing node state of the target Websocket node specifically includes:
Acquiring the routing node state and the routing state before updating; wherein the routing states are represented by binary numbers and the routing node states are represented by binary numbers with one and only one value being 1;
and performing AND operation on the routing node state and the routing state before updating, and updating the routing state based on the result of the AND operation.
In the implementation, for example, if the routing state of the target ue before the update is 10, the routing node state of the target Websocket node that establishes a connection relationship with the target ue is 100, and the routing state of the updated target ue can be obtained by performing an and operation on 100 and 10 to be 110. Thus, the routing state can be updated quickly. Optionally, each Websocket node stores a respective routing node state, and the corresponding routing node state can be directly obtained from the target Websocket node.
In some embodiments, updating the routing state based on the response to disconnect and the routing node state of the target Websocket node specifically includes:
Acquiring the routing node state and the routing state before updating; wherein the routing states are represented by binary numbers and the routing node states are represented by binary numbers with one and only one value being 1;
And performing exclusive-or operation on the routing node state and the routing state before updating, and updating the routing state based on the result of the exclusive-or operation.
In the implementation, for example, if the routing state of the target ue before the update is 111, the routing node state of the target Websocket node disconnected from the target ue is 100, and the routing state of the updated target ue can be 011 (i.e. 11) by performing an exclusive or operation on 111 and 100. Therefore, the routing state can be quickly updated based on the response of disconnection and the routing node state of the target Websocket node.
In some embodiments, after updating the routing state, the method further comprises:
deleting the updated routing state in response to determining that all values in the updated routing state are 0;
wherein the routing state is represented by a binary number.
In the implementation, when all values in the updated routing state are 0, it is indicated that no connection is established between the target ue and all Websocket nodes at this time, so that in order to save memory, the updated routing state may be deleted directly.
The message pushing method provided by the application is applied to a message pushing system based on Websocket, wherein the message pushing system comprises a plurality of Websocket nodes; the method comprises the steps of firstly obtaining a routing state of a target user terminal; then determining a target Websocket node with a connection relation with the target user side from the plurality of Websocket nodes based on the routing state; and finally, pushing the message to be pushed to the target Websocket node, so that the target Websocket node sends the message to be pushed to the target user terminal, and the Websocket node only receives the message of the user terminal which establishes connection with the Websocket node, so that the waste of network flow and node computing power does not exist, and the efficiency of pushing the message is improved. In addition, in the related technology, a consistent hash algorithm is used to ensure that a push message is sent to a corresponding Websocket node, and then the corresponding Websocket node is pushed to a user side, but the method needs to erect a service registry and a gateway, the service registry needs to register to the service registry after the Websocket node is started, the service registry uses the consistent hash algorithm to construct a hash ring according to the registered Websocket node, the Websocket node is distributed on the hash ring, and the addition or deletion of the Websocket node can cause the unavailable connection of part of users, and meanwhile, the service registry needs to be additionally erected, so that the consistent hash algorithm is realized, the system complexity is increased, and the system maintenance burden of developers is increased; compared with the method, the method provided by the embodiment of the application has no additional system building cost and post maintenance cost, and is simple to realize; meanwhile, a part of Websocket nodes are added or deleted, other Websocket nodes cannot be affected, namely, connection established between a user side and other Websocket nodes cannot be interfered.
Exemplary apparatus
Based on the same inventive concept, the application also provides a message pushing device corresponding to the method in any embodiment.
Referring to fig. 4, the message pushing system includes:
An obtaining module 201, configured to obtain a routing state of a target user terminal;
A determining module 202, configured to determine, from the plurality of Websocket nodes, a target Websocket node having a connection relationship with the target client based on the routing state;
And the pushing module 203 pushes the message to be pushed to the target Websocket node, so that the target Websocket node sends the message to be pushed to the target user terminal.
For convenience of description, the above system is described as being functionally divided into various modules, respectively. Of course, the functions of each module may be implemented in the same piece or pieces of software and/or hardware when implementing the present application.
The system of the foregoing embodiment is configured to implement the corresponding message pushing method in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiment, which is not described herein.
Based on the same inventive concept, the application also provides an electronic device corresponding to the method of any embodiment, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor realizes the message pushing method of any embodiment when executing the program.
Fig. 5 shows a more specific hardware architecture of an electronic device according to this embodiment, where the device may include: a processor 1010, a memory 1020, an input/output interface 1030, a communication interface 1040, and a bus 1050. Wherein processor 1010, memory 1020, input/output interface 1030, and communication interface 1040 implement communication connections therebetween within the device via a bus 1050.
The processor 1010 may be implemented by a general-purpose CPU (Central Processing Unit ), a microprocessor, an Application SPECIFIC INTEGRATED Circuit (ASIC), or one or more integrated circuits, etc. for executing related programs to implement the technical solutions provided in the embodiments of the present disclosure.
The Memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory ), static storage, dynamic storage, etc. Memory 1020 may store an operating system and other application programs, and when the embodiments of the present specification are implemented in software or firmware, the associated program code is stored in memory 1020 and executed by processor 1010.
The input/output interface 1030 is used to connect with an input/output module for inputting and outputting information. The input/output module may be configured as a component in a device (not shown) or may be external to the device to provide corresponding functionality. Wherein the input devices may include a keyboard, mouse, touch screen, microphone, various types of sensors, etc., and the output devices may include a display, speaker, vibrator, indicator lights, etc.
Communication interface 1040 is used to connect communication modules (not shown) to enable communication interactions of the present device with other devices. The communication module may implement communication through a wired manner (such as USB, network cable, etc.), or may implement communication through a wireless manner (such as mobile network, WIFI, bluetooth, etc.).
Bus 1050 includes a path for transferring information between components of the device (e.g., processor 1010, memory 1020, input/output interface 1030, and communication interface 1040).
It should be noted that although the above-described device only shows processor 1010, memory 1020, input/output interface 1030, communication interface 1040, and bus 1050, in an implementation, the device may include other components necessary to achieve proper operation. Furthermore, it will be understood by those skilled in the art that the above-described apparatus may include only the components necessary to implement the embodiments of the present description, and not all the components shown in the drawings.
The electronic device of the foregoing embodiment is configured to implement the corresponding message pushing method in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiment, which is not described herein.
Exemplary program product
Based on the same inventive concept, the present application also provides a non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the message pushing method according to any of the above embodiments, corresponding to the method of any of the above embodiments.
The computer readable media of the present embodiments, including both permanent and non-permanent, removable and non-removable media, may be used to implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device.
The storage medium of the foregoing embodiments stores computer instructions for causing the computer to perform a message pushing method according to any of the foregoing embodiments, and has the advantages of the corresponding method embodiments, which are not described herein.
Those of ordinary skill in the art will appreciate that: the discussion of any of the embodiments above is merely exemplary and is not intended to suggest that the scope of the application (including the claims) is limited to these examples; the technical features of the above embodiments or in the different embodiments may also be combined within the idea of the application, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the application as described above, which are not provided in detail for the sake of brevity.
Additionally, well-known power/ground connections to Integrated Circuit (IC) chips and other components may or may not be shown within the provided figures, in order to simplify the illustration and discussion, and so as not to obscure the embodiments of the present application. Furthermore, the devices may be shown in block diagram form in order to avoid obscuring the embodiments of the present application, and also in view of the fact that specifics with respect to implementation of such block diagram devices are highly dependent upon the platform within which the embodiments of the present application are to be implemented (i.e., such specifics should be well within purview of one skilled in the art). Where specific details (e.g., circuits) are set forth in order to describe example embodiments of the application, it should be apparent to one skilled in the art that embodiments of the application can be practiced without, or with variation of, these specific details. Accordingly, the description is to be regarded as illustrative in nature and not as restrictive.
While the application has been described in conjunction with specific embodiments thereof, many alternatives, modifications, and variations of those embodiments will be apparent to those skilled in the art in light of the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.
The present embodiments are intended to embrace all such alternatives, modifications and variances which fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, and the like, which are within the spirit and principles of the embodiments of the application, are intended to be included within the scope of the application.

Claims (12)

1. The message pushing method is characterized by being applied to a message pushing system based on Websocket, wherein the message pushing system comprises a plurality of Websocket nodes; the method comprises the following steps:
Acquiring a routing state of a target user terminal;
Determining a target Websocket node with a connection relation with the target user terminal from the plurality of Websocket nodes based on the routing state;
pushing the message to be pushed to the target Websocket node so that the target Websocket node sends the message to be pushed to the target user side;
The determining, based on the routing state, a target Websocket node having a connection relationship with the target user terminal from the plurality of Websocket nodes specifically includes:
Acquiring a first routing key of each Websocket node in the plurality of Websocket nodes; wherein the first routing key is represented by a binary number and has only one value of 1;
determining a second position of a second target value with a value of 1 in the first routing key;
acquiring a first position of a first target value with a value of 1 in the routing state; wherein the routing state is represented by a binary number;
and determining the target Websocket node based on the first position and the second position.
2. The method of claim 1, wherein determining, from the plurality of Websocket nodes, a target Websocket node having a connection relationship with the target client based on the routing state, specifically comprises:
Acquiring a first routing key of each Websocket node in the plurality of Websocket nodes;
Determining a second routing key of the target user terminal based on the routing state, and determining a target first routing key corresponding to the second routing key;
and determining the Websocket node corresponding to the target first routing key as the target Websocket node.
3. The method according to claim 2, wherein determining the second routing key of the target ue based on the routing state specifically comprises:
Acquiring a first target value with a value of 1 in the routing state and a first position of the first target value; wherein the routing state is represented by a binary number;
Determining the second routing key based on the first target value and the first location; wherein the second routing key is represented by a binary number.
4. A method according to claim 3, wherein the second routing key is a plurality of; determining a target first routing key corresponding to the second routing key specifically comprises:
for each of a plurality of the second routing keys, determining the first routing key corresponding to the second routing key; wherein the first routing key is represented by a binary number and has only one value of 1;
And determining all the first routing keys corresponding to the second routing keys as the target first routing keys.
5. The method of claim 1, wherein prior to obtaining the routing state of the target client, the method further comprises:
responding to the establishment of connection between the target user and the target Websocket node, and updating the routing state based on the connection establishment response and the routing node state of the target Websocket node;
And in response to determining that the target user is disconnected from the target Websocket node, updating the routing state based on the response of the disconnection and the routing node state of the target Websocket node.
6. The method of claim 5, wherein updating the routing state based on the response to establish the connection and the routing node state of the target Websocket node, specifically comprises:
Acquiring the routing node state and the routing state before updating; wherein the routing states are represented by binary numbers and the routing node states are represented by binary numbers with one and only one value being 1;
and performing AND operation on the routing node state and the routing state before updating, and updating the routing state based on the result of the AND operation.
7. The method according to claim 5, wherein updating the routing state based on the response to the disconnection and the routing node state of the target Websocket node, in particular comprises:
Acquiring the routing node state and the routing state before updating; wherein the routing states are represented by binary numbers and the routing node states are represented by binary numbers with one and only one value being 1;
And performing exclusive-or operation on the routing node state and the routing state before updating, and updating the routing state based on the result of the exclusive-or operation.
8. The method of claim 5, wherein after updating the routing state, the method further comprises:
Deleting the routing state in response to determining that all values in the updated routing state are 0;
wherein the routing state is represented by a binary number.
9. The method of claim 1, wherein the routing state is stored by redis.
10. A message pushing device, comprising:
the acquisition module acquires the routing state of the target user terminal;
the determining module is used for determining a target Websocket node with a connection relation with the target user terminal from a plurality of Websocket nodes based on the routing state;
the pushing module pushes the message to be pushed to the target Websocket node so that the target Websocket node sends the message to be pushed to the target user terminal;
The determining module is specifically configured to:
Acquiring a first routing key of each Websocket node in the plurality of Websocket nodes; wherein the first routing key is represented by a binary number and has only one value of 1;
determining a second position of a second target value with a value of 1 in the first routing key;
acquiring a first position of a first target value with a value of 1 in the routing state; wherein the routing state is represented by a binary number;
and determining the target Websocket node based on the first position and the second position.
11. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable by the processor, the processor implementing the method of any one of claims 1 to 9 when the program is executed.
12. A non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the method of any one of claims 1 to 9.
CN202211269247.4A 2022-10-17 2022-10-17 Message pushing method and device, electronic equipment and storage medium Active CN115514809B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211269247.4A CN115514809B (en) 2022-10-17 2022-10-17 Message pushing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211269247.4A CN115514809B (en) 2022-10-17 2022-10-17 Message pushing method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN115514809A CN115514809A (en) 2022-12-23
CN115514809B true CN115514809B (en) 2024-09-03

Family

ID=84509731

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211269247.4A Active CN115514809B (en) 2022-10-17 2022-10-17 Message pushing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115514809B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111917687A (en) * 2019-05-08 2020-11-10 北京京东振世信息技术有限公司 Method and device for circularly pushing reminding message

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112511595B (en) * 2020-11-04 2022-03-04 华云数据控股集团有限公司 Message pushing method and message service system
CN112925788B (en) * 2021-01-27 2025-03-14 上海商汤智能科技有限公司 A data set management method, system, device, electronic device and storage medium
CN113157466A (en) * 2021-04-27 2021-07-23 上海销氪信息科技有限公司 Message pushing method, device, system, electronic equipment and storage medium
CN114461419A (en) * 2022-01-14 2022-05-10 车智互联(北京)科技有限公司 Message pushing method, system, computing device and readable storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111917687A (en) * 2019-05-08 2020-11-10 北京京东振世信息技术有限公司 Method and device for circularly pushing reminding message

Also Published As

Publication number Publication date
CN115514809A (en) 2022-12-23

Similar Documents

Publication Publication Date Title
US20230118489A1 (en) Network-Assisted Consensus Protocol
CN110391938B (en) Method and apparatus for deploying services
CN106570097A (en) Sequence generating method and device
CN115145806A (en) Data acquisition method and device and computer readable storage medium
CN113626512A (en) Data processing method, device, equipment and readable storage medium
CN111259282A (en) URL duplicate removal method and device, electronic equipment and computer readable storage medium
CN112714042A (en) Pressure testing method and device, electronic equipment and storage medium
US10298656B2 (en) Extending representational state transfer application program interface (REST API) functionality
CN111597107B (en) Information output method and device and electronic equipment
JP2005228183A (en) Program execution method and computer system for program execution
CN115514809B (en) Message pushing method and device, electronic equipment and storage medium
CN109428788B (en) Function testing method and system
CN110928952A (en) Data synchronization method and device based on block chain
CN112286706B (en) Application information remote and rapid acquisition method of Android application and related equipment
CN113220281A (en) Information generation method and device, terminal equipment and storage medium
CN113347234A (en) Network information acquisition method, device, system, computer equipment and storage medium
US11838207B2 (en) Systems for session-based routing
CN116899212A (en) Game weapon control method and device, electronic equipment and storage medium
CN114760298B (en) Service request response method, device, electronic equipment and storage medium
CN112463410B (en) Distributed message architecture management method, platform and electronic equipment
CN114979128B (en) Cross-region communication method, device and electronic equipment
CN112256700B (en) Data storage method, device, electronic equipment and computer readable storage medium
CN112667579A (en) File storage method, device, equipment and storage medium
CN109450885B (en) Network data interception method and device, electronic equipment and storage medium
CN114115941A (en) Resource sending method, page rendering method, apparatus, electronic device and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant