Methods, apparatus, computer equipment and readable storage media for sending messages
By detecting and storing messages when the network transmission rate is high, resource scheduling conflicts and network congestion problems are resolved, ensuring that the transmission of important messages is not affected and achieving the stability and effectiveness of message sending.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- UBTECH ROBOTICS CORP LTD
- Filing Date
- 2022-12-30
- Publication Date
- 2026-05-26
AI Technical Summary
In existing technologies, the message sending process is prone to resource scheduling conflicts, which may cause network congestion, especially when the network transmission rate is high, affecting the transmission of important messages.
When the network transmission rate is higher than the preset rate, it checks whether an important message is being received or sent. If so, it checks whether the target message meets the discard condition. If not, it stores the message in the preset storage space and re-evaluates the transmission rate at an appropriate time to send the message.
This avoids the transmission of important messages from being affected by other messages, rationally allocates resources, reduces message loss, and ensures the effectiveness of message delivery.
Smart Images

Figure CN116319562B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data transmission, and more particularly to a method, apparatus, computer device, and readable storage medium for sending messages. Background Technology
[0002] When a computer device needs to send a message, it typically invokes the corresponding network interface immediately to send the message to the appropriate receiver. Understandably, the message sending process usually consumes bandwidth and other resources.
[0003] Therefore, if other applications / processes on the computer device are using bandwidth and other resources, this message sending method is prone to resource scheduling conflicts and may cause network congestion. Summary of the Invention
[0004] In view of this, the present invention provides a message sending method, apparatus, computer device, and readable storage medium to improve the current situation where existing message sending methods are prone to resource scheduling conflicts and may cause network congestion.
[0005] In a first aspect, embodiments of the present invention provide a message sending method applied to a computer device, the method comprising:
[0006] Obtain the target message and determine the current network transmission rate;
[0007] If the current network transmission rate is higher than the preset rate, then it is detected whether an important message receiving or sending operation is in progress at the current moment;
[0008] If an important message is being received or sent at the current moment, then it is checked whether the target message meets the preset discard condition.
[0009] If the target message does not meet the preset discard conditions, the target message is stored in the preset storage space;
[0010] After a preset time interval, return to the step of determining the current network transmission rate until the sending conditions are met, and then execute the sending operation of the target message.
[0011] Optionally, in one feasible embodiment of the present invention, the method further includes:
[0012] If no important message receiving or sending operation is being performed at the current time, then the target message sending operation is executed.
[0013] Optionally, in one feasible embodiment of the present invention, the method further includes:
[0014] If the current network transmission rate is lower than the preset rate, the target message will be stored in the preset storage space.
[0015] Optionally, in one feasible embodiment of the present invention, after storing the target message in a preset storage space if the target message does not meet the preset discard conditions, the method further includes:
[0016] If the target message is being stored in the preset storage space for the first time, then the number of retry attempts for sending the target message is set to one, and the current time is taken as the time for attempting to send the target message.
[0017] If the target message is not being stored in the preset storage space for the first time, then the number of retry attempts is incremented by one, and the sending attempt time of the target message is updated using the current time.
[0018] Optionally, in one feasible embodiment of the present invention, if the target message does not meet the preset discard conditions, the target message is stored in a preset storage space, including:
[0019] When the number of retry attempts reaches a preset threshold, the target message is discarded.
[0020] Optionally, in one feasible embodiment of the present invention, the computer device stores an identifier for each type of important message, and discarding the target message when the number of retry attempts reaches a preset threshold includes:
[0021] When the number of retry attempts is a preset threshold, it is detected whether the identifier of the target message matches the identifier of any of the important messages.
[0022] If the identifier of the target message does not match the identifier of any of the important messages, then the target message is discarded.
[0023] If the identifier of the target message matches the identifier of one of the important messages, the number of retry attempts is incremented by one, and the sending attempt time of the target message is updated using the current time.
[0024] Optionally, in one feasible method provided by an embodiment of the present invention, obtaining the target message includes:
[0025] Retrieve the original message;
[0026] The original message is encoded in binary stream format to obtain the target message.
[0027] Optionally, in one feasible embodiment of the present invention, determining the current network transmission rate includes:
[0028] A connectivity test program is invoked to send a test data packet to a test server, wherein the test server is configured to send corresponding response data to the sender of the test data packet after receiving the test data packet;
[0029] The current network transmission rate is determined based on the time it takes for the test server to send the response data.
[0030] Secondly, embodiments of the present invention provide a message sending apparatus, the apparatus comprising:
[0031] The acquisition module is used to acquire the target message and determine the current network transmission rate;
[0032] The first detection module is used to detect whether an important message receiving or sending operation is in progress at the current moment if the current transmission rate of the network is higher than the preset rate.
[0033] The second detection module is used to detect whether the target message meets the preset discard conditions if an important message receiving or sending operation is in progress at the current time.
[0034] A storage module is used to store the target message in a preset storage space if the target message does not meet the preset discard conditions.
[0035] The sending module is used to return to the step of determining the current network transmission rate after a preset time interval, until the sending conditions are met, and then execute the sending operation of the target message.
[0036] Thirdly, embodiments of the present invention provide a computer device, including a memory and a processor, wherein the memory stores a computer program, and the computer program, when run on the processor, executes a message sending method as disclosed in any of the first aspects.
[0037] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, which, when run on a processor, executes a message sending method as disclosed in any of the first aspects.
[0038] In the message sending method provided by this invention, the computer device first acquires the target message and determines the current network transmission rate. Then, if the current network quality is high, i.e., the current network transmission rate is higher than a preset rate, it checks whether an important message is being received or sent at the current moment. If an important message is being received or sent at the current moment, it checks whether the target message meets a preset discard condition. If the target message does not meet the preset discard condition, the target message is stored in a preset storage space, and after a preset time interval, the process returns to the step of determining the current network transmission rate until the target message is sent. Based on this, this invention ensures that the sending of any message occurs under conditions of good network quality, where sending a message at the current moment will not affect the sending or transmission of important messages. This avoids the negative impact of sending other messages on the sending or transmission of important messages, allowing for reasonable scheduling of message sending resources. Furthermore, it effectively avoids packet loss during message sending, ensuring the effectiveness of message sending. Attached Figure Description
[0039] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope of protection of the present invention. In the various drawings, similar components are numbered similarly.
[0040] Figure 1 A flowchart illustrating a first message sending method provided by an embodiment of the present invention is shown;
[0041] Figure 2 A flowchart illustrating a second message sending method provided in an embodiment of the present invention is shown;
[0042] Figure 3 A flowchart illustrating a third message sending method provided in an embodiment of the present invention is shown;
[0043] Figure 4 A schematic diagram of the structure of a message sending device provided in an embodiment of the present invention is shown. Detailed Implementation
[0044] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0045] The components of the embodiments of the invention described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0046] In the following, the terms “comprising,” “having,” and their cognates, which may be used in various embodiments of the invention, are intended only to indicate a particular feature, number, step, operation, element, component, or combination thereof, and should not be construed as excluding, firstly, the presence of one or more other features, numbers, steps, operations, elements, components, or combinations thereof, or adding the possibility of one or more features, numbers, steps, operations, elements, components, or combinations thereof.
[0047] Furthermore, the terms "first," "second," and "third" are used only to distinguish descriptions and should not be interpreted as indicating or implying relative importance.
[0048] Unless otherwise specified, all terms used herein (including technical and scientific terms) shall have the same meaning as commonly understood by one of ordinary skill in the art to which the various embodiments of the invention pertain. Terms (such as those defined in commonly used dictionaries) shall be interpreted as having the same meaning as in their contextual meaning in the relevant technical field and shall not be interpreted as having an idealized or overly formal meaning, unless clearly defined in the various embodiments of the invention.
[0049] Example 1
[0050] Reference Figure 1 This diagram illustrates a flowchart of a first message sending method provided by an embodiment of the present invention. The message sending method provided by the present invention is applied to a computer device, and the method includes:
[0051] Step S110: Obtain the target message and determine the current network transmission rate.
[0052] It should be understood that, in the embodiments of the present invention, the target message refers to the message data to be sent / to be sent.
[0053] It is conceivable that the method of obtaining the target message can be set according to the actual situation. For example, in a feasible method provided by an embodiment of the present invention, the aforementioned target message acquisition process is as follows: when a message sending request is triggered by any functional module, the computer device calls the corresponding resources to parse the message sending request, and then obtains the target message in the message sending request.
[0054] Optionally, to improve the transmission efficiency of the target message, in one feasible method provided by this embodiment of the invention, obtaining the target message in step S110 above includes:
[0055] Retrieve the original message;
[0056] The original message is encoded in binary stream format to obtain the target message.
[0057] In other words, after receiving a message to be sent, the computer device in this embodiment converts the message into a binary stream format. Specifically, it iterates through each member of the message, converts each member into bytes, and then sets it as the corresponding stream file. Therefore, when this message needs to be sent subsequently, it will be transmitted / sent in binary stream format.
[0058] It should also be understood that the current network transmission rate in this embodiment of the invention refers to the amount of data transmitted per unit time when the computer device communicates with other devices at the current moment. A higher current network transmission rate indicates better communication quality at the current moment. Conversely, a lower current network transmission rate indicates lower communication quality at the current moment, with a risk of packet loss.
[0059] Optionally, in one feasible embodiment of the present invention, determining the current network transmission rate in step S110 includes:
[0060] A connectivity test program is invoked to send a test data packet to a test server, wherein the test server is configured to send corresponding response data to the sender of the test data packet after receiving the test data packet;
[0061] The current network transmission rate is determined based on the time it takes for the test server to send the response data.
[0062] It should be noted that after the connectivity test program (Packet Internet Groper) is invoked, it will send the corresponding data packets to the specified test terminal. After receiving the data packets, the test terminal will send back the corresponding response data to the sender of the data packets. In this way, the sender of the data packets (that is, the receiver of the response data) can know whether it can communicate with the outside world.
[0063] Furthermore, after receiving the response data, the computer device will calculate the current network transmission rate based on the reception time of the response data, the time it sent the data packet, and the size of the data packet.
[0064] Step S120: If the current network transmission rate is higher than the preset rate, then detect whether an important message receiving or sending operation is in progress at the current moment.
[0065] It is understandable that if the network communication quality is poor, packet loss of the target message is highly likely to occur during the transmission process. Therefore, the computer device in this embodiment of the invention will only send messages when the current network transmission rate is higher than a preset rate, that is, when the network communication quality is good.
[0066] It's also understandable that sending the target message at the current moment will inevitably consume some bandwidth or other resources. Therefore, if the computer device is currently sending or receiving other data / messages, sending the target message will negatively impact the messages being sent / received. Furthermore, if the target message is large, it will consume significant bandwidth resources, further affecting the messages being sent / received.
[0067] Furthermore, if the message being sent / received is important, such as involving financial transaction data or identity authentication data, then the sending / receiving process should be kept as undisturbed as possible. However, if the message being sent / received is relatively ordinary, such as promotional information, then the sending / receiving process should be allowed to be interrupted.
[0068] Furthermore, it is understood that the method / rules for identifying important and unimportant messages can be set according to the actual situation. For example, in one feasible method provided by the embodiment of the present invention, the computer device stores an identifier (i.e., ID) for each type of important message, and the embodiment of the present invention determines whether a message is an important message by the identifier of the message.
[0069] In another feasible embodiment of the present invention, messages from the currently used application are considered important messages. For example, suppose a user opens a social media application and a financial product application sequentially on a terminal / computer device. At the current moment, when the user is browsing the page displayed by the social media application (i.e., the social media application is active), while the financial product application is suspended or running in the background, the interaction messages between the terminal and the server corresponding to the social media application are considered important messages, while the interaction messages between the terminal and the server corresponding to the financial product application are considered unimportant messages.
[0070] Step S130: If an important message receiving or sending operation is in progress at the current moment, then detect whether the target message meets the preset discard condition.
[0071] That is, in this embodiment of the invention, it is also necessary to determine whether the target message needs to be sent to its corresponding receiving end, that is, to determine whether the target message meets the preset discard conditions.
[0072] It should be understood that, in this embodiment of the invention, if the target message meets the preset discard condition, it means that it is a case where not sending the message to its corresponding receiving end at the current moment has little impact. Therefore, the computer device will skip the subsequent operations of the target message when the preset discard condition is met.
[0073] Furthermore, it is conceivable that if an important message is being received or sent at the current moment, it indicates that the network communication quality is good at the current moment, and the message transmission will not cause significant impact. Therefore, in one feasible method provided in this embodiment of the invention, please refer to... Figure 2 The diagram illustrates a second feasible method provided by an embodiment of the present invention, wherein in this feasible method, the method further includes:
[0074] S160, if no important message receiving or sending operation is being performed at the current time, then the target message sending operation is executed.
[0075] In other words, in this embodiment of the invention, the target message will be sent to the corresponding receiving end when the network quality is good (i.e., the current network transmission rate is higher than the preset rate) and the sending of the target message will not affect the communication of important messages (i.e., there are no other important messages being sent or received at the current time).
[0076] This ensures that the target message will not affect the transmission of important messages within the computer device, and that the computer device can complete the message transmission reasonably. Furthermore, because the network quality is good at the current time, the sending process of the target message can proceed stably, thereby reducing the probability of packet loss of the target message.
[0077] Step S140: If the target message does not meet the preset discard conditions, then the target message is stored in the preset storage space.
[0078] That is, in order to avoid the sending of the target message from affecting important messages being sent or received at the current moment, the computer device in this embodiment of the invention caches the target message in a preset storage space so as to send the target message in the preset storage space at an appropriate time.
[0079] Optionally, in one feasible embodiment of the present invention, the computer device is equipped with database software, and therefore, the storage of the target message will be completed based on the database software.
[0080] Step S150: After a preset time interval, return to the step of determining the current network transmission rate until the sending conditions are met, and then execute the sending operation of the target message.
[0081] That is, after storing the target message in the preset storage space, the computer device in this embodiment of the invention will determine again after a preset time interval whether the target message can be sent at the current moment. That is, it will determine whether the network transmission rate at the current moment is higher than the preset rate, whether important messages are being received or sent at the current moment, and whether the discard condition is met.
[0082] If the conditions are not met at the current moment, the computer device will store the target message again in the preset storage space. In one feasible approach, to reduce data redundancy in the preset storage space, if the target message already exists in the preset storage space, the computer device will skip the step of storing the target message and directly perform a new round of judgment when the next preset time interval arrives.
[0083] If the conditions are met at the current moment, the target message stored in the preset storage space is read and sent to the corresponding receiving end.
[0084] Optionally, to reduce information redundancy in the preset storage space and avoid computer devices repeatedly reading target messages that have already been sent from the preset storage space, in one feasible embodiment of the present invention, the method further includes:
[0085] Delete the target message from the preset storage space.
[0086] Therefore, after the target message is sent to the corresponding receiving end, the relevant content of the target message in the preset storage space has been cleared, so the computer device cannot read the target message in the preset storage space again, thus avoiding the situation where the target message is sent repeatedly.
[0087] Based on this, the embodiments of the present invention ensure that the sending of any message is carried out under conditions of good network quality and where sending a message at this time will not affect the sending or transmission of important messages. This avoids the negative impact of sending other messages on the sending or transmission of important messages, and allows for the reasonable scheduling of resources related to message sending. Furthermore, it effectively avoids packet loss during the message sending process, ensuring the effectiveness of message sending.
[0088] Optionally, in one feasible embodiment of the present invention, the method further includes:
[0089] If the current network transmission rate is lower than the preset rate, the target message is stored in the preset storage space.
[0090] That is, when the network communication quality is poor, the embodiments of the present invention will no longer perform the judgment on whether there is an important message being received or sent at the current moment, and will directly store the target message in the preset storage space.
[0091] Therefore, based on this feasible method, the embodiments of the present invention eliminate the need for computer devices to perform network current transmission rate related judgments and important message related judgments every time they obtain target messages, thereby reducing the operating load of computer devices.
[0092] Optionally, to reduce data redundancy in the preset storage space, in one feasible method provided in this embodiment of the invention, please refer to... Figure 3 The diagram illustrates a flowchart of a second message sending method provided by an embodiment of the present invention. In this feasible mode, after step S140, the method further includes:
[0093] S170, if the target message is being stored in the preset storage space for the first time, then the number of retry attempts for sending the target message is set to one, and the current time is taken as the time for attempting to send the target message;
[0094] S180, if the target message is not being stored in the preset storage space for the first time, then the number of retry attempts is incremented by one, and the sending attempt time of the target message is updated using the current time.
[0095] In other words, the computer device in this embodiment of the invention stores the target message only once. That is, when the target message cannot be sent for the first time due to poor network communication quality, or because important messages are being received or sent at the current moment, the target message is stored in the preset storage space. At the same time, the number of retry attempts for sending this target message is set to one, indicating that the target message has undergone one round of sending detection / judgment, and the current time is recorded as the sending attempt time of the target message. Then, the computer device will perform a new round of sending detection after a preset time interval of the sending attempt time.
[0096] If the target message fails to be sent again due to poor network communication quality or because important messages are being received or sent at the current moment, the computer device will simply increment the retry count of the target message to indicate that another sending detection / judgment has been performed, and update the sending attempt time using the current moment, so as to ensure that the target message can be correctly detected and sent in a new round.
[0097] Optionally, to avoid the target message consuming excessive resources for transmission detection, in one feasible approach, if the number of retries for sending the target message reaches the upper limit, the target message is discarded, and subsequent judgment / detection logic is not executed in this transmission detection. That is, the method further includes:
[0098] When the number of retry attempts for sending the target message reaches a preset threshold, the target message is discarded.
[0099] Understandably, if the discard action is performed, the sending attempt time and the number of retry attempts for the target message will not be updated, in order to reduce the resources consumed by the computer equipment.
[0100] Optionally, in one feasible embodiment of the present invention, the computer device stores an identifier for each type of important message, and discarding the target message when the number of retry attempts reaches a preset threshold includes:
[0101] When the number of retry attempts is a preset threshold, it is detected whether the identifier of the target message matches the identifier of any of the important messages.
[0102] If the identifier of the target message does not match the identifier of any of the important messages, then the target message is discarded.
[0103] If the identifier of the target message matches the identifier of one of the important messages, the number of retry attempts is incremented by one, and the sending attempt time of the target message is updated using the current time.
[0104] In other words, the computer device in this embodiment of the invention will determine whether the target message is an important message based on the pre-stored identifier of each important message. If the target message is not an important message, it means that discarding / deleting the target message will not have a serious negative impact on the operation of the computer device. Therefore, this embodiment of the invention will perform the discard operation normally when the number of retries reaches a preset threshold.
[0105] It is understood that if the identifier of the target message matches the identifier of an important message, that is, when the target message is an important message, the computer device in this embodiment of the invention will update its sending attempt time and sending retry count accordingly when the number of sending retries reaches a preset threshold.
[0106] This prevents the deletion of the target message. Therefore, it ensures that important messages are always sent to the appropriate receiver.
[0107] Example 2
[0108] Corresponding to the message sending method provided in Embodiment 1 of the present invention, Embodiment 2 of the present invention also provides a message sending device, referring to... Figure 4 The diagram illustrates a structural schematic of a message sending apparatus provided in an embodiment of the present invention. The message sending apparatus 200 provided in this embodiment of the present invention is applied to a computer device, and the apparatus includes:
[0109] The acquisition module 210 is used to acquire the target message and determine the current network transmission rate;
[0110] The first detection module 220 is used to detect whether an important message receiving or sending operation is in progress at the current moment if the current transmission rate of the network is higher than the preset rate.
[0111] The second detection module 230 is used to detect whether the target message meets the preset discard condition if an important message receiving or sending operation is in progress at the current time.
[0112] The first storage module 240 is used to store the target message in a preset storage space if the target message does not meet the preset discard conditions.
[0113] The first sending module 250 is used to return to the step of determining the current network transmission rate after a preset time interval, until the sending conditions are met, and then execute the sending operation of the target message.
[0114] Optionally, in one feasible embodiment of the present invention, the apparatus further includes:
[0115] The second sending module is used to execute the sending operation of the target message if no receiving or sending operation of the important message is being performed at the current time.
[0116] Optionally, in one feasible embodiment of the present invention, the apparatus further includes:
[0117] The second storage module is used to store the target message in the preset storage space if the current network transmission rate is lower than the preset rate.
[0118] Optionally, in one feasible embodiment of the present invention, the apparatus further includes:
[0119] The setting module is used to set the number of retry attempts for sending the target message to one if the target message is being stored in the preset storage space for the first time, and to use the current time as the time for attempting to send the target message.
[0120] The update module is used to increment the number of retry attempts by one and update the sending attempt time of the target message using the current time if the target message is not being stored in the preset storage space for the first time.
[0121] Optionally, in one feasible embodiment of the present invention, the apparatus further includes:
[0122] The discard module is used to discard the target message when the number of retry attempts reaches a preset threshold.
[0123] Optionally, in one feasible embodiment of the present invention, the computer device stores an identifier for each type of important message, and the discard module includes:
[0124] The matching detection submodule is used to detect whether the identifier of the target message matches the identifier of any of the important messages when the number of retry attempts is a preset threshold.
[0125] The message discarding submodule is used to discard the target message if the identifier of the target message does not match the identifier of any of the important messages.
[0126] The message update submodule is used to increment the number of retry attempts by one and update the sending attempt time of the target message using the current time if the identifier of the target message matches the identifier of an important message.
[0127] Optionally, in one feasible embodiment of the present invention, the acquisition module includes:
[0128] The raw message retrieval submodule is used to retrieve raw messages;
[0129] The encoding submodule is used to encode the original message in binary stream format to obtain the target message.
[0130] Optionally, in one feasible embodiment of the present invention, the acquisition module includes:
[0131] The calling submodule is used to call the connectivity test program to send test data packets to the test server, wherein the test server is used to send corresponding response data to the sender of the test data packets after receiving the test data packets;
[0132] The rate determination submodule is used to determine the current network transmission rate based on the time it takes for the test server to send the response data.
[0133] Optionally, in one feasible embodiment of the present invention, the apparatus further includes:
[0134] The deletion module is used to delete the target message from the preset storage space.
[0135] The message sending device 200 provided in this application embodiment can implement each process of the message sending method corresponding to Embodiment 1 and achieve the same technical effect. To avoid repetition, it will not be described again here.
[0136] This invention also provides a computer device, including a memory and a processor. The memory stores a computer program, and the computer program executes the message sending method as described in Embodiment 1 when it runs on the processor.
[0137] This invention also provides a computer-readable storage medium storing a computer program, which, when run on a processor, executes the message sending method as described in Embodiment 1.
[0138] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that, as an alternative implementation, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0139] In addition, the functional modules or units in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0140] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a smartphone, personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0141] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for sending a message, characterized in that, Applied to a computer device, the method includes: Obtain the target message and determine the current network transmission rate, whereby the current network transmission rate refers to the amount of data transmitted per unit time when the computer device communicates with other devices at the current moment. If the current network transmission rate is higher than the preset rate, then it is detected whether an important message receiving or sending operation is in progress at the current moment; If an important message receiving or sending operation is in progress at the current moment, then it is detected whether the target message meets the preset discard condition; If the target message does not meet the preset discard conditions, the target message is stored in the preset storage space; After a preset time interval, return to the step of determining the current network transmission rate until the sending conditions are met, and then execute the sending operation of the target message. If the target message does not meet the preset discard condition, the method further includes storing the target message in the preset storage space. If the target message is being stored in the preset storage space for the first time, the number of retry attempts for sending the target message is set to one, and the current time is used as the sending attempt time of the target message. If the target message is not being stored in the preset storage space for the first time, the number of retry attempts is incremented by one, and the sending attempt time of the target message is updated using the current time. The method further includes: discarding the target message when the number of retry attempts is a preset threshold number; The computer device stores an identifier for each type of important message. The step of discarding the target message when the number of retry attempts is a preset threshold includes: when the number of retry attempts is a preset threshold, detecting whether the identifier of the target message matches the identifier of any of the important messages; if the identifier of the target message does not match the identifier of any of the important messages, then discarding the target message. If the identifier of the target message matches the identifier of one of the important messages, the number of retry attempts is incremented by one, and the sending attempt time of the target message is updated using the current time.
2. The message sending method according to claim 1, characterized in that, The method further includes: If no important message receiving or sending operation is being performed at the current time, then the target message sending operation is executed.
3. The message sending method according to claim 1, characterized in that, The method further includes: If the current network transmission rate is lower than the preset rate, the target message will be stored in the preset storage space.
4. The message sending method according to claim 1, characterized in that, The acquisition of the target message includes: Retrieve the original message; The original message is encoded in binary stream format to obtain the target message.
5. The message sending method according to claim 1, characterized in that, Determining the current network transmission rate includes: A connectivity test program is invoked to send a test data packet to a test server, wherein the test server is configured to send corresponding response data to the sender of the test data packet after receiving the test data packet; The current network transmission rate is determined based on the time it takes for the test server to send the response data.
6. The message sending method according to claim 1, characterized in that, After performing the sending operation of the target message, the method further includes: Delete the target message from the preset storage space.
7. A message sending device, characterized in that, The device includes: The acquisition module is used to acquire the target message and determine the current network transmission rate, which refers to the amount of data transmitted per unit time when the computer device communicates with other devices at the current moment. The first detection module is used to detect whether an important message receiving or sending operation is in progress at the current moment if the current transmission rate of the network is higher than the preset rate. The second detection module is used to detect whether the target message meets the preset discard conditions if an important message receiving or sending operation is in progress at the current time. A storage module is used to store the target message in a preset storage space if the target message does not meet the preset discard conditions. The sending module is used to return to the step of determining the current network transmission rate after a preset time interval, until the sending conditions are met, and then execute the sending operation of the target message. The setting module is used to set the number of retry attempts for sending the target message to one if the target message is being stored in the preset storage space for the first time, and to use the current time as the time for attempting to send the target message. The update module is used to increment the number of retry attempts by one if the target message is not being stored in the preset storage space for the first time, and to update the sending attempt time of the target message using the current time. The discard module is used to discard the target message when the number of retry attempts reaches a preset threshold. The computer device stores an identifier for each type of important message, and the discard module includes: The matching detection submodule is used to detect whether the identifier of the target message matches the identifier of any of the important messages when the number of retry attempts is a preset threshold. The message discarding submodule is used to discard the target message if the identifier of the target message does not match the identifier of any of the important messages. The message update submodule is used to increment the number of retry attempts by one and update the sending attempt time of the target message using the current time if the identifier of the target message matches the identifier of an important message.
8. A computer device, characterized in that, It includes a memory and a processor, the memory storing a computer program that, when executed on the processor, performs the message sending method as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed on a processor, performs the message sending method as described in any one of claims 1-6.