Method and apparatus for synchronizing messages
By detecting the identity consistency in message records between devices, determining the synchronization identifier and sending corresponding messages, the problem of waste of communication and storage resources in message synchronization between devices is solved, and complete synchronization of messages is achieved.
Patent Information
- Application Number
- CN202110056753.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-15
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2041-01-15
AI Technical Summary
Existing message synchronization methods between devices have the problem of wasting communication resources and storage resources.
By receiving the identifier in the message record, detecting the consistency of the identifier in the message synchronization instruction, determining the synchronization identifier, and sending the corresponding message record to achieve message synchronization between devices, ensure message integrity and reduce redundant message transmission.
It effectively saves communication resources during the message synchronization process, avoids the waste of storage resources caused by the second terminal receiving redundant messages, and ensures complete synchronization of messages between devices.
Smart Images

Figure CN113765985B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a method and device for synchronizing messages. Background Art
[0002] As users have more and more electronic devices, keeping messages between devices synchronized can facilitate users to chat or process files. The existing method for synchronizing messages between devices is to synchronize messages within a preset time period of the user or the latest preset number of messages between devices.
[0003] However, the existing method for synchronizing messages between devices has the problem of wasting communication resources and storage resources. Summary of the invention
[0004] The present disclosure provides a method, an apparatus, an electronic device, and a computer-readable storage medium for synchronizing messages.
[0005] According to a first aspect of the present disclosure, a method for synchronizing messages is provided, the method comprising: receiving a message record, wherein the message record includes a message and an identifier corresponding to the message; in response to detecting a message synchronization instruction, determining whether a first identifier corresponding to the latest message in the message record is consistent with a second identifier in the message synchronization instruction; in response to determining that the first identifier is inconsistent with the second identifier, determining a synchronization identifier based on the first identifier and the second identifier; and sending a message in the message record that corresponds to the synchronization identifier.
[0006] In some embodiments, the identifier corresponding to each message in the message record is a continuous serial number, the second identifier includes the second serial number, and in response to determining that the first identifier and the second identifier are inconsistent, a synchronization identifier is determined based on the first identifier and the second identifier, including: in response to determining that the first serial number and the second serial number are inconsistent, the first serial number and the serial number between the first serial number and the second serial number are determined as synchronization identifiers.
[0007] In some embodiments, the message record includes an operation instruction of the message, and sending the message corresponding to the synchronization identifier in the message record includes: sending the message corresponding to the synchronization identifier in the message record and the operation instruction of the message.
[0008] In some embodiments, sending a message corresponding to a synchronization identifier in a message record includes: encapsulating the message corresponding to the synchronization identifier in the message record into a data packet; and sending the data packet.
[0009] According to a second aspect of the present disclosure, a method for receiving information is provided, the method comprising: sending a message synchronization instruction, wherein the message synchronization instruction includes a second identifier; receiving a message corresponding to the synchronization identifier in a message record; wherein the message record includes the message and an identifier corresponding to the message; the synchronization identifier is determined based on a first identifier and a second identifier corresponding to the latest message in the message record.
[0010] In some embodiments, the method includes: receiving a message corresponding to a synchronization identifier in a message record and an operation instruction of the message; and performing an operation indicated by the operation instruction on the message.
[0011] In some embodiments, the method further includes: before sending a message synchronization instruction next time, updating the second identifier according to the first identifier.
[0012] According to a third aspect of the present disclosure, a device for synchronizing messages is provided, the device comprising: a first receiving unit, configured to receive a message record, wherein the message record includes a message and an identifier corresponding to the message; a matching unit, configured to determine, in response to detecting a message synchronization instruction, whether a first identifier corresponding to the latest message in the message record is consistent with a second identifier in the message synchronization instruction; a determination unit, configured to determine a synchronization identifier based on the first identifier and the second identifier in response to determining that the first identifier is inconsistent with the second identifier; and a first sending unit, configured to send a message corresponding to the synchronization identifier in the message record.
[0013] In some embodiments, the identifiers corresponding to the messages in the message record are continuous serial numbers, the second identifier includes the second serial number, and the determination unit includes: a determination module, configured to, in response to determining that the first serial number and the second serial number are inconsistent, determine the first serial number and the serial number between the first serial number and the second serial number as synchronization identifiers.
[0014] In some embodiments, the message record includes an operation instruction of the message, and the first sending unit includes: a first sending module configured to send a message corresponding to the synchronization identifier in the message record and the operation instruction of the message.
[0015] In some embodiments, the first sending unit includes: an encapsulation module configured to encapsulate the message corresponding to the synchronization identifier in the message record into a data packet; and a third sending module configured to send the data packet.
[0016] According to a fourth aspect of the present disclosure, a device for receiving information is provided, the device comprising: a second sending unit, configured to send a message synchronization instruction, wherein the message synchronization instruction includes a second identifier; a second receiving unit, configured to receive a message corresponding to the synchronization identifier in a message record; wherein the message record includes a message and an identifier corresponding to the message; the synchronization identifier is determined based on a first identifier and a second identifier corresponding to the latest message in the message record.
[0017] In some embodiments, the device includes: a receiving module configured to receive a message corresponding to a synchronization identifier in a message record and an operation instruction of the message; and an execution module configured to execute the operation indicated by the operation instruction on the message.
[0018] In some embodiments, the device further includes: an updating module configured to update the second identifier according to the first identifier before sending a message synchronization instruction next time.
[0019] According to the fifth aspect of the present disclosure, an embodiment of the present disclosure provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the method for synchronizing messages as provided in the first aspect or implement the method for receiving information as provided in the second aspect.
[0020] According to the sixth aspect of the present disclosure, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the method for synchronizing messages provided in the first aspect or the method for receiving information provided in the second aspect is implemented.
[0021] The method and device for synchronizing messages provided by the present disclosure can receive a message record, and after detecting a message synchronization instruction, determine whether a first identifier corresponding to the latest message in the message record is consistent with a second identifier in the message synchronization instruction; if it is determined that the first identifier and the second identifier are inconsistent, a synchronization identifier is determined based on the first identifier and the second identifier, and a message corresponding to the synchronization identifier in the message record is sent; based on the first identifier in the message record and the second identifier in the message synchronization request, messages sent and received by a user using a first terminal stored on a server are synchronized with the user's second terminal, which can save communication resources in the message synchronization process and avoid waste of storage resources caused by the second terminal receiving redundant messages.
[0022] The technology of the present application solves the problem of waste of communication resources and storage resources in the existing method for synchronizing messages between devices.
[0023] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present application.
[0025] Figure 1 is an exemplary system architecture diagram to which embodiments of the present application may be applied;
[0026] Figure 2 is a flow chart of an embodiment of a method for synchronizing messages according to the present application;
[0027] Figure 3 is a flow chart of an embodiment of a method for receiving information according to the present application;
[0028] Figure 4 is a structural diagram of an embodiment of an apparatus for synchronizing messages according to the present application;
[0029] Figure 5 is a structural schematic diagram of an embodiment of a device for receiving information according to the present application;
[0030] Figure 6 It is a block diagram of an electronic device used to implement the method for synchronizing messages in an embodiment of the present application. DETAILED DESCRIPTION
[0031] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0032] Figure 1 An exemplary system architecture 100 is shown to which embodiments of the method for receiving information or the apparatus for receiving information of the present application can be applied.
[0033] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0034] The user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages, etc. The terminal devices 101, 102, 103 can be installed with various client applications for receiving push services, such as shopping applications, chat applications, web applications, search applications, banking applications, game applications, financial applications, etc.
[0035] The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting messaging services, including but not limited to smart phones, tablet computers, e-book readers, electronic players, portable computers, desktop computers, and the like.
[0036] The terminal devices 101, 102, 103 can be hardware or software. When the terminal devices 101, 102, 103 are hardware, they can be various electronic devices. When the terminal devices 101, 102, 103 are software, they can be installed in the above electronic devices. They can be implemented as multiple software or software modules (for example, multiple software modules for providing distributed services), or they can be implemented as a single software or software module. No specific limitation is made here.
[0037] The server 105 can receive message records from terminal devices 101, 102, and 103, wherein the message records include messages and identifiers corresponding to the messages. If a message synchronization instruction is detected, it is determined whether the first identifier corresponding to the latest message in the message record is consistent with the second identifier in the message synchronization instruction. If it is determined that the first identifier and the second identifier are inconsistent, the synchronization identifier is determined based on the first identifier and the second identifier, and the message corresponding to the synchronization identifier in the message record is sent to the terminal device.
[0038] It should be noted that the method for synchronizing messages provided in the embodiments of the present disclosure is generally performed by the server 105, and accordingly, the apparatus for synchronizing messages is generally provided in the server 105. The method for receiving information provided in the embodiments of the present disclosure is generally performed by the terminal devices 101, 102, 103, and accordingly, the apparatus for receiving information is generally provided in the terminal devices 101, 102, 103.
[0039] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0040] Continue to refer Figure 2 , shows a process 200 of an embodiment of a method for synchronizing messages according to the present disclosure. The method for synchronizing messages comprises the following steps:
[0041] Step 201: Receive a message record, wherein the message record includes a message and an identifier corresponding to the message.
[0042] In this embodiment, the execution subject of the method for synchronizing messages (eg Figure 1 The server shown in the figure can obtain the message record sent by the first terminal in a wired or wireless manner, wherein the message record includes the message sent by the user to other devices (such as a friend's terminal) when using the first terminal, or the message received from other devices (such as a friend's terminal), and the message can be a conversation information, or data such as a file, picture or video; the message record also includes the identifier of each message, such as the sequence number of the message, the number of the message, etc.
[0043] Step 202: In response to detecting the message synchronization instruction, determine whether a first identifier corresponding to the latest message in the message record is consistent with a second identifier in the message synchronization instruction.
[0044] In this embodiment, if the server detects a message synchronization instruction, it can determine whether the identifier corresponding to the message most recently received by the server (the last message received) in the message record, that is, the first identifier, is consistent with the identifier in the message synchronization instruction, that is, the second identifier. The message synchronization instruction can be an instruction generated by the server at regular intervals. In this case, the second identifier can be the identifier of the last message in the message record sent by the server based on the message synchronization instruction generated last time; the message synchronization instruction can also be an instruction received by the server and sent by a terminal with a message synchronization requirement (such as a heartbeat signal generated when the device is online). In this case, the second identifier can be the identifier carried in the message synchronization instruction sent by the terminal to the server, that is, the identifier corresponding to the message that the terminal device needs to synchronize.
[0045] Step 203: In response to determining that the first identifier is inconsistent with the second identifier, a synchronization identifier is determined according to the first identifier and the second identifier.
[0046] In this embodiment, if the server determines that the first identifier is inconsistent with the second identifier, a synchronization identifier can be determined based on the first identifier and the second identifier, and the synchronization identifier refers to the identifier of the message to be synchronized. Specifically, the server can determine the second identifier as the synchronization identifier, for example, the second identifier is the identifier of the message that the message synchronization instruction sending end needs to synchronize, the server determines the second identifier as the synchronization identifier, and can send the message that the message synchronization instruction sending end needs to synchronize to it; if the identifier of the message is incremented / decremented in sequence according to the time when the message is generated, the server can determine the identifier between the first identifier and the second identifier as the synchronization identifier, so as to send the message that the message synchronization instruction sending terminal is missing to it; the server can also determine an identifier other than the second identifier as a synchronization identifier, for example, the second identifier is the identifier of the message stored by the message synchronization instruction sending end, the server determines an identifier other than the second identifier as a synchronization identifier, and can send messages other than the messages that the message synchronization instruction sending end has to it.
[0047] Step 204: Send the message corresponding to the synchronization identifier in the message record.
[0048] In this embodiment, the server can send the message corresponding to the synchronization identifier in the message record stored therein to the second terminal. It can be understood that the second terminal can be a terminal of the above-mentioned user other than the first terminal, that is, the server stores the messages sent and received by the above-mentioned user using the first terminal in the server, and sends the message to the second terminal of the above-mentioned user.
[0049] It should be noted that the first terminal and the second terminal can be different terminals. In this case, message synchronization between different terminals can maintain the integrity of the message records on each terminal; the first terminal and the second terminal can also be the same terminal. In this case, the server will synchronize the messages received from the terminal to the same terminal, and the message records can be backed up or restored.
[0050] The method for synchronizing messages provided in this embodiment can receive a message record, and after detecting a message synchronization instruction, determine whether a first identifier corresponding to the latest message in the message record is consistent with a second identifier in the message synchronization instruction; if it is determined that the first identifier and the second identifier are inconsistent, a synchronization identifier is determined based on the first identifier and the second identifier, and a message corresponding to the synchronization identifier in the message record is sent; based on the first identifier in the message record and the second identifier in the message synchronization request, messages sent and received by a user using a first terminal saved by a server are synchronized with the user's second terminal, so that messages can be synchronized on demand, communication resources can be saved during the message synchronization process, and storage resource waste caused by the second terminal receiving redundant messages can be avoided.
[0051] Optionally, the identifier corresponding to each message in the message record is a continuous serial number, the second identifier includes the second serial number, and in response to determining that the first identifier and the second identifier are inconsistent, a synchronization identifier is determined based on the first identifier and the second identifier, including: in response to determining that the first serial number and the second serial number are inconsistent, the first serial number and the serial number between the first serial number and the second serial number are determined as synchronization identifiers.
[0052] In this embodiment, the identifiers corresponding to the messages in the message record are continuous serial numbers, and the second identifier in the message synchronization instruction is the second serial number, that is, the identifiers corresponding to all messages generated on the devices owned by the user are continuous serial numbers. If the server determines that the first serial number is inconsistent with the second serial number, the first serial number and the serial number between the first serial number and the second serial number can be determined as the synchronization identifier.
[0053] For example, a user owns three terminal devices, a tablet computer, a smart phone, and a portable computer. When the user is using the tablet computer, he receives a message "Hello" sent by his friend's terminal. After that, the tablet computer runs out of power and automatically shuts down. The user continues to use the smart phone to send and receive messages and receives a message "What time is it now?". After that, the user turns off the smart phone and continues to send and receive messages using the portable computer, and feeds back a message "It is ten o'clock in the morning" to his friend's terminal. Then, the serial number of the message "Hello" may be "001", the serial number of the message "What time is it now" may be "002", and the serial number of the message "It is ten o'clock in the morning" may be "003". The server can receive messages sent and received by the tablet terminal, smart phone and portable computer, as well as the serial number of each message. When the tablet is charged and turned on by the user again to send and receive messages, a message synchronization instruction can be sent to the server, and the second serial number "001" can be carried in the message synchronization instruction. The server matches the second serial number "001" with the serial number "003" of the latest message in the message record received by the server, and determines that the two are inconsistent, then "003" and the serial number "002" between "001" and "003" are determined as synchronization identifiers, and the message corresponding to the synchronization identifier is sent to the tablet computer, so that the tablet computer stores a complete message record of the user sending and receiving messages using each terminal. It can be understood that using the same method in this example, the server can synchronize the complete message record to the user's smart phone and portable computer.
[0054] This embodiment adopts a continuous serial number as the message identifier. It can determine the sequence number corresponding to the message missing from the message synchronization instruction sending end based on the latest message stored in the server and the sequence number corresponding to the message stored in the message synchronization instruction sending end, and use the sequence number corresponding to the missing message as the synchronization identifier to send the missing message to the message synchronization instruction sending end, thereby improving the accuracy and efficiency of determining the synchronization identifier.
[0055] Optionally, the server may detect whether the serial numbers corresponding to the messages in the stored message record are continuous, and in response to detecting that the serial numbers corresponding to the messages are not continuous, determine that there are missing messages in the message record.
[0056] In this embodiment, when the server receives the message sent by the terminal, there is a problem of reception failure caused by network lag or weak network signal, or storage failure caused by excessive server storage pressure or write failure. When a continuous serial number is used as the message identifier, the server can detect whether the serial number in the message record is continuous, and determine whether there are missing messages in the message record when it detects that the serial number is discontinuous, and re-acquire the message corresponding to the missing serial number from the terminal, thereby ensuring the accuracy of the messages stored by the server.
[0057] Optionally, the message synchronization instruction includes a user tag, and determining the synchronization identifier according to the first identifier and the second identifier includes: determining the synchronization identifier according to the first identifier, the second identifier and the user tag.
[0058] In this embodiment, the message synchronization instruction may include a user tag, that is, a user identifier corresponding to the message sending user, the message receiving user, or the message creating user, and the server may determine the synchronization identifier based on the first identifier, the second identifier, and the user tag. Specifically, the server may determine the message corresponding to the user tag in the storage unit based on the user tag in the message instruction, and determine the synchronization identifier in the message record corresponding to the user tag based on the first identifier and the second identifier. Matching the message record with the user tag allows the user to obtain messages in a targeted manner, improves the efficiency of obtaining messages, and saves communication resources.
[0059] Optionally, the message record includes an operation instruction of the message, and sending the message corresponding to the synchronization identifier in the message record includes: sending the message corresponding to the synchronization identifier in the message record and the operation instruction of the message.
[0060] In this embodiment, the message record may include an operation instruction of the message, and the server may send the message corresponding to the synchronization identifier in the message record and the operation instruction of the message to the terminal with message synchronization requirements. The operation instruction indicates the operation performed on the message, such as deleting the message, copying the message, and collecting the message.
[0061] This embodiment sends the operation instructions corresponding to the message together with the message, so that the receiving end can perform the same operation on the corresponding message according to the operation instructions, so as to maintain the consistency of the operations performed by the user's various terminal devices on the same message, and further improve the user's comfort and convenience when using multiple terminals to send and receive messages or process messages.
[0062] In the above combination Figure 2 In some optional implementations of the described embodiment, sending a message corresponding to a synchronization identifier in a message record includes: encapsulating the message corresponding to the synchronization identifier in the message record into a data packet; and sending the data packet.
[0063] In this embodiment, the server can encapsulate the message to be sent corresponding to the synchronization identifier in the message record into a data packet and send the data packet. In this embodiment, multiple messages to be sent are packaged and sent in a data packaging manner, which can save communication resources and improve transmission efficiency.
[0064] Further references Figure 3 , shows a process 300 of an embodiment of a method for receiving information according to the present disclosure. The method for receiving information comprises the following steps:
[0065] Step 301: Send a message synchronization instruction, wherein the message synchronization instruction includes a second identifier.
[0066] In this embodiment, the execution subject of the method for receiving information (eg Figure 1 The terminal device shown in the figure) can send a message synchronization instruction to the server via wired or wireless means, and the message synchronization instruction can carry a second identifier, wherein the second identifier can be an identifier corresponding to the message that the terminal device needs to synchronize, the second identifier can be an identifier corresponding to the message stored / existing in the terminal device, and the second identifier can also be an identifier corresponding to the latest message stored in the terminal device (the last message received / sent).
[0067] Step 302, receiving a message corresponding to a synchronization identifier in a message record; wherein the message record includes a message and an identifier corresponding to the message; and the synchronization identifier is determined according to a first identifier and a second identifier corresponding to the latest message in the message record.
[0068] In this embodiment, the terminal device can receive the message corresponding to the synchronization identifier in the message record stored by the server. The message record includes the messages uploaded by each terminal received by the server and the identifiers corresponding to each message; the synchronization identifier is determined according to the first identifier and the second identifier corresponding to the latest message in the message record stored by the server.
[0069] The method for receiving information provided in this embodiment is that a terminal device with a message synchronization requirement sends a message synchronization instruction to a server that stores message records of messages sent and received by each terminal device, and receives a message returned by the server based on the message synchronization instruction. The terminal device can receive the synchronization message based on the second identifier in the message synchronization instruction, so that the reception of the message is targeted, which can avoid wasting communication resources and reduce the storage pressure of the terminal device.
[0070] Optionally, the method for receiving information includes: receiving a message corresponding to a synchronization identifier in a message record and an operation instruction of the message; and performing an operation indicated by the operation instruction on the message.
[0071] In this embodiment, the terminal device may receive a message corresponding to the synchronization identifier in the message record stored by the server and an operation instruction of the message, and perform the operation indicated by the operation instruction on the received message.
[0072] This embodiment receives messages and operation instructions corresponding to the messages, and can enable the terminal device to perform the same operation on the received message according to the operation instruction, thereby maintaining the consistency of operations performed by the user's various terminal devices on the same message, and further improving the user's comfort and convenience when using multiple terminals to send and receive messages or process messages.
[0073] Optionally, the method for receiving information includes: before sending a message synchronization instruction next time, updating the second identifier according to the first identifier.
[0074] In this embodiment, after receiving the message sent by the server this time / before sending a message synchronization instruction to the server next time, the terminal device can use the first identifier, that is, the identifier corresponding to the latest message in the stored message record at the time node when the server receives the message synchronization instruction this time, as the identifier carried in the message synchronization instruction when sending the message synchronization instruction to the server next time.
[0075] This embodiment updates the identifier carried by the next message synchronization instruction according to the first identifier of the server when the message record is received this time, so that the server can know the identifier corresponding to the message synchronized by the terminal device, avoid the server synchronizing the same message to the terminal device, and save communication resources and storage space of the terminal device.
[0076] In some application scenarios, a user has a first device and a second device. When a friend of the user uses another device to send a message to the user's chat account, the user only uses the first device to receive the message; then, the first device sends the received message A and the corresponding version number "11" to the server that provides the offline message storage function.
[0077] Then, the user uses the second device to chat and sends a message synchronization instruction to the server. The server can send message A and the corresponding version number "11" to the second device. After that, the second device receives message B, whose corresponding version number is "12", and sends message C, whose corresponding version number is "13" to other devices used by friends; then the second device sends the received message B and the corresponding version number "12", the sent message C and the corresponding version number "13", and the collection instruction executed on message B to the server, so that the server stores the messages on each device owned by the user.
[0078] When the server uses the first device to send and receive messages again, the first device can send a message synchronization instruction to the server, and the message synchronization instruction carries the version number "11" (second identifier), that is, the version number corresponding to the latest message stored in the second device. After receiving the version number "11", the server matches it with the version number "13" (first identifier) corresponding to the latest message stored in the server. If it is determined that the two are inconsistent, the version number "13" and the version number "12" between version numbers "11" and "13" are determined as synchronization identifiers.
[0079] The server sends the message C and message B corresponding to the version numbers "13" and "12" together with the collection instruction for message B to the first device. Optionally, to avoid communication link failure or storage pressure on the first device caused by too many synchronized messages, the server can send a preset number of messages corresponding to the synchronization identifier or a preset time period to the first device.
[0080] After receiving the above information, the first device can perform a collection operation on message B locally, and the next time it sends a message synchronization instruction to the server to request synchronization of the messages stored locally with the messages in the message record stored on the server, the second identifier carried in the message synchronization instruction will be updated to version number "13" to prevent the server from repeatedly synchronizing the messages corresponding to version number "13" and previous version numbers to the second device.
[0081] Optionally, a different version number sequence (user tag) may be assigned to each user. When a specified version number sequence (specified user's version number sequence) is included in a message synchronization request, the message of the specified user is synchronized to the terminal, making the message synchronization more targeted.
[0082] Optionally, the server may periodically detect the continuity of version numbers corresponding to messages in locally stored message records. If the version numbers are discontinuous, it may be determined that there are missing messages in the message records stored by the server, and the messages corresponding to the missing version numbers that cause the version numbers to be discontinuous may be determined as missing messages.
[0083] Further references Figure 4 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a device for synchronizing messages. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0084] like Figure 4 As shown, the apparatus 400 for synchronizing messages in this embodiment includes: a first receiving unit 401, a matching unit 402, a determining unit 403, and a first sending unit 404. The first receiving unit is configured to receive a message record, wherein the message record includes a message and an identifier corresponding to the message; the matching unit is configured to determine, in response to detecting a message synchronization instruction, whether the first identifier corresponding to the latest message in the message record is consistent with the second identifier in the message synchronization instruction; the determining unit is configured to determine a synchronization identifier based on the first identifier and the second identifier in response to determining that the first identifier is inconsistent with the second identifier; and the first sending unit is configured to send a message corresponding to the synchronization identifier in the message record.
[0085] In some embodiments, the identifiers corresponding to the messages in the message record are continuous serial numbers, the second identifier includes the second serial number, and the determination unit includes: a determination module, configured to, in response to determining that the first serial number and the second serial number are inconsistent, determine the first serial number and the serial number between the first serial number and the second serial number as synchronization identifiers.
[0086] In some embodiments, the message record includes an operation instruction of the message, and the first sending unit includes: a first sending module configured to send a message corresponding to the synchronization identifier in the message record and the operation instruction of the message.
[0087] In some embodiments, the first sending unit includes: an encapsulation module configured to encapsulate the message corresponding to the synchronization identifier in the message record into a data packet; and a third sending module configured to send the data packet.
[0088] Each unit in the above device 400 is similar to the reference Figure 2 Therefore, the operations, features and technical effects described above for the method for synchronizing messages are also applicable to the device 400 and the units included therein, and will not be described in detail here.
[0089] Further references Figure 5 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a device for receiving information, and the device embodiment is Figure 3 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0090] like Figure 5 As shown, the apparatus 500 for receiving information in this embodiment includes: a second sending unit 501 and a second receiving unit 502. The second sending unit is configured to send a message synchronization instruction, wherein the message synchronization instruction includes a second identifier; the second receiving unit is configured to receive a message corresponding to the synchronization identifier in a message record; wherein the message record includes a message and an identifier corresponding to the message; the synchronization identifier is determined according to the first identifier and the second identifier corresponding to the latest message in the message record.
[0091] In some embodiments, the device includes: a receiving module configured to receive a message corresponding to a synchronization identifier in a message record and an operation instruction of the message; and an execution module configured to execute the operation indicated by the operation instruction on the message.
[0092] In some embodiments, the device further includes: an updating module configured to update the second identifier according to the first identifier before sending the message synchronization instruction next time.
[0093] Each unit in the above device 500 is similar to the reference Figure 3 Therefore, the operations, features and technical effects described above for the method for synchronizing messages are also applicable to the device 500 and the units included therein, and will not be described in detail here.
[0094] According to an embodiment of the present application, the present application also provides an electronic device and a readable storage medium.
[0095] like Figure 6 , is a block diagram of an electronic device 600 for a method for synchronizing messages according to an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.
[0096] like Figure 6As shown, the electronic device includes: one or more processors 601, a memory 602, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are interconnected using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In other embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 601 is taken as an example.
[0097] The memory 602 is a non-transient computer-readable storage medium provided in the present application. The memory stores instructions executable by at least one processor to enable the at least one processor to perform the method for synchronizing messages provided in the present application. The non-transient computer-readable storage medium of the present application stores computer instructions, which are used to enable a computer to perform the method for synchronizing messages provided in the present application.
[0098] The memory 602 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as program instructions / modules corresponding to the method for synchronizing messages in the embodiment of the present application (for example, the attached Figure 4 The processor 601 executes various functional applications and data processing of the server by running the non-transient software programs, instructions and modules stored in the memory 602, that is, implements the method for synchronizing messages in the above method embodiment.
[0099] The memory 602 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of an electronic device for synchronizing messages, etc. In addition, the memory 602 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 602 may optionally include a memory remotely arranged relative to the processor 601, and these remote memories may be connected to the electronic device for synchronizing messages via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0100] The electronic device for the method of synchronizing messages may further include: an input device 603, an output device 604, and a bus 605. The processor 601, the memory 602, the input device 603, and the output device 604 may be connected via the bus 605 or in other ways. Figure 6 The connection via bus 605 is taken as an example.
[0101] The input device 603 can receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device for synchronization messages, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick and other input devices. The output device 604 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display and a plasma display. In some embodiments, the display device may be a touch screen.
[0102] Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0103] These computer programs (also referred to as programs, software, software applications, or code) include machine instructions for programmable processors and can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or means (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0104] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0105] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0106] A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.
[0107] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the expected results of the technical solution disclosed in this application can be achieved, and this document is not limited here.
[0108] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.
Claims
1. A method for synchronizing messages, comprising: Receive a message record, wherein the message record includes a message and an identifier and an operation instruction corresponding to the message, and the operation instruction is used to indicate an operation performed on the message; In response to detecting a message synchronization instruction, determining whether a first identifier corresponding to a latest message in the message record is consistent with a second identifier in the message synchronization instruction, wherein the message synchronization instruction includes a user tag; In response to determining that the first identifier is inconsistent with the second identifier, determining a synchronization identifier according to the first identifier, the second identifier and the user tag; Sending a message corresponding to the synchronization identifier in the message record and an operation instruction of the message; The method further includes: detecting whether the sequence numbers corresponding to the messages in the message record are continuous; in response to detecting that the sequence numbers corresponding to the messages in the message record are not continuous, determining that there are missing messages in the message record, and reacquiring the messages corresponding to the missing sequence numbers; The sending of the message corresponding to the synchronization identifier in the message record includes: encapsulating the message corresponding to the synchronization identifier in the message record into a data packet; and sending the data packet.
2. The method according to claim 1, wherein: The identifiers corresponding to the messages in the message record are continuous sequence numbers, the second identifier includes a second sequence number, and in response to determining that the first identifier is inconsistent with the second identifier, determining a synchronization identifier according to the first identifier and the second identifier, comprises: In response to determining that the first sequence number is inconsistent with the second sequence number, the first sequence number and sequence numbers between the first sequence number and the second sequence number are determined as synchronization identifiers.
3. A method for receiving information, comprising: Sending a message synchronization instruction, wherein the message synchronization instruction includes a second identifier and a user tag; Receiving a message corresponding to the synchronization identifier in a message record stored by a server, and an operation instruction of the message, wherein the operation instruction is used to indicate an operation performed on the message; wherein the message record includes a message, an identifier corresponding to the message, and an operation instruction; the synchronization identifier is determined according to the first identifier corresponding to the latest message in the message record, the second identifier, and the user tag; Performing the operation indicated by the operation instruction on the message; Among them, the server detects whether the serial numbers corresponding to the messages in the message record are continuous; in response to detecting that the serial numbers corresponding to the messages in the message record are discontinuous, determines that there are missing messages in the message record, and re-acquires the messages corresponding to the missing sequence numbers; encapsulates the messages corresponding to the synchronization identifier in the message record into a data packet; and sends the data packet.
4. The method according to claim 3, wherein: The method further comprises: Before sending a message synchronization instruction next time, the second identifier is updated according to the first identifier.
5. A device for synchronizing messages, comprising: A first receiving unit is configured to receive a message record, wherein the message record includes a message and an identifier and an operation instruction corresponding to the message, and the operation instruction is used to indicate an operation performed on the message; a matching unit, configured to, in response to detecting a message synchronization instruction, determine whether a first identifier corresponding to the latest message in the message record is consistent with a second identifier in the message synchronization instruction, wherein the message synchronization instruction includes a user tag; A determining unit, configured to determine a synchronization identifier according to the first identifier, the second identifier and a user tag in response to determining that the first identifier is inconsistent with the second identifier; A first sending unit, configured to send a message corresponding to the synchronization identifier in the message record and an operation instruction of the message; The first receiving unit is further configured to: detect whether the sequence numbers corresponding to the messages in the message record are continuous; in response to detecting that the sequence numbers corresponding to the messages in the message record are not continuous, determine that there are missing messages in the message record, and re-acquire the messages corresponding to the missing sequence numbers; The first sending unit is further configured to: encapsulate the message corresponding to the synchronization identifier in the message record into a data packet; and send the data packet.
6. The device according to claim 5, wherein: The identifiers corresponding to the messages in the message record are continuous sequence numbers, the second identifiers include the second sequence numbers, and the determining unit includes: The determination module is configured to, in response to determining that the first sequence number is inconsistent with the second sequence number, determine the first sequence number and the sequence number between the first sequence number and the second sequence number as synchronization identifiers.
7. A device for receiving information, comprising: A second sending unit is configured to send a message synchronization instruction, wherein the message synchronization instruction includes a second identifier and a user tag; A second receiving unit is configured to receive a message corresponding to the synchronization identifier in a message record stored by the server, and an operation instruction of the message, wherein the operation instruction is used to indicate an operation performed on the message; wherein the message record includes a message, an identifier corresponding to the message, and an operation instruction; and the synchronization identifier is determined according to the first identifier, the second identifier, and a user tag corresponding to the latest message in the message record; An execution module, configured to execute the operation indicated by the operation instruction on the message; Among them, the server detects whether the serial numbers corresponding to the messages in the message record are continuous; in response to detecting that the serial numbers corresponding to the messages in the message record are discontinuous, determines that there are missing messages in the message record, and re-acquires the messages corresponding to the missing sequence numbers; encapsulates the messages corresponding to the synchronization identifier in the message record into a data packet; and sends the data packet.
8. The device according to claim 7, wherein: The device also includes: The updating module is configured to update the second identifier according to the first identifier before sending the message synchronization instruction next time.
9. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 4.
10. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Message synchronization method and device, storage medium and electronic equipment
CN109617949A
Data synchronization method in local area network, and apparatus and user terminal therefor
WO2017177621A1
