CN114301860A - Message sending method, device, equipment and storage medium - Google Patents

Message sending method, device, equipment and storage medium Download PDF

Info

Publication number
CN114301860A
CN114301860A CN202111566547.4A CN202111566547A CN114301860A CN 114301860 A CN114301860 A CN 114301860A CN 202111566547 A CN202111566547 A CN 202111566547A CN 114301860 A CN114301860 A CN 114301860A
Authority
CN
China
Prior art keywords
message
state
data
sending
database
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202111566547.4A
Other languages
Chinese (zh)
Other versions
CN114301860B (en
Inventor
孙阳
田阳
孟红梅
杨磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202111566547.4A priority Critical patent/CN114301860B/en
Publication of CN114301860A publication Critical patent/CN114301860A/en
Application granted granted Critical
Publication of CN114301860B publication Critical patent/CN114301860B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Transfer Between Computers (AREA)

Abstract

The disclosure relates to a message sending method, a device, equipment and a storage medium, the method firstly obtains message data to be sent; then storing the message data into a database, and sending the message data to a communication server in the process of storing the message data into the database; and when a response result of the communication service end to the message data is received, updating the state of the message data in the database according to the response result so as to finish the sending process of the message data. It can be seen that, in the message sending method provided by the embodiment of the present disclosure, the message preparation stage and the network transmission stage are performed simultaneously, so that the time consumption of the message sending process is the sum of the larger time consumption in the message preparation stage and the network transmission stage and the time consumption in the sending result confirmation stage, thereby shortening the time consumption of the message sending process, and the shortened time duration is the smaller time consumption in the message preparation stage and the network transmission stage.

Description

Message sending method, device, equipment and storage medium
Technical Field
The present disclosure relates to the field of instant messaging technologies, and in particular, to a message sending method, device, apparatus, and storage medium.
Background
Instant Messaging (IM) is a popular way of communicating. Based on various instant communication software, users can use the network to transmit characters, files, voice, video and the like in real time.
The time consumption of the message sending process, namely the speed of the message reaching the opposite-end user, is an important index for measuring the IM quality, and the speed of the message reaching the opposite-end user, which can be sensed by the user, can directly influence the use experience of the user on the communication software. Therefore, how to shorten the time consumption of the message sending process is an urgent technical problem to be solved.
Disclosure of Invention
The present disclosure provides a message sending method, device, equipment and storage medium, to at least solve the problem of how to shorten the time consumption of the message sending process. The technical scheme of the disclosure is as follows:
according to a first aspect of the embodiments of the present disclosure, a message sending method is provided, including: acquiring message data to be sent; storing the message data into a database, and sending the message data to the communication server in the process of storing the message data into the database; and when a response result of the communication service end to the message data is received, updating the state of the message data in the database according to the response result so as to finish the sending process of the message data.
In the related art, the message sending process is divided into three stages, namely a message preparation stage, a network transmission stage and a sending result confirmation stage. In order to optimize the time consumption of the message sending process, the message preparation stage and the network transmission stage are performed simultaneously in the embodiment of the disclosure, that is: and storing the message data into a database, and sending the message data to the communication service terminal in the process of storing the message data into the database. Thus, the time consumption of the message sending process is the sum of the larger time consumption in the message preparation stage and the network transmission stage and the time consumption in the sending result confirmation stage. Therefore, the time consumption of the message sending process is shortened, and the shortened time is the smaller time consumption in the message preparation stage and the network transmission stage. In addition, according to the embodiment of the present disclosure, after the status of the message data in the database is updated according to the response result of the server, the message sending process is considered to be completed, that is, after the sending result confirmation stage is completed, the message sending completion information is conveyed to the user, so that the time consumption of the message sending process is reduced, and the problem of inconsistent data of the sending end and the receiving end is avoided.
With reference to the first aspect, in a possible implementation manner of the first aspect, the sending the message data to the communication server in the process of executing the storing of the message data in the database includes: if the type of the message data is a preset type, the message data is sent to the communication service end in the process of storing the message data into a database, wherein the preset type comprises at least one of a character type and an expression type; or if the data volume of the message data is smaller than the preset data volume, the message data is sent to the communication server in the process of storing the message data into the database.
In the above implementation manner, it is considered that different types of message data are different in size, for example, the basic types of message data such as characters and expressions are smaller in size, and the non-basic types of message data such as multimedia resources or files in various formats are larger in size. Thus, in practice, the time consumption for sending the basic type of message data is small, while the data for sending the non-basic type of message is large, and in a specific implementation, the logic used for sending the basic type of message data is different from the logic used for sending the non-basic type of message data. Based on the above consideration, in the embodiment of the present disclosure, for message data of a preset type or message data with a small data volume, a manner of "sending the message data to the communication server in the process of storing the message data in the database" is adopted to shorten the time consumption of the sending process, and when the sending process is specifically implemented, the sending logic corresponding to the message data is configured; for the message data of the non-preset type or the message data with a large data volume, because the network transmission time for sending the message data is long, the mode of sending the message data to the communication service terminal in the process of storing the message data in the database is adopted, the shortened time consumption is negligible and even cannot be perceived by the user, and because the sending logic adopted by the message data is different from the sending logic of the message of the preset type, the logic cannot be multiplexed, so that the embodiment of the disclosure adopts the existing sending logic for the message data of the non-preset type, namely, after the message data is stored in the database, the message data is sent to the communication service terminal without additional configuration, thereby reducing the development cost.
With reference to the first aspect, in a possible implementation manner of the first aspect, the sending the message data to the communication server in the process of executing the storing of the message data in the database includes: if the message data comprise the multimedia data, uploading the multimedia data to a file server, and acquiring a storage address of the multimedia data returned by the file server; generating a message body according to the storage address of the multimedia data; if the message data does not comprise the multimedia data, generating a message body according to the message data; and in the process of storing the message body in a database, sending the message body to the communication server.
In the implementation manner, when the message data to be sent contains multimedia data, the multimedia data is uploaded to the file server to obtain the storage address of the multimedia data, and then the message body is generated according to the storage address instead of directly generating the message body according to the multimedia data, so that the data volume for sending the message is reduced, and the time consumption of network transmission is reduced.
With reference to the first aspect, in a possible implementation manner of the first aspect, the sending the message body to the communication server in the process of storing the message body in the database includes: storing the message body into the database, and marking the state of the message body as a first state, wherein the first state is used for representing that the message body is in a state before being sent; modifying the message body marked as the first state from the first state to a second state, wherein the second state is used for representing the state that the message body is in sending; and sending the message body to the communication service terminal in the process of storing the message body into the database, marking the state of the message body as a first state or modifying the state of the message body from the first state to a second state.
As can be seen from the first aspect, the operation of storing the message data is performed in parallel with the operation of sending the message to the server. This means that when the message data is stored, the actual state of the message data is the "sending state", so in theory, the message body can be marked directly as the second state when it is stored in the database. However, in order to avoid that the request transmission fails for some reasons (such as network and hardware), but the message body is marked as "transmitting state" so that the state of the data in the database is inconsistent with the actual state of the data, the embodiment of the present disclosure stores the message body in the database, and marks the state of the message body as the first state (i.e., initial state) and immediately updates the state to the second state (i.e., transmitting state), thereby ensuring the security and stability of the data storage operation.
With reference to the first aspect, in a possible implementation manner of the first aspect, sending the message body to the communication server in a process of storing the message body in a database includes: storing the message body into the database, and marking the state of the message body as a second state, wherein the second state is used for representing the state of the message body in sending; and in the process of storing the message body into the database and marking the state of the message body as the second state, sending the message body to the communication service terminal.
As can be seen from the first aspect, the operation of storing the message data is performed in parallel with the operation of sending the message to the server. This means that, when storing the message data, the actual state of the message data is the "sending state", so in this implementation, when the message body is stored in the database, the message body is directly marked as the second state (i.e., sending state), which simplifies the storage operation and reduces the time consumption of the data storage process.
With reference to the first aspect, in a possible implementation manner of the first aspect, the storing the message data in a database includes: when the message data comprises the multimedia data, storing the multimedia data in the database in the process of uploading the multimedia data to the file server, and marking the state of the multimedia data as a first state, wherein the first state is used for representing the state of the multimedia data before being sent; and in the process of sending the message body to the communication server, modifying the multimedia data marked as the first state in the database from the first state to a second state, wherein the second state is used for representing the state of the message body in sending.
In the implementation mode, when the message data is multimedia data and the multimedia data is uploaded, the multimedia data is stored in the database, the state of the multimedia data is marked as a first state, the multimedia data stored in the database is updated to a second state while a request is sent to the server, and a message body generated according to a storage address is stored without waiting for obtaining the storage address of the multimedia data, so that time consumption is saved.
With reference to the first aspect, in a possible implementation manner of the first aspect, the updating the state of the message data in the database according to the response result includes: if the response result represents that the message is successfully sent, updating the state of the message data in the database to a third state, wherein the third state is used for representing that the message data is in a state of successful sending; and if the response result represents that the message is failed to be sent, updating the state of the message data in the database to a fourth state, wherein the fourth state is used for representing that the message data is in a state of failure to be sent.
In the implementation manner of the present disclosure, in the case of successful message transmission, the message status of the data in the database is updated to the third status (i.e., transmission successful status), and in the case of failed message transmission, the status of the message data of the data in the database is updated to the fourth status (i.e., transmission failed status). Therefore, the consistency of the message record data at both sides of the sending end and the receiving end can be ensured.
According to a second aspect of the embodiments of the present disclosure, there is provided a message transmitting apparatus including: the data acquisition module is used for acquiring message data to be sent; the parallel execution module is used for storing the message data into a database and sending the message data to the communication server in the process of storing the message data into the database; and the sending result confirmation module is used for updating the state of the message data in the database according to the response result when receiving the response result of the communication service end to the message data so as to finish the sending process of the message data.
With reference to the second aspect, in a possible implementation manner of the second aspect, the parallel execution module is specifically configured to: if the type of the message data is a preset type, the message data is sent to the communication service end in the process of storing the message data into a database, wherein the preset type comprises at least one of a character type and an expression type; or if the data volume of the message data is smaller than the preset data volume, the message data is sent to the communication server in the process of storing the message data into the database.
With reference to the second aspect, in a possible implementation manner of the second aspect, the parallel execution module is specifically configured to: if the message data comprise the multimedia data, uploading the multimedia data to a file server, and acquiring a storage address of the multimedia data returned by the file server; generating a message body according to the storage address of the multimedia data; if the message data does not comprise the multimedia data, generating a message body according to the message data; and in the process of storing the message body in a database, sending the message body to the communication server.
With reference to the second aspect, in a possible implementation manner of the second aspect, the parallel execution module is specifically configured to: storing the message body into the database, and marking the state of the message body as a first state, wherein the first state is used for representing that the message body is in a state before being sent; modifying the message body marked as the first state from the first state to a second state, wherein the second state is used for representing the state that the message body is in sending; and sending the message body to the communication service terminal in the process of storing the message body into the database, marking the state of the message body as a first state or modifying the state of the message body from the first state to a second state.
With reference to the second aspect, in a possible implementation manner of the second aspect, the parallel execution module is specifically configured to: storing the message body into the database, and marking the state of the message body as a second state, wherein the second state is used for representing the state of the message body in sending; and in the process of storing the message body into the database and marking the state of the message body as a second state, sending the message body to the communication service terminal.
With reference to the second aspect, in a possible implementation manner of the second aspect, the parallel execution module is specifically configured to: when the message data comprises the multimedia data, in the process of uploading the multimedia data to the file server by the request generation module, storing the multimedia data to the database, and marking the state of the multimedia data as a first state, wherein the first state is used for representing the state of the multimedia data before being sent; and in the process of sending the message body to the communication server, modifying the multimedia data marked as the first state in the database from the first state to a second state, wherein the second state is used for representing the state of the message body in sending.
With reference to the second aspect, in a possible implementation manner of the second aspect, the sending result confirmation module is specifically configured to: if the response result represents that the message is successfully sent, updating the state of the message data in the database to a third state, wherein the third state is used for representing that the message data is in a state of successful sending; and if the response result represents that the message is failed to be sent, updating the state of the message data in the database to a fourth state, wherein the third state is used for representing that the message data is in a state of successful sending.
According to a third aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including: a processor and a memory for storing processor-executable instructions; wherein the processor is configured to execute the executable instructions to implement the method as described in the first aspect and any implementation thereof.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium, wherein instructions, when executed by a processor of an electronic device, enable the electronic device to perform the method as described in the first aspect and any implementation thereof.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer program product comprising computer instructions which, when run on an electronic device, cause the electronic device to perform the method as set forth in the first aspect and any implementation thereof.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:
the embodiment of the disclosure provides a message sending method, a device, equipment and a storage medium, wherein the method comprises the steps of firstly obtaining message data to be sent; then storing the message data into a database, and sending the message data to a communication server in the process of storing the message data into the database; and when a response result of the communication service end to the message data is received, updating the state of the message data in the database according to the response result so as to finish the sending process of the message data. It can be seen that, in the message sending method provided by the embodiment of the present disclosure, the message preparation stage and the network transmission stage are performed simultaneously, so that the time consumption of the message sending process is the sum of the larger time consumption in the message preparation stage and the network transmission stage and the time consumption in the sending result confirmation stage, thereby shortening the time consumption of the message sending process, and the shortened time duration is the smaller time consumption in the message preparation stage and the network transmission stage.
In addition, according to the embodiment of the present disclosure, after the status of the message data in the database is updated according to the response result of the server, the message sending process is considered to be completed, that is, after the sending result confirmation stage is completed, the message sending completion information is conveyed to the user, so that the time consumption of the message sending process is reduced, and the problem of inconsistent data of the sending end and the receiving end is avoided.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.
FIG. 1 is a schematic diagram of a communication system according to an exemplary embodiment;
FIG. 2 is a flow diagram illustrating a method of messaging according to an example embodiment;
FIG. 3 is a diagram illustrating a messaging process consuming time in accordance with an exemplary embodiment;
FIG. 4 is a schematic diagram illustrating another messaging process consuming time in accordance with an illustrative embodiment;
FIG. 5 is a block diagram illustrating a messaging device in accordance with an exemplary embodiment;
FIG. 6 is a schematic diagram of an electronic device shown in accordance with an exemplary embodiment.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
In addition, in the description of the embodiments of the present disclosure, "/" indicates an OR meaning, for example, A/B may indicate A or B, unless otherwise specified. "and/or" herein is merely an association describing an associated object, and means that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of the present disclosure, "a plurality" means two or more.
In the related art, the message sending process is divided into three stages, namely a message preparation stage, a network transmission stage and a sending result confirmation stage. When the three stages are executed in sequence, the message sending process is considered to be completed. Further, the time consumed by the message sending process is the time consumed by the three stages.
In order to optimize time consumption of a message sending process, an embodiment of the present disclosure provides a message sending method, where a message preparation phase and a network transmission phase are performed simultaneously, that is: and storing the message data into a database, and sending the message data to the communication server in the process of storing the message data into the database. This is achieved bySimilarly, the time consumption of the message sending process is the sum of the larger time consumption of the message preparation stage and the network transmission stage and the time consumption of the sending result confirmation stage, i.e. TGeneral assembly=Max{TMessage preparation phase,TNetwork transmission phase}+TTransmission result confirmation phaseTherefore, the time consumption of the message sending process is shortened, the shortened time is the smaller time consumption in the message preparation stage and the network transmission stage, namely, the time delta T is Min { T {Message preparation phase,TNetwork transmission phase}。
The message sending method provided by the embodiment of the disclosure can be applied to a communication system. Fig. 1 is a schematic diagram of a communication system according to an embodiment of the disclosure, as shown in fig. 1, the communication system may include: a first device 110, a messaging server 120, and a second device 130. Wherein, the first device 110 and the second device 130 can establish a communication connection with the communication server 120.
In the above communication system, the communication server 120 is used for providing services, such as an instant messaging service, for the first device 110 and the second device 130. Messages may be communicated between the first device 110 and the second device 130 via the messaging server 120. It should be understood that, during the communication between the first device 110 and the second device 130, the first device 110 may serve as a message sender to send message data to the communication server 120 to request the communication server 120 to send the message data to the second device 130 serving as a message receiver, and the second device 130 may also serve as a message sender to send message data to the communication server 120 to request the communication server 120 to send the message data to the first device 110 serving as a message receiver.
In the embodiment of the present disclosure, the first device 110 or the second device 130 is configured to transmit message data to the second device 130 or the first device 110 by performing the message transmission method provided by the embodiment of the present disclosure. For example, obtaining message data to be sent; storing the message data in a database, and, in the process of storing the message data in the database, transmitting the message data to the communication server 120 to transmit the message data to the receiving end device through the communication server 120; when a response result of the messaging server 120 to the message is received, the state of the message data in the database is updated according to the response result, so as to complete the sending process of the message data. The communication server 120 may also be referred to as a communication server.
In some embodiments, the first device 110 and the second device 130 may be terminal devices, such as a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a Personal Digital Assistant (PDA), an Augmented Reality (AR) Virtual Reality (VR) device, and the like, which can install and use an instant messaging application (e.g., a fast hand), and the present disclosure does not particularly limit the specific form of the terminal. The system can be used for man-machine interaction with a user through one or more modes of a keyboard, a touch pad, a touch screen, a remote controller, voice interaction or handwriting equipment and the like.
In some embodiments, the first device 110 and the second device 130 may also be a message sending apparatus provided in the embodiments of the present disclosure, and the message sending apparatus is configured to execute the message sending method provided in the embodiments of the present disclosure. Alternatively, the first device 110 and the second device 130 may also have message side apparatuses provided by the embodiments of the present disclosure built therein. The present disclosure does not limit the specific implementation of the first device 110 and the second device 130.
The communication server 120 may be a single server, or may be a server cluster including a plurality of servers. In some embodiments, the server cluster may also be a distributed cluster.
In some embodiments, the first device 110 and the second device 130 may also be electronic devices.
It will be readily appreciated that the device that is the sender of the message may be integrated with the messenger server 120 in the same device. When the device as the message sender and the communication server 120 are integrated in the same device, the communication mode between the message sender and the communication server 120 is communication between internal modules of the device. In this case, the communication procedure between the two is the same as that in the case where the two are independent of each other.
The following describes a message sending method according to an embodiment of the present disclosure in detail with reference to the communication system shown in fig. 1. The message transmission method may be applied to the first device 110 and the second device 130 shown in fig. 1 described above. As shown in fig. 2, the method may include:
s201, obtaining message data to be sent.
S202, storing the message data into a database, and sending the message data to a communication service terminal in the process of storing the message data into the database.
S203, when the response result of the communication service end to the message data is received, the state of the message data in the database is updated according to the response result so as to complete the sending process of the message data.
In the embodiment of the present disclosure, the database may be a local storage of the sending end device.
As shown in fig. 3, the message sending process can be divided into three phases, namely a message preparation phase, a network transmission phase and a sending result confirmation phase. The processing operation of the message preparation stage comprises the steps of obtaining message data to be sent and storing the message data into a database; the network transmission stage comprises the steps of sending the message data to a communication server so as to send the message data to receiving end equipment through the communication server; and a step of sending result confirmation, namely receiving a response result returned by the server, and updating the state of the message data in the database according to the response result. When the three stages are executed in sequence, the message sending process is considered to be completed. Furthermore, the time consumption of the message sending process, which can be perceived by the user, is the total time consumption of the three stages. Referring to the example shown in fig. 3, if the time consumed for executing the message preparation phase, the network transmission phase and the transmission result confirmation phase is denoted as TMessage preparation phase,TNetwork transmission phase,TTransmission result confirmation phaseThen the message sending process takes time TGeneral assembly=TMessage preparation phase+TNetwork transmissionStage of delivery+TTransmission result confirmation phase
As can be seen from the foregoing S201 to S203, in order to optimize the time consumption of the message sending process, in the message sending method provided in the embodiment of the present disclosure, the message preparation stage and the network transmission stage are performed simultaneously, referring to fig. 4, that is: and storing the message data into a database, and sending the message data to a communication service terminal in the process of storing the message data into the database. Thus, the time consumption of the message sending process is the sum of the larger time consumption of the message preparation stage and the network transmission stage and the time consumption of the sending result confirmation stage, i.e. TGeneral assembly=Max{TMessage preparation phase,TNetwork transmission phase}+TTransmission result confirmation phaseTherefore, the time consumption of the message sending process is shortened, the shortened time is the smaller time consumption in the message preparation stage and the network transmission stage, namely, the time delta T is Min { T {Message preparation phase,TNetwork transmission phase}。
Illustratively, suppose TMessage preparation phase=50ms,TNetwork transmission phase=100ms,TTransmission result confirmation phase30 ms. Then, by the prior art, the time-consuming T of the message sending process is performedGeneral assembly50ms +100ms +30 ms-180 ms. By the message sending method provided by the embodiment of the disclosure, the time-consuming T of the message sending process is executedGeneral assembly100ms +30ms 130 ms. Therefore, the message sending method provided by the embodiment of the disclosure can shorten the time consumption of the message sending process, and the shortened time is the smaller time consumption in the message preparation stage and the network transmission stage.
In S203, the response result of the communication service to the message data may indicate that the message transmission is successful or the message transmission is failed. Wherein, successful message sending can be understood as successful message data sending to the target receiving terminal device; the failure of message transmission may be understood as a failure of message data to the target receiving end device side. In S203, the sending-end device needs to update the state of the message data in the database according to the meaning represented by the response result. Specifically, if the response result represents that the message is successfully sent, the state of the message data in the database is updated to a "sending success state"; and if the response result represents that the message is failed to be sent, updating the state of the message data in the database into a 'sending failure state'. Therefore, the consistency of the message record data at the two sides of the sending terminal equipment and the receiving terminal equipment can be ensured. Here, the "transmission success state" may also be referred to as a third state, and the "transmission failure state" may also be referred to as a fourth state.
In addition, if the response result indicates that the message is successfully sent, the response result may further include information related to the message, such as a message ID generated by the communication service end. In this case, in S203, the transmitting-end device needs to update the status of the message data in the database to the "transmission success status", and also needs to save the information about the message in the response result in the database.
In some aspects, the message sending process is considered complete when the network transmission phase is complete. However, the sending result confirmation stage is not completed yet, and the communication application is closed by the user, so that the message transmission is successful, but the message sending record locally stored by the sending end device is missing, so that the message record data of the receiving end device and the message record data of the two sides of the sending end device are inconsistent. Compared with the technical solutions, the message sending method provided by the embodiment of the present disclosure considers that the message sending process is completed after the status of the message data in the database is updated according to the response result of the communication server, that is, the message sending completion information is transmitted to the user after the sending result confirmation phase is completed, so that the time consumption of the message sending process is reduced, and the problem of inconsistent data between the sending end device and the receiving end device is avoided.
In practical applications, different types of message data are different in size, for example, basic types such as characters and expressions are smaller in size, and non-basic types such as multimedia data in various formats such as pictures, audio and video are larger in size. In practice, the time consumption for sending the message data of the basic type is small, while the data for sending the message data of the non-basic type is large, and in a specific implementation, the logic for sending the message data of the basic type is different from the logic for sending the message data of the non-basic type.
Based on the above consideration, in the embodiment of the present disclosure, for the preset type of message data, a "fast sending" manner of "sending the message data to the communication server during the process of storing the message data in the database is adopted, so as to shorten the time consumption of the sending process, and when the message data is specifically implemented, the sending logic corresponding to the message data may be configured. The preset type of message data may be understood as the aforementioned basic type of message data, such as characters, expressions, and the like. A message type set supporting the aforementioned "quick sending" mode may be preconfigured, where the message type set includes at least one message type, and the message types in the message type set are all preset types. Specifically, the set of message types may be configuration parameters that the upper layer instant messaging application enters when initializing the IMSDK.
And the message data of the non-preset type, that is, the message data of the non-basic type, that is, the message type not included in the message type set supporting the "quick send" mode, is not included. For the message data of the non-preset type, because the network transmission time for sending the message data is long, the ' fast sending ' mode of ' sending the message data to the communication server side in the process of storing the message data in the database is adopted, the time consumption can be reduced to be negligible and even can not be perceived by the user, and because the sending logic adopted by the method is different from the sending logic of the message of the preset type, the logic for sending the message data of the preset type can not be reused when the message data of the non-preset type is sent, so the disclosed embodiment adopts the existing sending logic for the message data of the non-preset type, namely: and after the message data are stored in the database, the message data are sent to the communication server. And further, the message sending logic does not need to be configured additionally, so that the development cost is reduced.
Based on this, in an implementation manner of S202, if the type of the message data acquired in S201 is a preset type, the message data is sent to the communication server in the process of storing the message data in the database. Correspondingly, if the type of the message data acquired in S201 is not the preset type, the message data is stored in the database and then sent to the communication server.
In other embodiments, for message data with a data volume smaller than a preset data volume, a "fast sending" mode of sending the message data to the communication server in the process of storing the message data in the database is adopted to shorten the time consumption of the sending process. Based on this, in one implementation manner of S202, if the data amount of the message data acquired in S201 is smaller than the preset data amount, the message data is sent to the communication server in the process of storing the message data in the database.
It should be noted that the message data to be transmitted may include multimedia data and/or non-multimedia data. Multimedia data such as files in various formats of pictures, audio, video, and the like; non-multimedia data such as text, emoticons, and the like. In a possible implementation manner, if the message data comprises multimedia data, uploading the multimedia data to a file server, and obtaining a storage address of the multimedia data returned by the file server; generating a message body according to the storage address of the multimedia data; if the message data does not include multimedia data, a message body is generated based on the non-multimedia data. In the implementation mode, when the message data to be sent contains multimedia data, the multimedia data is uploaded to the file server to obtain the storage address of the multimedia data, and then a message body is generated according to the storage address instead of the message body directly generated according to the multimedia data, so that the data volume of the message data is reduced, and the time consumption of network transmission is reduced.
Based on this, S202 above can be further understood as: and in the process of storing the message body in a database, sending the message body to the communication server.
As can be seen from S202, the operation of storing the message data and the operation of sending the message data to the server are executed simultaneously. This means that when storing the message data, the actual state of the message data is "sending state", so theoretically, the message body can be directly marked as "sending state" when storing the message body in the database, thereby simplifying the storage operation, and reducing the time consumption of the data storage process, that is, the time consumption of the data preparation stage. This "sending state" may also be referred to as a second state. Based on this, in a possible implementation manner, S202 may specifically include: storing the message body into a database, and marking the state of the message body as a second state; and in the process of storing the message body into the database and marking the state of the message body as the second state, sending the message body to the communication server.
In addition, when the message sending process is executed, the message sending may fail for some reasons (such as network and hardware), but the message body is marked as "sending state", which will cause the state of the data in the database to be inconsistent with the actual state of the data. Based on this, in a possible implementation manner, S202 may specifically include: storing the message body into a database, marking the state of the message body as a first state (namely an initial state), and updating the state of the message body from the first state to a second state; and sending the message body to a communication service terminal in the process of storing the message body into a database, marking the state of the message body as a first state or updating the state of the message body from the first state to a second state. Therefore, the situation that the message body is marked as the 'sending state' due to the fact that message sending is possibly failed for some reasons (such as network and hardware) can be avoided, the condition that the state of the data in the database is consistent with the actual state of the data is guaranteed, and the safety and the stability of data storage operation are guaranteed.
In other embodiments, when the message data to be sent includes multimedia data, S202 may specifically include: in the process of uploading the multimedia data to the file server, storing the multimedia data to a database, and marking the state of the multimedia data as a first state; and updating the state of the multimedia data in the database to a second state in the process of sending the message body to the communication service terminal. In the embodiments, the message body generated according to the storage address is stored without waiting for obtaining the storage address of the multimedia data, but the multimedia data is directly stored in the database in the process of uploading the multimedia data to the file server, so that the time consumption of data storage operation is reduced, namely the time consumption of a data preparation stage is reduced.
In a possible implementation manner, after a message body is generated according to a storage address of the multimedia data returned by the file server, the generated message body is used for replacing the corresponding multimedia data in the database, and the state of the data is kept unchanged to the second state.
It should be noted that the multimedia data may be message data of a non-preset type, or message data of a preset type. Accordingly, the non-multimedia data may be a preset type of message data or a non-preset type of message data. In another implementation manner of S202, if the type of the message data acquired in S201 is a preset type and does not include multimedia data, the message data is sent to the communication server in the process of storing the message data in the database. Correspondingly, if the type of the message data acquired in S201 is not the preset type, the message data is stored in the database and then sent to the communication server. Or, if the message data acquired in S201 includes multimedia data, uploading the multimedia data to the file server, and acquiring a storage address of the multimedia data returned by the file server; generating a message body according to the storage address of the multimedia data; and after the message body is stored in the database, the message body is sent to the communication server.
As can be seen from the foregoing embodiments, the embodiments of the present disclosure provide a message sending method, where the method first obtains message data to be sent; then storing the message data into a database, and sending the message data to a communication server in the process of storing the message data into the database; and when a response result of the communication service end to the message data is received, updating the state of the message data in the database according to the response result so as to finish the sending process of the message data. It can be seen that, in the message sending method provided by the embodiment of the present disclosure, the message preparation stage and the network transmission stage are performed simultaneously, so that the time consumption of the message sending process is the sum of the larger time consumption in the message preparation stage and the network transmission stage and the time consumption in the sending result confirmation stage, thereby shortening the time consumption of the message sending process, and the shortened time duration is the smaller time consumption in the message preparation stage and the network transmission stage.
In addition, according to the embodiment of the present disclosure, after the status of the message data in the database is updated according to the response result of the server, the message sending process is considered to be completed, that is, after the sending result confirmation stage is completed, the message sending completion information is conveyed to the user, so that the time consumption of the message sending process is reduced, and the problem of inconsistent data of the sending end and the receiving end is avoided.
Fig. 5 is a block diagram illustrating a message sending apparatus according to an exemplary embodiment, and as shown in fig. 5, the message sending apparatus 50 provided by the embodiment of the present disclosure includes a data obtaining module 501, a parallel execution module 502 and a sending result confirmation module 503. Wherein:
a data obtaining module 501, configured to obtain message data to be sent. For example, as shown in fig. 2, the data acquisition module 501 may be configured to execute S201.
The parallel execution module 502 is configured to store the message data in a database, and send the message data to the communication server in the process of storing the message data in the database. For example, as shown in fig. 2, the parallel execution module 502 may be used to execute S202.
A sending result confirming module 503, configured to, when a response result of the communication service to the message data is received, update the state of the message data in the database according to the response result, so as to complete a sending process of the message data. For example, as shown in fig. 2, the transmission result confirmation module 503 may be configured to execute S203.
In a possible implementation manner, the parallel execution module 502 is specifically configured to: if the type of the message data is a preset type, the message data is sent to the communication service end in the process of storing the message data into a database, wherein the preset type comprises at least one of a character type and an expression type; or if the data volume of the message data is smaller than the preset data volume, the message data is sent to the communication server in the process of storing the message data into the database.
In a possible implementation manner, the parallel execution module 502 is specifically configured to: if the message data comprise the multimedia data, uploading the multimedia data to a file server, and acquiring a storage address of the multimedia data returned by the file server; generating a message body according to the storage address of the multimedia data; if the message data does not comprise the multimedia data, generating a message body according to the message data; and in the process of storing the message body in a database, sending the message body to the communication server.
In a possible implementation manner, the parallel execution module 502 is specifically configured to: storing the message body into the database, and marking the state of the message body as a first state, wherein the first state is used for representing that the message body is in a state before being sent; modifying the message body marked as the first state from the first state to a second state, wherein the second state is used for representing the state that the message body is in sending; and sending the message body to the communication service terminal in the process of storing the message body into the database, marking the state of the message body as a first state or modifying the state of the message body from the first state to a second state.
In a possible implementation manner, the parallel execution module 502 is specifically configured to: storing the message body into the database, and marking the state of the message body as a second state, wherein the second state is used for representing the state of the message body in sending; and in the process of storing the message body into the database and marking the state of the message body as a second state, sending the message body to the communication service terminal.
In a possible implementation manner, the parallel execution module 502 is specifically configured to: when the message data comprises the multimedia data, in the process of uploading the multimedia data to the file server by the request generation module, storing the multimedia data to the database, and marking the state of the multimedia data as a first state, wherein the first state is used for representing the state of the multimedia data before being sent; and in the process of sending the message body to the communication server, modifying the multimedia data marked as the first state in the database from the first state to a second state, wherein the second state is used for representing the state of the message body in sending.
In a possible implementation manner, the sending result confirmation module 503 is specifically configured to: if the response result represents that the message is successfully sent, updating the state of the message data in the database to a third state, wherein the third state is used for representing that the message data is in a state of successful sending; and if the response result represents that the message is failed to be sent, updating the state of the message data in the database to a fourth state, wherein the third state is used for representing that the message data is in a state of successful sending.
The embodiment of the present disclosure provides a message sending apparatus, which first obtains message data to be sent through a data obtaining module 501; then, the message data is stored in the database through the parallel execution module 502, and the message data is sent to the communication server in the process of storing the message data in the database; when the sending result confirmation module 503 receives the response result of the communication service end to the message, the state of the message data in the database is updated according to the response result, so as to complete the sending process of the message data. It can be seen that, in the message sending apparatus provided in the embodiment of the present disclosure, the message preparation phase and the network transmission phase are performed simultaneously, so that the time consumed by the message sending process is the sum of the time consumed by the message preparation phase and the time consumed by the network transmission phase, and the time consumed by the message sending process is shortened, and the shortened time is the time consumed by the message preparation phase and the network transmission phase.
In addition, according to the embodiment of the present disclosure, after the status of the message data in the database is updated according to the response result of the server, the message sending process is considered to be completed, that is, after the sending result confirmation stage is completed, the message sending completion information is conveyed to the user, so that the time consumption of the message sending process is reduced, and the problem of inconsistent data of the sending end and the receiving end is avoided.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
As shown in fig. 6, a schematic structural diagram of an electronic device to which the technical solution provided by the embodiment of the present disclosure is applied is shown. The electronic device 60 in fig. 6 includes but is not limited to: a processor 601, a memory 602, an input unit 603, an interface unit 604, a power supply 605, and a display unit 606.
The processor 601 is a control center of the electronic device, connects various parts of the whole electronic device by using various interfaces and lines, and performs various functions of the electronic device and processes data by running or executing software programs and/or modules stored in the memory 602 and calling data stored in the memory 602, thereby performing overall monitoring of the electronic device. For example, the processor 601 is configured to execute executable instructions in the memory 602 to implement the methods provided by the embodiments of the present disclosure.
Processor 601 may include one or more processing units; optionally, the processor 601 may integrate an application processor and a modem processor, wherein the application processor mainly handles operating systems, user interfaces, application programs, and the like, and the modem processor mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 601.
The memory 602 may be used to store software programs as well as various data. The memory 602 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one functional unit, and the like. Further, the memory 602 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Alternatively, the memory 602 may be a non-transitory computer readable storage medium, for example, a read-only memory (ROM), a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
The input unit 603 may be a keyboard, a touch screen, or the like.
The interface unit 604 is an interface for connecting an external device to the electronic apparatus 60. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device having an identification module, an audio input/output (I/O) port, a video I/O port, an earphone port, and the like. The interface unit 604 may be used to receive input (e.g., data information, etc.) from an external device and transmit the received input to one or more elements within the electronic apparatus 20 or may be used to transmit data between the electronic apparatus 60 and the external device.
A power supply 605 (e.g., a battery) may be used to power the various components. Optionally, the power supply 605 may be logically connected to the processor 601 through a power management system, so as to implement functions of managing charging, discharging, power consumption management, and the like through the power management system.
The display unit 606 is used to display a User Interface (UI). The user interface may include graphics, text, icons, video, and any combination thereof. In the case where the display unit 606 is a display screen, the display unit 606 also has the ability to capture touch signals on or over the surface of the display unit 606. The touch signal may be input to the processor 601 as a control signal for processing. At this time, the display unit 606 may also be used to provide virtual buttons and/or a virtual keyboard, also referred to as soft buttons and/or a soft keyboard.
In some embodiments, the display unit 606 may be a front panel of the terminal device; the display unit 606 may be made of a Liquid Crystal Display (LCD), an organic light-emitting diode (OLED), or the like. In the case where the electronic device 60 is a terminal device, the terminal device includes a display unit 606.
Alternatively, the computer instructions in the embodiments of the present disclosure may also be referred to as application program codes or systems, which are not specifically limited by the embodiments of the present disclosure.
Note that the electronic device shown in fig. 6 is an example, and does not limit the electronic device to which the embodiment of the present disclosure is applicable. In actual implementation, the electronic device may include more or fewer devices or devices than those shown in fig. 6.
In addition, the present disclosure also provides a computer-readable storage medium, wherein when the instructions in the computer-readable storage medium are executed by the processor of the server, the electronic device is enabled to execute the method provided by the embodiment.
In addition, the present disclosure also provides a computer program product comprising computer instructions which, when run on a server, cause the server to perform the method as provided in the above embodiments.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (10)

1. A method for sending a message, comprising:
acquiring message data to be sent;
storing the message data into a database, and sending the message data to the communication server in the process of storing the message data into the database;
and when a response result of the communication service end to the message data is received, updating the state of the message data in the database according to the response result so as to finish the sending process of the message data.
2. The method according to claim 1, wherein the sending the message data to the communication service terminal in the process of storing the message data in the database comprises:
if the type of the message data is a preset type, the message data is sent to the communication service end in the process of storing the message data into a database, wherein the preset type comprises at least one of a character type and an expression type;
or if the data volume of the message data is smaller than the preset data volume, the message data is sent to the communication server in the process of storing the message data into the database.
3. The method according to claim 1, wherein the sending the message data to the communication service terminal in the process of storing the message data in the database comprises:
if the message data comprise the multimedia data, uploading the multimedia data to a file server, and acquiring a storage address of the multimedia data returned by the file server;
generating a message body according to the storage address of the multimedia data;
if the message data does not comprise the multimedia data, generating a message body according to the message data;
and in the process of storing the message body in a database, sending the message body to the communication server.
4. The method according to claim 3, wherein the sending the message body to the communication server in the process of storing the message body in the database comprises:
storing the message body into the database, and marking the state of the message body as a first state, wherein the first state is used for representing that the message body is in a state before being sent;
modifying the message body marked as the first state from the first state to a second state, wherein the second state is used for representing the state that the message body is in sending;
and sending the message body to the communication service terminal in the process of storing the message body into the database, marking the state of the message body as a first state or modifying the state of the message body from the first state to a second state.
5. The method according to claim 3, wherein the sending the message body to the communication server in the process of storing the message body in the database comprises:
storing the message body into the database, and marking the state of the message body as a second state, wherein the second state is used for representing the state of the message body in sending;
and in the process of storing the message body into the database and marking the state of the message body as the second state, sending the message body to the communication service terminal.
6. The method according to claim 3, wherein the storing the message data in a database comprises:
when the message data comprises the multimedia data, storing the multimedia data in the database in the process of uploading the multimedia data to the file server, and marking the state of the multimedia data as a first state, wherein the first state is used for representing the state of the multimedia data before being sent;
and in the process of sending the message body to the communication server, modifying the multimedia data marked as the first state in the database from the first state to a second state, wherein the second state is used for representing the state of the message body in sending.
7. A message transmission apparatus, comprising:
the data acquisition module is used for acquiring message data to be sent;
the parallel execution module is used for storing the message data into a database and sending the message data to the communication server in the process of storing the message data into the database;
and the sending result confirmation module is used for updating the state of the message data in the database according to the response result when receiving the response result of the communication service end to the message data so as to finish the sending process of the message data.
8. An electronic device, comprising: a processor and a memory for storing processor-executable instructions; wherein the processor is configured to execute the executable instructions to implement the method of any one of claims 1-6.
9. A computer-readable storage medium, wherein instructions in the computer-readable storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the method of any of claims 1-6.
10. A computer program product, characterized in that it comprises computer instructions which, when run on an electronic device, cause the electronic device to perform the method according to any of claims 1-6.
CN202111566547.4A 2021-12-20 2021-12-20 Message sending method, device, equipment and storage medium Active CN114301860B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111566547.4A CN114301860B (en) 2021-12-20 2021-12-20 Message sending method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111566547.4A CN114301860B (en) 2021-12-20 2021-12-20 Message sending method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN114301860A true CN114301860A (en) 2022-04-08
CN114301860B CN114301860B (en) 2023-09-26

Family

ID=80968721

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111566547.4A Active CN114301860B (en) 2021-12-20 2021-12-20 Message sending method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114301860B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108459787A (en) * 2018-03-13 2018-08-28 百度在线网络技术(北京)有限公司 Man-machine interaction method, device, equipment and the storage medium of terminal device
CN110430126A (en) * 2019-09-02 2019-11-08 江苏满运软件科技有限公司 Instant communication message processing method, device, system, equipment and storage medium
CN110719221A (en) * 2019-10-16 2020-01-21 北京蚂蜂窝网络科技有限公司 Instant messaging method, device, equipment and storage medium
CN112615907A (en) * 2020-12-04 2021-04-06 北京齐尔布莱特科技有限公司 Data synchronization system and method
CN113794622A (en) * 2021-08-17 2021-12-14 北京达佳互联信息技术有限公司 Message processing method and device, electronic equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108459787A (en) * 2018-03-13 2018-08-28 百度在线网络技术(北京)有限公司 Man-machine interaction method, device, equipment and the storage medium of terminal device
CN110430126A (en) * 2019-09-02 2019-11-08 江苏满运软件科技有限公司 Instant communication message processing method, device, system, equipment and storage medium
CN110719221A (en) * 2019-10-16 2020-01-21 北京蚂蜂窝网络科技有限公司 Instant messaging method, device, equipment and storage medium
CN112615907A (en) * 2020-12-04 2021-04-06 北京齐尔布莱特科技有限公司 Data synchronization system and method
CN113794622A (en) * 2021-08-17 2021-12-14 北京达佳互联信息技术有限公司 Message processing method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN114301860B (en) 2023-09-26

Similar Documents

Publication Publication Date Title
US11025963B2 (en) Data processing method, apparatus, and system for live streaming page
US10524084B2 (en) Apparatus and method for determining a wireless device's location after shutdown
CN110673782B (en) Control method applied to screen projection scene and related equipment
CN103326923B (en) Method and device for information sharing
CN102958008B (en) Method, system and mobile terminals for realizing instant messaging
CN113438355B (en) Communication method, device, equipment and storage medium based on cloud mobile phone
CN109697100A (en) Conversation message display processing method and device
WO2013130887A2 (en) Integrated messaging
CN109391476B (en) Network communication method, device and system
US20100317335A1 (en) Systems and Methods for Remotely Configuring a Mobile Device
CN108712320B (en) Message pushing method and device
CN102821150A (en) Cloud server and application managing method based on same
CN113365106A (en) Multimedia resource generation method and device, electronic equipment and storage medium
CN112016068A (en) Account control method, device, equipment and computer readable storage medium
CN113285866B (en) Information sending method and device and electronic equipment
CN109446204B (en) Data storage method and device for instant messaging, electronic equipment and medium
KR20140107736A (en) Method for providing of voice message, apparatus and system for the same
CN112035087B (en) Information prompting method and device, electronic equipment and readable storage medium
WO2019095388A1 (en) Remotely-assisted processing method and device
CN110109594B (en) Drawing data sharing method and device, storage medium and equipment
CN108616443A (en) Associated person information methods of exhibiting and device
CN102970207A (en) Instant communication method, client device and instant communication system
US20240089223A1 (en) Information display method and apparatus, and electronic device
US11775274B2 (en) Application software installation method, device, and server
US20230371088A1 (en) Communication establishment method and apparatus and storage medium

Legal Events

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