Disclosure of Invention
The embodiment of the invention aims to provide a synchronization method, a terminal, a server and a system for message reading states.
In order to solve the above technical problem, an embodiment of the present invention provides a synchronization method for a message reading status, which is applied to a terminal, where the terminal and an associated terminal share a same account, and the method includes: sending a message receiving instruction to a server; the server is used for carrying out message transmission with the terminal and the associated terminal, and the instruction at least comprises the following steps: information of the account number; receiving historical information and first identification information sent by a server according to the information of the account; the historical information is specifically all information which is not received by the account on the terminal, and the first identification information is used for indicating the last information of the account sent by the server when an instruction sent by the terminal is received; and dividing the history message into a read state message and an unread state message according to the first identification information.
The embodiment of the invention also provides a synchronization method for message reading states, which is applied to a server and comprises the following steps: when receiving a message receiving instruction sent by a terminal, acquiring a history message according to the instruction; wherein, the instruction at least comprises: information of the account number; the historical messages are all messages which are not received by the account on the terminal; acquiring first identification information used for indicating the last message of an account sent by a server when an instruction sent by a terminal is received; and sending the acquired history message and the first identification information to the terminal.
An embodiment of the present invention further provides a terminal, including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a method of synchronizing a message read status.
The embodiment of the invention also provides a server, which comprises: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a method of synchronizing a message read status.
The embodiment of the invention also provides a synchronization system for message reading state, which comprises the terminal and the server.
Compared with the prior art, the method and the system for sending the message have the advantages that the terminal and the related terminal share the same account number, and when the terminal is on-line, the instruction for receiving the message in the off-line period is sent to the server side. And when receiving the instruction, the server sends the history information of the account and first identification information used for indicating the last message of the account sent by the server when receiving the instruction sent by the terminal to the terminal according to the information of the account in the instruction. After receiving the history message and the first identification information sent by the server, the terminal divides the history message into a read state message and an unread state message according to the first identification information. The reading state of the calculation message is finished at the terminal, the server side does not need to transmit the message, does not need to perform extra calculation operation, and greatly saves the resources of the server under a high concurrency scene.
Additionally, the instructions to receive a message further include at least: and the second identification information is used for indicating the last message received by the account at the terminal so that the server side can determine the sent historical message according to the second identification information. In this way, the server side can directly judge the message range of the history message to be sent through the second identification information sent by the terminal, and the sending of useless messages is avoided.
In addition, the messages are stored in the corresponding message queues in time sequence; the first identification information is specifically used for indicating the position of the last message of the account sent by the server in the message queue. The information of each account is stored in the corresponding information queue, and the first identification information of each information queue is used for identifying and indicating the position of the last information of the account in the information queue, which is sent by the server, so that the terminal can conveniently calculate the reading state of the information through the information queue of the historical information sent by the server and the first identification information, and the calculation efficiency of the reading state of the information is improved.
In addition, the dividing of the history message into a read status message and an unread status message according to the first identification information specifically includes: determining the position in the queue of the historical messages indicated by the first identification information, and taking the message corresponding to the position as a boundary message; and respectively taking the two parts of history messages divided by the boundary message as unread status messages and read status messages. The specific implementation mode of the reading state of each message in the history message is judged through the first identification information, so that the read state message and the unread state message can be quickly and accurately distinguished, and the use experience of a user for reading the message by using a terminal is improved.
In addition, when a new message is received, whether a terminal corresponding to the new message is in an off-line state is detected; and if the terminal corresponding to the new message is in an off-line state, storing the new message into a corresponding message queue, and sending the new message after the terminal is detected to be on-line. And when the terminal is offline, the new messages are classified and stored, so that the new messages can be quickly acquired from the corresponding message queue after the terminal is online, and the rate of searching the required messages by the server is improved.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, embodiments of the present invention will be described in detail below with reference to the accompanying drawings. However, it will be appreciated by those of ordinary skill in the art that numerous technical details are set forth in order to provide a better understanding of the present application in various embodiments of the present invention. However, the technical solution claimed in the present application can be implemented without these technical details and various changes and modifications based on the following embodiments.
The following embodiments are divided for convenience of description, and should not constitute any limitation to the specific implementation manner of the present invention, and the embodiments may be mutually incorporated and referred to without contradiction.
The first embodiment of the invention relates to a synchronization method for message reading states, which is applied to a terminal, wherein the terminal and a related terminal share the same account number, and the method comprises the following steps: sending a message receiving instruction to a server; the server is used for carrying out message transmission with the terminal and the associated terminal, and the instruction at least comprises the following steps: information of the account number; receiving historical information and first identification information sent by a server according to the information of the account; the historical information is specifically all information which is not received by the account on the terminal, and the first identification information is used for indicating the last information of the account sent by the server when an instruction sent by the terminal is received; and dividing the history message into a read state message and an unread state message according to the first identification information. The client side carries out the calculation of the message reading state, the server side only needs to transmit the message without carrying out additional calculation operation, and the resources of the server are greatly saved under a high concurrency scene. The following describes the synchronization method for message reading status in the present embodiment in detail, and the following is only provided for the convenience of understanding and is not necessary for implementing the present embodiment. The specific flow is shown in figure 1.
Step 101, sending a message receiving instruction to a server. Specifically, after the terminal is on-line, the terminal sends a message receiving instruction to the server, and receives a new message sent to the account by another terminal during off-line. For example, if the terminal logs in the QQ and acquires a new message during an offline period, the instruction of the received message sent by the terminal at least carries information of the QQ account or ID information specific to the user, so that the server can know a message list required by the terminal when receiving the instruction, and the number of communications between the client and the server is reduced.
In addition, the instruction for receiving the message sent by the terminal may also carry second identification information, where the second identification information is used to indicate the last message received by the account at the terminal, so that the server determines the sent history message according to the second identification information. For example, when the terminal logs in the QQ account, the last message received is a message a at time T1, and then the second identification information may be time T1, or may be a unique identifier of the message a, where the second identification information is used to indicate the position of the message a in the message queue, so that the service end can accurately and quickly find the position of the message in the message queue of the service end through the second identification information, thereby avoiding sending the message that the terminal has received, and improving the experience of the user in checking and receiving the message.
And 102, receiving the history information and the first identification information sent by the server according to the information of the account. Specifically, the terminal receives a history message sent by the server during the terminal offline period and the first identification information. Because a user can log in the same account through a plurality of different terminals, in a history message received by the terminal during an offline period, the user may already read part of messages in the history message at other terminals, and the first identification information sent by the server may indicate the last message of the account sent by the server when receiving an instruction sent by the terminal, and the first identification information may also be used for indicating the last message sent by the server. For example, the server sends a message 1 to a message 10 to the terminal a at time T1, at this time, the first identification information is used to indicate the position of the message 10 in the message queue, at time T2, the server receives a message request of the same account sent by the terminal B and carries that the last message received by the terminal B is a message 3, and then the server sends the latest message 14 from the message 3 to the currently received account to the terminal B and also sends the first identification information indicating the position of the message 10 in the message queue to the terminal B. Terminal B, upon receiving the history messages (message 3 to message 14) and the first identification information, may divide the history messages (message 3 to message 14) into a read status message and an unread status message according to the first identification information.
And 103, dividing the history message into a read state message and an unread state message according to the first identification information. Specifically, the history messages received by the terminal are stored in a message queue, and the messages in the message queue are sorted in time sequence. When the terminal receives the history message and the first identification information, the position of the message in the message queue of the history message indicated by the first identification information is used as a boundary, the history message is divided into two parts, and the two parts of history message are respectively used as a read state message and an unread state message. Taking the history message received by the terminal B and the first identification information as examples, when the terminal B receives the messages 3 to 14 and the first identification information indicates the position of the message 10 in the message queue, the messages 3 to 10 are regarded as read status messages, and the messages 11 to 14 are regarded as unread status messages. In practical application, the messages in different reading states can be displayed in different display modes, so that a user can accurately and efficiently check the required messages, and the user experience is improved.
Compared with the prior art, the method and the system for sending the message have the advantages that the terminal and the related terminal share the same account number, and when the terminal is on-line, the instruction for receiving the message in the off-line period is sent to the server side. And when receiving the instruction, the server sends the history information of the account and first identification information used for indicating the last message of the account sent by the server when receiving the instruction sent by the terminal to the terminal according to the information of the account in the instruction. After receiving the history message and the first identification information sent by the server, the terminal divides the history message into a read state message and an unread state message according to the first identification information. The reading state of the calculation message is finished at the terminal, the server side does not need to transmit the message, does not need to perform extra calculation operation, and greatly saves the resources of the server under a high concurrency scene.
The second embodiment of the invention relates to a synchronization method for message reading states, which is applied to a server and comprises the following steps: when receiving a message receiving instruction sent by a terminal, acquiring a history message according to the instruction; wherein, the instruction at least comprises: information of the account number; the historical messages are all messages which are not received by the account on the terminal; acquiring first identification information used for indicating the last message of an account sent by a server when an instruction sent by a terminal is received; and sending the acquired history message and the first identification information to the terminal. The server only needs to transmit the message without extra calculation operation, and greatly saves the resources of the server in a high concurrency scene. The following describes the synchronization method for message reading status in the present embodiment in detail, and the following is only provided for the convenience of understanding and is not necessary for implementing the present embodiment. The specific flow is shown in fig. 2.
Step 201, when receiving an instruction of receiving a message sent by a terminal, acquiring a history message according to the instruction.
Step 202, obtaining first identification information used for indicating the last message of the account sent by the server when receiving the instruction sent by the terminal.
And step 203, sending the acquired history message and the first identification information to the terminal.
Specifically, when receiving an instruction sent by a terminal, a server finds a message queue of an account in a database of the server according to account information carried in the instruction sent by the terminal, finds a history message required by the terminal in the message queue of the account according to second identification information used for indicating the account to receive the last message received by the terminal, and sends the history message to the terminal. In addition, the server needs to send the first identification information to the terminal together, where the first identification information is used to indicate the last message of the account sent by the server when receiving the instruction sent by the terminal, and the terminal can divide the reading state of the history message by using the first identification information, so as to implement synchronization of the message reading state. The server only needs to transmit the message in the whole message synchronization process, and does not need to perform extra calculation operation, so that server resources consumed by calculation operation are saved, the working pressure of the server is greatly reduced, and the server is prevented from being dragged and crossed under a high-concurrency scene.
In the following, by a specific example, the system specifically describes the workflow of the client and the server in the message synchronization process, as shown in fig. 3, L1, L2, and L3 respectively represent the message flow of an account of the terminal a, the message flow of the account of the server, and the message flow of the account of the terminal B. The terminal A and the terminal B are associated terminals and log in the same account together, the server stores the message list data of the account, and the server can communicate with the terminal A and the terminal B. And marking the position of the message of the client on the message stream by using the identification cid, and marking the position of the message of the server on the message stream by using the identification sid.
In the message flow L1 of the terminal a, the position of the last message in the message flow displayed when the terminal a goes online is identified by C0, and the terminal a sends an instruction to the server to receive the message after going online, where the instruction carries the identifier C0 indicating the message. After receiving the command, the server determines the historical messages sent to the terminal a, i.e. all messages with the server message stream positions between C0 and S1, according to the identifier C0 in the command and the latest message (assumed to be the message at the S1 position on the message stream) received by the current server. In addition, the server determines the last message sent upon receiving the instruction of terminal a, i.e. the message of the location identified as S0 on the message stream. The server sends the determined history message and the identification information S0 to the terminal a, and updates the identification sid, that is, the last message sent by the current server is the location of S1. After receiving the history messages (C0 to S1) sent by the server, the terminal a divides the received history messages into read messages and unread messages according to the identification information S0, that is, the messages located at positions C0 to S0 on the terminal a message stream L1 are displayed as read messages, the messages located at positions S0 to S1 are unread messages, and while receiving the history messages sent by the server, updates the cid of the terminal a to the position of the latest received message, that is, the position updated by C0 is the position identified as S1 by the message stream L1, and marks the position of the message stream at S1 as C1.
Assuming that after the server sends the history record to the terminal a, the server receives the instruction of receiving the message sent by the terminal B, where the instruction of the terminal B carries the identifier C2, and the latest message received by the server at this time is the message with the position of S2 in the message flow L2. If the position indicated by the server according to the instruction and the position indicated by the C2 is the same as the position indicated by the S0, the message with the position between S0 and S2 in the message flow L2 is taken as a history message, and the position of the last message sent by the server to the terminal a is updated in S1, so that the identification information sent by the server is S1. The server updates the message location on the message stream identified by the sid to S2 after transmitting the history message (S0 to S2) to the terminal B. After receiving the history message and the identification information, the terminal B also divides the history message into a read status message and an unread status message, for example, positions S1 to C3 in a message flow L3 in the figure are unread status messages, and updates the identification cid indicating the position of the message flow where the last message is received to C3, thereby completing the synchronization of the message reading status of the terminal B and the message reading status of the terminal a.
In addition, in practical application, the identification tid can be used for identifying a message which is newly received by the server, and the position of the tid on the message stream is updated when the server receives the message again, so that the position of the message queue where the latest message received by the server is located can be accurately found through the updated tid.
The steps of the above methods are divided for clarity, and the implementation may be combined into one step or split some steps, and the steps are divided into multiple steps, so long as the same logical relationship is included, which are all within the protection scope of the present patent; it is within the scope of the patent to add insignificant modifications to the algorithms or processes or to introduce insignificant design changes to the core design without changing the algorithms or processes.
A third embodiment of the present invention relates to a synchronization device for message read status, as shown in fig. 4, including: afirst sending module 41, afirst receiving module 42, a dividingmodule 43; thefirst sending module 41 is configured to send a message receiving instruction to the server; the server is used for carrying out message transmission with the terminal and the associated terminal, and the instruction at least comprises the following steps: information of the account number; thefirst receiving module 42 is configured to receive a history message and first identification information sent by the server according to the information of the account; the historical information is specifically all information which is not received by the account on the terminal, and the first identification information is used for indicating the last information of the account sent by the server when an instruction sent by the terminal is received; the dividingmodule 43 is configured to divide the history message into a read status message and an unread status message according to the first identification information.
It should be understood that this embodiment is a system example corresponding to the first embodiment, and may be implemented in cooperation with the first embodiment. The related technical details mentioned in the first embodiment are still valid in this embodiment, and are not described herein again in order to reduce repetition. Accordingly, the related-art details mentioned in the present embodiment can also be applied to the first embodiment.
It should be noted that each module referred to in this embodiment is a logical module, and in practical applications, one logical unit may be one physical unit, may be a part of one physical unit, and may be implemented by a combination of multiple physical units. In addition, in order to highlight the innovative part of the present invention, elements that are not so closely related to solving the technical problems proposed by the present invention are not introduced in the present embodiment, but this does not indicate that other elements are not present in the present embodiment.
A fourth embodiment of the present invention relates to a synchronization device for a message read status, as shown in fig. 5, including: asecond receiving module 51, an obtaining module 52, asecond sending module 53; thesecond receiving module 51 is configured to receive a message receiving instruction sent by the terminal; the obtaining module 52 is configured to obtain the history message according to the instruction, and obtain first identification information used for indicating a last message of the account sent by the server when receiving the instruction sent by the terminal; wherein, the instruction at least comprises: information of the account number; the historical messages are all messages which are not received by the account on the terminal; thesecond sending module 53 is configured to send the acquired history message and the first identification information to the terminal.
Since the second embodiment corresponds to the present embodiment, the present embodiment can be implemented in cooperation with the second embodiment. The related technical details mentioned in the second embodiment are still valid in this embodiment, and the technical effects that can be achieved in the second embodiment can also be achieved in this embodiment, and are not described herein again in order to reduce the repetition. Accordingly, the related-art details mentioned in the present embodiment can also be applied to the second embodiment.
A fifth embodiment of the present invention is directed to a terminal, as shown in fig. 6, including at least oneprocessor 601; and amemory 602 communicatively coupled to the at least oneprocessor 601; thememory 602 stores instructions executable by the at least oneprocessor 601, and the instructions are executed by the at least oneprocessor 601 to enable the at least oneprocessor 601 to execute the synchronization method for the message reading status.
Where thememory 602 and theprocessor 601 are coupled by a bus, the bus may comprise any number of interconnected buses and bridges that couple one or more of the various circuits of theprocessor 601 and thememory 602 together. The bus may also connect various other circuits such as peripherals, voltage regulators, power management circuits, and the like, which are well known in the art, and therefore, will not be described any further herein. A bus interface provides an interface between the bus and the transceiver. The transceiver may be one element or a plurality of elements, such as a plurality of receivers and transmitters, providing a means for communicating with various other apparatus over a transmission medium. The data processed by the processor is transmitted over a wireless medium via an antenna, which further receives the data and transmits the data to theprocessor 601.
Theprocessor 601 is responsible for managing the bus and general processing and may also provide various functions including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Whilememory 602 may be used to store data used byprocessor 601 in performing operations.
A sixth embodiment of the present invention relates to a server, as shown in fig. 7, including at least oneprocessor 701; and, amemory 702 communicatively coupled to the at least oneprocessor 701; thememory 702 stores instructions executable by the at least oneprocessor 701, and the instructions are executed by the at least oneprocessor 701 to enable the at least oneprocessor 701 to execute the synchronization method for the message reading status.
Thememory 702 and theprocessor 701 are coupled by a bus, which may comprise any number of interconnecting buses and bridges that couple one or more of the various circuits of theprocessor 701 and thememory 702. The bus may also connect various other circuits such as peripherals, voltage regulators, power management circuits, and the like, which are well known in the art, and therefore, will not be described any further herein. A bus interface provides an interface between the bus and the transceiver. The transceiver may be one element or a plurality of elements, such as a plurality of receivers and transmitters, providing a means for communicating with various other apparatus over a transmission medium. The data processed by the processor is transmitted over a wireless medium via an antenna, which further receives the data and transmits the data to theprocessor 701.
Theprocessor 701 is responsible for managing the bus and general processing and may also provide various functions including timing, peripheral interfaces, voltage regulation, power management, and other control functions. And thememory 702 may be used for storing data used by theprocessor 701 in performing operations.
A seventh embodiment of the present invention relates to a synchronization system for message reading status, which includes a plurality of terminals and a server; as shown in fig. 8, thefirst terminal 811, thesecond terminal 812, thethird terminal 813, and the server 82 together constitute a synchronization system for message reading status.
An eighth embodiment of the present invention relates to a computer-readable storage medium storing a computer program. The computer program realizes the above-described method embodiments when executed by a processor.
That is, as can be understood by those skilled in the art, all or part of the steps in the method for implementing the embodiments described above may be implemented by a program instructing related hardware, where the program is stored in a storage medium and includes several instructions to enable a device (which may be a single chip, a chip, or the like) or a processor (processor) to execute all or part of the steps of the method described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It will be understood by those of ordinary skill in the art that the foregoing embodiments are specific examples for carrying out the invention, and that various changes in form and details may be made therein without departing from the spirit and scope of the invention in practice.