Message sending method, device, electronic device and storage medium
By monitoring the user account's message to establish a live broadcast connection and storing the message to be sent in the storage channel, and sending the message through a fixed thread based on the live broadcast room identification, it solves the problem of high cost and risk of APP-level long connection communication, and realizes efficient point-to-point communication. .
Patent Information
- Application Number
- CN202110477102.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-29
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2041-04-29
AI Technical Summary
In the existing technology, when using APP-level long connections for live broadcast point-to-point communication, the development cost is high and the communication risk is high. In addition, the user-level QPS in the live broadcast room is amplified, affecting the reliability of message arrival.
By monitoring the user account's message to establish a live broadcast connection, obtain the message to be sent and store it in the corresponding storage channel, and send the message through a fixed thread based on the live broadcast room identification, realizing point-to-point communication based on a single live broadcast long connection, reducing the burden on the APP Dependencies and risks.
It realizes point-to-point communication based on a single live broadcast long connection, saving development costs, reducing communication risks, and improving the reliability of message arrival.
Smart Images

Figure CN113204440B
Abstract
Description
Technical Field
[0001] The present disclosure relates to communication technology, and in particular to a message sending method, device, electronic device, and storage medium. Background Art
[0002] With the continuous development of communication technology, online live streaming has become an emerging social method. Currently, long connections in live streaming rooms are usually managed based on the live streaming room dimension.
[0003] In related technologies, when point-to-point communication is required during live broadcasts, app-level persistent connections are generally used. However, using app-level persistent connections requires both the client and backend to implement the app-level persistent connection protocol, increasing development costs. The introduction of additional channels also increases the risk of message delivery. Summary of the Invention
[0004] The present disclosure provides a message sending method, device, electronic device, and storage medium to at least address the problem in related technologies of high development costs and high communication risks associated with live point-to-point communication via app-level persistent connections. The technical solutions of the present disclosure are as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, a message sending method is provided, including:
[0006] Listening for a connection message from a user account establishing a live broadcast connection, wherein the connection message includes an account identifier of the user account and a live broadcast process to which the user account is connected;
[0007] Obtaining a message to be sent, wherein the message to be sent carries an account identifier of a target account to receive the message and an identifier of a live broadcast room where the target account is located;
[0008] Based on the account identifier of the target account receiving the message and the live broadcast process to which the target account is connected, obtaining a storage channel corresponding to the message to be sent, and storing the message to be sent in the corresponding storage channel;
[0009] Based on the live broadcast room identifier, the message to be sent stored in the storage channel is sent to the corresponding target account through a fixed thread.
[0010] In one embodiment, the connection message also includes the connection time of the user account connecting to the live broadcast process; before obtaining the message to be sent, the method further includes: recording the live broadcast process and connection time of the user account connecting.
[0011] In one embodiment, after recording the live broadcast process and connection time of the user account connection, the method further includes: monitoring the heartbeat message of the user account establishing the live broadcast connection, obtaining the current live broadcast process and current connection time of the user account connection based on the heartbeat message; and recording the current live broadcast process and current connection time of the user account connection in a storage sequence.
[0012] In one embodiment, after monitoring the heartbeat message of the user account establishing a live connection, the method further includes: if no heartbeat message of the user account establishing a live connection is monitored within a preset time period, deleting the message to be sent corresponding to the account identifier of the user account in the storage channel.
[0013] In one embodiment, the live broadcast process of the user account is the latest current live broadcast process in the storage sequence corresponding to the current connection time.
[0014] After storing the message to be sent in the corresponding storage channel, the method further includes:
[0015] Record the message to be sent in the sending queue;
[0016] When it is monitored that the message to be sent stored in the storage channel is sent to the corresponding target account through a fixed thread, the message to be sent is deleted from the sending queue.
[0017] In one embodiment, after recording the message to be sent in the sending queue, the method further includes: recording the recording time of the message to be sent in the sending queue; periodically scanning the messages to be sent recorded in the sending queue, and if the time interval between the current scanning time and the recording time of the message to be sent exceeds a first set threshold, the message to be sent is re-stored in the storage channel.
[0018] In one embodiment, after the periodic scanning records the pending messages in the sending queue, the method further includes: if the time interval between the current scanning time and the recording time of the pending messages exceeds a second set threshold, deleting the pending messages from the sending queue, and the second set threshold is greater than the first set threshold.
[0019] According to a second aspect of an embodiment of the present disclosure, a message sending device is provided, including:
[0020] A connection message monitoring module is configured to monitor a connection message sent by a user account to establish a live broadcast connection, wherein the connection message includes an account identifier of the user account and a live broadcast process connected to the user account;
[0021] A message acquisition module to be sent is configured to execute acquisition of a message to be sent, wherein the message to be sent carries an account identifier of a target account for receiving the message and an identifier of a live broadcast room where the target account is located;
[0022] A storage module is configured to obtain a storage channel corresponding to the message to be sent based on an account identifier of a target account receiving the message and a live broadcast process to which the target account is connected, and store the message to be sent in the corresponding storage channel;
[0023] The message sending module is configured to execute, based on the live broadcast room identifier, sending the message to be sent stored in the storage channel to the corresponding target account through a fixed thread.
[0024] In one embodiment, the connection message also includes the connection time of the user account connecting to the live broadcast process; the device also includes: a recording module configured to execute and record the live broadcast process and connection time of the user account connecting.
[0025] In one embodiment, the device further includes: a heartbeat message monitoring module, configured to monitor the heartbeat message of the user account establishing a live broadcast connection, and obtain the current live broadcast process and current connection time of the user account connection based on the heartbeat message; the recording module is also configured to record the current live broadcast process and current connection time of the user account connection in a storage sequence.
[0026] In one embodiment, the heartbeat message monitoring module is further configured to execute: if no heartbeat message for establishing a live broadcast connection of the user account is monitored within a preset time period, then the message to be sent corresponding to the account identifier of the user account in the storage channel is deleted.
[0027] In one embodiment, the live broadcast process of the user account is the latest current live broadcast process in the storage sequence corresponding to the current connection time.
[0028] In one embodiment, the device further includes a sending queue recording module, which is configured to execute: recording the message to be sent in the sending queue; and deleting the message to be sent from the sending queue when it is monitored that the message to be sent stored in the storage channel is sent to the corresponding target account through a fixed thread.
[0029] In one embodiment, the sending queue recording module is further configured to execute: recording the recording time of the message to be sent in the sending queue; periodically scanning the messages to be sent recorded in the sending queue, and if the time interval between the current scanning time and the recording time of the message to be sent exceeds a first set threshold, then re-storing the message to be sent in the storage channel.
[0030] In one embodiment, the sending queue recording module is further configured to execute: if the time interval between the current scanning time and the recording time of the message to be sent exceeds a second set threshold, then the message to be sent is deleted from the sending queue, and the second set threshold is greater than the first set threshold.
[0031] According to a third aspect of an embodiment of the present disclosure, a server is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions so that the server executes the message sending method described in any one of the embodiments of the first aspect.
[0032] According to a fourth aspect of an embodiment of the present disclosure, a storage medium is provided. When instructions in the storage medium are executed by a processor of a server, the server is enabled to execute the message sending method described in any one of the embodiments of the first aspect.
[0033] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, which includes a computer program stored in a readable storage medium, and at least one processor of a device reads and executes the computer program from the readable storage medium, so that the device executes the message sending method described in any one of the embodiments of the first aspect.
[0034] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects: by monitoring the connection message of the user account to establish a live broadcast connection, and obtaining the message to be sent to the target account, based on the account identification of the target account and the live broadcast process to which the target account is connected, obtaining the storage channel corresponding to the message to be sent, storing the message to be sent in the corresponding storage channel, and based on the live broadcast room identification, sending the message to be sent stored in the storage channel to the corresponding target account through a fixed thread, thereby realizing point-to-point communication based on a single live broadcast long connection, which not only saves the development cost of implementing point-to-point communication based on APP, but also reduces the dependence and risk of implementing point-to-point communication based on APP.
[0035] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The accompanying drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute an improper limitation of the present disclosure.
[0037] Figure 1 The figure is a flowchart of a message sending method according to an exemplary embodiment.
[0038] Figure 2 The figure is a flowchart of a message sending method according to another exemplary embodiment.
[0039] Figure 3 The figure is a flowchart of a message sending method according to yet another exemplary embodiment.
[0040] Figure 4 The figure is a block diagram of a device for sending a message according to an exemplary embodiment.
[0041] Figure 5 The figure is a block diagram of a server according to an exemplary embodiment. DETAILED DESCRIPTION
[0042] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0043] It should be noted that the terms "first," "second," and the like in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the numbers used in this manner are interchangeable where appropriate so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure as detailed in the appended claims.
[0044] Since the current long connection of the live broadcast room is usually managed in the dimension of the live broadcast room, this method is very friendly to the support of broadcast messages in the live broadcast room, but it is not very friendly to the support of point-to-point communication capabilities. Therefore, for scenarios that require point-to-point communication, the current implementation method is to use APP-level long connections for communication. Sending point-to-point messages directly on the existing live broadcast long connection solution will cause the user-level amplification of the storage and related resource access QPS (Queries-per-second) of the entire link in the live broadcast room. If the APP-level long connection is continued to be used for communication, the end and the back-end need to access the APP-level long connection protocol, which increases the development cost, and the introduction of additional channels also increases the risk of message arrival.
[0045] Based on this, the present disclosure provides a message sending method, which realizes point-to-point communication based on the long connection of the live broadcast room. Figure 1 As shown, this embodiment takes the method applied to a server as an example for description, and specifically includes the following steps:
[0046] In step S110, a connection message for establishing a live broadcast connection with a user account is monitored.
[0047] Among them, the connection message includes the account identification of the user account and the live broadcast process to which the user account is connected. Specifically, the account identification is a sign or mark used to identify the account identity, such as an ID (Identity document, such as the account's ID number, account number, unique code, etc.) used to uniquely represent the account identity. Establishing a live broadcast connection refers to establishing a connection with the live broadcast server. Specifically, when the user account logs in to the live broadcast application or opens the live broadcast page, it indicates that the user account has established a connection with the live broadcast server. The live broadcast process refers to the system resources owned by the user account to establish a connection with the live broadcast server, that is, the backend process or instance. Specifically, the live broadcast process to which the user account is connected can be obtained when the user account establishes a connection with the live broadcast server. In this embodiment, the account identification of the user account in the connection message and the live broadcast process to which the user account establishes a live broadcast connection are obtained by monitoring the connection message of the user account to establish a live broadcast connection.
[0048] In step S120, the message to be sent is obtained.
[0049] The "to-be-sent message" refers to a message to be sent to a user account that has established a live broadcast connection. Specifically, the to-be-sent message carries the account ID of the target account receiving the message and the ID of the live broadcast room where the target account resides. The live broadcast room ID is a mark or symbol used to distinguish live broadcast rooms, such as a live broadcast room ID that uniquely represents a live broadcast room. The live broadcast room ID enables point-to-point message processing based on the live broadcast room dimension. In this embodiment, by obtaining the to-be-sent message to be sent to the target account, subsequent steps are taken to implement point-to-point message sending to the target account based on the long live broadcast room connection.
[0050] In step S130, based on the account identifier of the target account and the live broadcast process to which the target account is connected, a storage channel corresponding to the message to be sent is obtained, and the message to be sent is stored in the corresponding storage channel.
[0051] Among them, the storage channel is an intermediate storage space for storing messages to be sent. Since the live broadcast process is the system resource owned by the user account to establish a connection with the live broadcast server, that is, the backend process or instance, and the single instance has a limit on the total number of connections, the total number of account connections will be controlled within a certain range, but usually the number will not be too small. Therefore, in this embodiment, in order to avoid the problem of message sending delays caused by too many concurrent messages, the messages to be sent processed by the same instance are diverted by means of storage channels in this embodiment, that is, the storage channel corresponding to the message to be sent is obtained based on the account identifier of the target account, and the message to be sent is then stored in the corresponding storage channel. In this embodiment, the storage channel of the message to be sent can be obtained by calculation. For example, if the account identifier of the target account receiving the message in the message to be sent is U1, and it establishes a connection with the live broadcast process S1, then there is a mapping U1->S1. Then, according to U1, its corresponding storage channel can be calculated. For example, U1 can be modulo-operated based on the set value to obtain the modulus of U1 divided by the set value. For example, if the modulus of U1 divided by the set value is 3, then it can be determined that the storage channel corresponding to the message to be sent is key_S1_3. Therefore, the message to be sent can be stored in key_S1_3.
[0052] In step S140, based on the live broadcast room identifier, the message to be sent stored in the storage channel is sent to the corresponding target account through a fixed thread.
[0053] In this embodiment, based on the live broadcast room identifier, that is, based on the live broadcast room dimension, the pending messages stored in the storage channel can be sent to the corresponding target account through a fixed thread, thereby achieving point-to-point communication based on a single live broadcast long connection. Since multiple threads can run concurrently in a process, and multiple threads can execute different tasks in parallel, it is also possible to specify a fixed thread for each storage channel. Then, the pending messages stored in the storage channel can be sent to the corresponding target account through the fixed thread corresponding to the storage channel, thereby speeding up the processing speed of point-to-point communication.
[0054] The above-mentioned message sending method monitors the connection message of the user account to establish a live broadcast connection, and obtains the message to be sent to the target account. Based on the account identifier of the target account and the live broadcast process to which the target account is connected, the storage channel corresponding to the message to be sent is obtained, the message to be sent is stored in the corresponding storage channel, and based on the live broadcast room identifier, the message to be sent stored in the storage channel is sent to the corresponding target account through a fixed thread, thereby realizing point-to-point communication based on a single live broadcast long connection, which not only saves the development cost of point-to-point communication based on APP, but also reduces the dependence and risk of point-to-point communication based on APP.
[0055] In an exemplary embodiment, the connection message also includes the connection time of the user account connecting to the live broadcast process. Prior to obtaining the message to be sent, the method further includes recording the live broadcast process connected to the user account and the connection time. The connection time may be the time at which the user account connected to the live broadcast process. Specifically, by monitoring the connection message of the user account establishing the live broadcast connection, the connection time of the user account connecting to the live broadcast process in the connection message can be obtained. Based on the monitored connection message, the live broadcast process connected to the user account and the connection time obtained from the connection message are recorded. In this embodiment, the live broadcast process connected to the user account may be the corresponding process identifier, and the connection time may be the time at which the connection with the live broadcast process was established. For example, if user account U1 establishes a connection with live broadcast process S1 at time T1, then a mapping U1->S1 exists. Therefore, U1->(S1, T1) may be recorded, indicating that user account U1 established a connection with S1 (i.e., the live broadcast process) at time T1 (i.e., the connection time).
[0056] In this embodiment, by recording the live broadcast process and connection time of the user account connection, when it is necessary to send a point-to-point message to the user account, the instance of message reception can be quickly determined based on the live broadcast process of the user account connection, so as to realize the transmission of point-to-point messages based on the live broadcast long connection.
[0057] In an exemplary embodiment, Figure 2 As shown, after recording the live broadcast process and connection time of the user account establishing the connection, the above method further includes the following steps:
[0058] In step S210, the heartbeat message of the user account establishing the live broadcast connection is monitored, and the current live broadcast process and the current connection time of the user account connection are obtained based on the heartbeat message.
[0059] Usually, due to network jitter or abnormality, the connection between the user account and the live broadcast process that was originally established will be disconnected, and when the network returns to normal, the live broadcast process will be re-assigned to the user account to enable it to establish a connection. Therefore, in this embodiment, by monitoring the heartbeat message of the user account to establish a live broadcast connection, and obtaining the current live broadcast process and current connection time of the user account connection based on the heartbeat message, the live broadcast process where the user account is located is maintained in real time. Among them, the current live broadcast process and the current connection time are obtained based on the currently monitored heartbeat message. Under normal circumstances, by monitoring each heartbeat message, the live broadcast process and the corresponding connection time that the corresponding user account establishes a connection can be obtained. In this embodiment, based on time as the dimension, the live broadcast process that the user account establishes a connection through the most recent heartbeat message monitoring can be determined as the current live broadcast process, and the corresponding connection time can be determined as the current connection time, while the live broadcast process and connection time before that are historical data.
[0060] In step S220, the current live broadcast process of the user account connection and the current connection time are recorded in the storage sequence.
[0061] Among them, the storage sequence is an ordered list with time as the dimension. Since the heartbeat message is usually periodic, the current live broadcast process connected to the corresponding monitored user account and the current connection time are stored in the storage sequence in order according to the sequence of the heartbeat messages. For example, if the user account U1 establishes a connection with the live broadcast process S1 at time point T1, there is a mapping U1->S1, and U1->(S1, T1) is recorded. Since the network jitter on the account side will cause the live broadcast process to be reconnected, the above mapping relationship U1->S1 becomes invalid. And by further monitoring the heartbeat message of the account, if the user account U1 is monitored to establish a connection with the live broadcast process S2 at the current time point T2, the live broadcast process where the user account is located is maintained, that is, the current live broadcast process connected to the user account and the current connection time are recorded through the storage sequence zset, then there is U1->zset(<S1,T1> ,<S2,T2> ), where T2 > T1, T1 is the historical connection time, and T2 is the current connection time. This indicates that the user account has switched from live stream process S1 to S2. Therefore, S2 should be the process that handles messages sent to the user account. Based on this, the live stream process in which the user account resides is the latest live stream process in the stored sequence that corresponds to the current connection time.
[0062] In the above embodiment, since the heartbeat message is periodic, if the heartbeat message for establishing a live broadcast connection with the user account is not monitored within the preset time period, it means that the user account has left the live broadcast room, that is, disconnected from the live broadcast server, and therefore no more messages can be pushed to the user account, thereby deleting the pending messages corresponding to the account identifier of the user account in the storage channel. Specifically, if the period for monitoring the heartbeat message is 20 seconds, the preset time period should have at least one redundant heartbeat loss logic. For example, the preset time period can be set to 45 seconds. If the heartbeat message for establishing a live broadcast connection with the user account is not monitored within 45 seconds, no more messages can be pushed to the user account, and the pending messages corresponding to the account identifier of the user account in the storage channel can be deleted, thereby avoiding message redundancy and affecting the immediacy of message sending.
[0063] In an exemplary embodiment, Figure 3 As shown, after storing the message to be sent in the corresponding storage channel, the above method further includes the following steps:
[0064] In step S310, the message to be sent is recorded in the sending queue.
[0065] The "sending queue" is a queue used to record messages being sent. Since the current live broadcast connection channel does not implement an ACK (Acknowledge character) mechanism for client messages, the server cannot detect whether a message has been sent. Therefore, in this embodiment, when a message needs to be sent, in step S120, the message to be sent is stored in the corresponding storage channel. At the same time, the message to be sent can be recorded in the "sending queue" and the corresponding monitoring message service can be started for processing.
[0066] In step S320, when it is monitored that the to-be-sent message stored in the storage channel is sent to the corresponding target account through a fixed thread, the to-be-sent message is deleted from the sending queue.
[0067] Specifically, when a pending message stored in a storage channel is detected being sent to the corresponding target account via a fixed thread, it indicates that the pending message has been sent, and the pending message can be deleted from the sending queue. This implements a feedback mechanism that can detect whether a message has been sent, and further enables statistics on message arrival rates.
[0068] In an exemplary embodiment, after recording the pending message in the sending queue, the method further includes: recording the time the pending message was recorded in the sending queue; periodically scanning the pending messages recorded in the sending queue, and if the time interval between the current scan time and the time the pending message was recorded exceeds a first set threshold, re-storing the pending message in the corresponding storage channel. If the time interval between the current scan time and the time the pending message was recorded exceeds a second set threshold, deleting the pending message from the sending queue, wherein the second set threshold is greater than the first set threshold. Specifically, when recording the pending message in the sending queue, the time the pending message was recorded in the sending queue is also recorded, and the pending messages recorded in the sending queue are periodically scanned. Since the pending message is deleted from the sending queue after it is sent to the corresponding target account, the pending message is deleted. Therefore, if the pending message remains in the sending queue for more than the first set threshold and has not been deleted, it indicates that the pending message has not been sent to the target account. Therefore, the pending message can be re-sent to the corresponding storage channel, i.e., resent. When the message to be sent exceeds the second set threshold in the sending queue and has not been deleted, since the messages in the live broadcast process have a certain timeliness, it means that the message to be sent is no longer necessary to be sent. Therefore, the message to be sent can be deleted from the sending queue.
[0069] In the above embodiment, by recording the recording time of the message to be sent in the sending queue, and periodically scanning the messages to be sent recorded in the sending queue, if the time interval between the current scanning time and the recording time of the message to be sent exceeds the first set threshold, the message to be sent is re-stored in the corresponding storage channel; if the time interval between the current scanning time and the recording time of the message to be sent exceeds the second set threshold, the message to be sent is deleted from the sending queue, thereby achieving a backup plan for the message sending failure scenario under network anomalies, and improving the message arrival rate by retransmitting.
[0070] It should be understood that although Figure 1-Figure 3 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 1-Figure 4 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The order of execution of these steps or stages is not necessarily one by one, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0071] Figure 4 FIG. 1 is a block diagram of a message sending device according to an exemplary embodiment. Figure 4 The device includes a connection message monitoring module 402, a message acquisition module 404 to be sent, a storage module 406 and a message sending module 408, wherein:
[0072] A connection message monitoring module 402 is configured to monitor a connection message for a user account to establish a live broadcast connection, wherein the connection message includes an account identifier of the user account and a live broadcast process connected to the user account;
[0073] The message acquisition module 404 is configured to acquire a message to be sent, wherein the message to be sent carries an account identifier of a target account receiving the message and an identifier of a live broadcast room where the target account is located;
[0074] The storage module 406 is configured to obtain a storage channel corresponding to the message to be sent based on the account identifier of the target account receiving the message and the live broadcast process connected to the target account, and store the message to be sent in the corresponding storage channel;
[0075] The message sending module 408 is configured to execute, based on the live broadcast room identifier, sending the to-be-sent message stored in the storage channel to the corresponding target account through a fixed thread.
[0076] In an exemplary embodiment, the connection message also includes the connection time of the user account connecting to the live broadcast process; the device also includes: a recording module configured to execute and record the live broadcast process and connection time of the user account connecting.
[0077] In an exemplary embodiment, the device also includes: a heartbeat message monitoring module, configured to monitor the heartbeat message of the user account establishing a live broadcast connection, and obtain the current live broadcast process and current connection time of the user account connection based on the heartbeat message; the recording module is also configured to record the current live broadcast process and current connection time of the user account connection in a storage sequence.
[0078] In an exemplary embodiment, the heartbeat message monitoring module is further configured to execute: if no heartbeat message for establishing a live broadcast connection with the user account is monitored within a preset time period, then the to-be-sent message corresponding to the account identifier of the user account in the storage channel is deleted.
[0079] In an exemplary embodiment, the live broadcast process in which the user account is located is the latest current live broadcast process in the storage sequence that corresponds to the current connection time.
[0080] In an exemplary embodiment, the device also includes a sending queue recording module, which is configured to execute: recording the message to be sent in the sending queue; and deleting the message to be sent from the sending queue when it is monitored that the message to be sent stored in the storage channel is sent to the corresponding target account through a fixed thread.
[0081] In an exemplary embodiment, the sending queue recording module is further configured to execute: recording the recording time of the message to be sent in the sending queue; periodically scanning the messages to be sent recorded in the sending queue, and if the time interval between the current scanning time and the recording time of the message to be sent exceeds a first set threshold, the message to be sent is re-stored in the storage channel.
[0082] In an exemplary embodiment, the sending queue recording module is further configured to execute: if the time interval between the current scanning time and the recording time of the message to be sent exceeds a second set threshold, the message to be sent is deleted from the sending queue, and the second set threshold is greater than the first set threshold.
[0083] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0084] Figure 5 FIG. 1 is a block diagram of a device S00 for sending a message according to an exemplary embodiment. For example, the device S00 may be a server. Figure 5 Device S00 includes a processing component S20, which further includes one or more processors and a memory resource represented by a memory S22 for storing instructions executable by processing component S20, such as an application. The application stored in memory S22 may include one or more modules, each corresponding to a set of instructions. Furthermore, processing component S20 is configured to execute the instructions to perform the above-described message sending method.
[0085] The device S00 may further include a power supply component S24 configured to perform power management of the device S00, a wired or wireless network interface S26 configured to connect the device S00 to a network, and an input / output (I / O) interface S28. The device S00 may operate based on an operating system stored in the memory S22, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, or the like.
[0086] In an exemplary embodiment, a computer-readable storage medium including instructions is further provided, such as a memory S22 including instructions. The instructions can be executed by a processor of the device S00 to perform the above method. The storage medium can be a computer-readable storage medium, such as a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0087] In an exemplary embodiment, a computer program product is further provided, including a computer program, wherein the computer program implements the above-mentioned message sending method when executed by a processor.
[0088] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the following claims.
[0089] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A message sending method, characterized in that: The method realizes point-to-point communication based on the long connection of the live broadcast room, and the method includes: Listening for a connection message of a user account to establish a live broadcast connection, wherein the connection message includes an account identifier of the user account and a live broadcast process connected to the user account; Obtaining a message to be sent, wherein the message to be sent carries an account identifier of a target account for receiving the message and an identifier of a live broadcast room where the target account is located; Based on the account identifier of the target account receiving the message and the live broadcast process to which the target account is currently connected, a storage channel corresponding to the message to be sent is obtained, and the message to be sent is stored in the corresponding storage channel; Based on the live broadcast room identifier, the to-be-sent message stored in the storage channel is sent to the corresponding target account through a fixed thread, where the fixed thread is a thread corresponding to the storage channel among multiple concurrent threads of the live broadcast process to which the target account is currently connected; The acquiring, based on the account identifier of the target account receiving the message and the live broadcast process to which the target account is currently connected, a storage channel corresponding to the message to be sent, comprises: performing a modulus operation on the account identifier of the target account based on a set value, acquiring a modulus of the account identifier of the target account divided by the set value, and determining the storage channel of the message to be sent based on the live broadcast process to which the target account is currently connected and the modulus; After storing the message to be sent in the corresponding storage channel, the method further includes: recording the message to be sent in a sending queue; and when monitoring that the message to be sent stored in the storage channel is sent to the corresponding target account through a fixed thread, deleting the message to be sent from the sending queue.
2. The message sending method according to claim 1, characterized in that: The connection message also includes the connection time of the user account connecting to the live broadcast process; before obtaining the message to be sent, the method also includes: Record the live broadcast process and connection time of the user account connection.
3. The message sending method according to claim 2, characterized in that: After recording the live broadcast process and connection time of the user account connection, the method further includes: Monitoring the heartbeat message of the user account establishing a live broadcast connection, and obtaining the current live broadcast process and current connection time of the user account connection based on the heartbeat message; The current live broadcast process and the current connection time of the user account connection are recorded in the storage sequence.
4. The message sending method according to claim 3, characterized in that: After monitoring the heartbeat message of establishing the live broadcast connection with the user account, the method further includes: If no heartbeat message for establishing a live broadcast connection with the user account is monitored within a preset time period, the to-be-sent message corresponding to the account identifier of the user account in the storage channel is deleted.
5. The message sending method according to claim 3, characterized in that: The live broadcast process to which the target account is currently connected is the latest current live broadcast process in the storage sequence that corresponds to the current connection time.
6. The message sending method according to claim 1, characterized in that: After recording the message to be sent in the sending queue, the method further includes: Recording the recording time of the message to be sent in the sending queue; The to-be-sent messages recorded in the sending queue are scanned periodically, and if the time interval between the current scanning time and the recording time of the to-be-sent messages exceeds a first set threshold, the to-be-sent messages are stored again in the storage channel.
7. The message sending method according to claim 6, characterized in that: After the periodic scanning records the messages to be sent in the sending queue, the method further includes: If the time interval between the current scanning time and the recording time of the message to be sent exceeds a second set threshold, the message to be sent is deleted from the sending queue, and the second set threshold is greater than the first set threshold.
8. A message sending device, characterized in that: The device realizes point-to-point communication based on the long connection of the live broadcast room, including: A connection message monitoring module is configured to monitor a connection message of a user account to establish a live broadcast connection, wherein the connection message includes an account identifier of the user account and a live broadcast process connected to the user account; A message acquisition module to be sent, configured to execute acquisition of a message to be sent, wherein the message to be sent carries an account identifier of a target account for receiving the message and an identifier of a live broadcast room where the target account is located; The storage module is configured to execute, based on the account identifier of the target account receiving the message and the live broadcast process to which the target account is currently connected, obtaining a storage channel corresponding to the message to be sent, and storing the message to be sent in the corresponding storage channel; A message sending module is configured to execute, based on the live broadcast room identifier, sending the to-be-sent message stored in the storage channel to the corresponding target account through a fixed thread, wherein the fixed thread is a thread corresponding to the storage channel among a plurality of concurrent threads of the live broadcast process to which the target account is currently connected; The storage module is further used to: perform a modulus operation on the account identifier of the target account based on a set value, obtain the modulus of the account identifier of the target account divided by the set value, and determine the storage channel of the message to be sent based on the live broadcast process currently connected to the target account and the modulus; The device also includes a sending queue recording module, which is configured to execute: recording the message to be sent in the sending queue; and deleting the message to be sent from the sending queue when it is monitored that the message to be sent stored in the storage channel is sent to the corresponding target account through a fixed thread.
9. The message sending device according to claim 8, characterized in that: The connection message also includes the connection time of the user account connecting to the live broadcast process; the device also includes: The recording module is configured to execute and record the live broadcast process and connection time of the user account connection.
10. The message sending device according to claim 9, characterized in that: The device also includes: A heartbeat message monitoring module is configured to monitor the heartbeat message of the user account establishing a live broadcast connection, and obtain the current live broadcast process and current connection time of the user account connection based on the heartbeat message; The recording module is also configured to execute recording of the current live broadcast process and current connection time of the user account connection in a storage sequence.
11. The message sending device according to claim 10, characterized in that: The heartbeat message monitoring module is also configured to execute: if no heartbeat message for establishing a live broadcast connection with the user account is monitored within a preset time period, deleting the to-be-sent message corresponding to the account identifier of the user account in the storage channel.
12. The message sending device according to claim 10, characterized in that: The live broadcast process to which the target account is currently connected is the latest current live broadcast process in the storage sequence that corresponds to the current connection time.
13. The message sending device according to claim 8, characterized in that: The sending queue record module is further configured to execute: Recording the recording time of the message to be sent in the sending queue; The to-be-sent messages recorded in the sending queue are scanned periodically, and if the time interval between the current scanning time and the recording time of the to-be-sent messages exceeds a first set threshold, the to-be-sent messages are stored again in the storage channel.
14. The message sending device according to claim 13, characterized in that: The sending queue record module is further configured to execute: If the time interval between the current scanning time and the recording time of the message to be sent exceeds a second set threshold, the message to be sent is deleted from the sending queue, and the second set threshold is greater than the first set threshold.
15. A server, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the message sending method according to any one of claims 1 to 7.
16. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of a server, the server is enabled to execute the message sending method according to any one of claims 1 to 7.
17. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the message sending method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Method and device for recommending connected user in live broadcast, server and storage medium
CN109348302A
Method and system for updating push information of live broadcast room
CN110012115A
Message pushing method and device, computer equipment and storage medium
CN110300050A
Live broadcast microphone connection state monitoring method and system, equipment, and storage medium
CN110971922A
Message pushing method and device, computer equipment and storage medium
CN111385330A
