WO2018095175A1 - 通信消息同步方法、数据备份方法、设备及存储介质 - Google Patents

通信消息同步方法、数据备份方法、设备及存储介质 Download PDF

Info

Publication number
WO2018095175A1
WO2018095175A1 PCT/CN2017/107471 CN2017107471W WO2018095175A1 WO 2018095175 A1 WO2018095175 A1 WO 2018095175A1 CN 2017107471 W CN2017107471 W CN 2017107471W WO 2018095175 A1 WO2018095175 A1 WO 2018095175A1
Authority
WO
WIPO (PCT)
Prior art keywords
message
data
communication
session
application client
Prior art date
Application number
PCT/CN2017/107471
Other languages
English (en)
French (fr)
Inventor
陈志炯
李刚
郭咏诗
左岗
牛智昊
Original Assignee
腾讯科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Priority claimed from CN201611055670.9A external-priority patent/CN106776124B/zh
Priority claimed from CN201611056492.1A external-priority patent/CN106506674B/zh
Application filed by 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Publication of WO2018095175A1 publication Critical patent/WO2018095175A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/40Support for services or applications

Definitions

  • the embodiments of the present invention relate to the field of Internet technologies, and in particular, to a communication message synchronization method, a data backup method, a device, and a storage medium.
  • a user can log in to a social account in a different social application client.
  • the user can log in to the social account of the social application client of the mobile phone, or log in to the social application client of the computer.
  • Social account number For example, the user can log in to the social account of the social application client of the mobile phone, or log in to the social application client of the computer.
  • the first social application client may acquire the stored communication message to be synchronized, and the obtained communication message is obtained. Sync to the second social application client. In this way, the user can view the received communication message in the second social application client.
  • the first social application client and the second social application client are clients running in different platforms, for example, the first social application client runs in the mobile phone of the Android system, and the second social application client runs.
  • the first social application client runs in the mobile phone of the Android system
  • the second social application client runs.
  • the first social application client since the encapsulation format of the data is different by different platforms, after the first social application client synchronizes the communication message to the second social application client, the second social application client may not be able to parse the communication. Message.
  • the embodiment of the invention provides a communication message synchronization method, a data backup method, a device and a storage medium, which can solve the problems in the related art.
  • the technical solutions are as follows:
  • a communication message synchronization method for a first society
  • the method includes:
  • n pieces of communication messages to be synchronized in the first social application client and message types of each communication message where n is an integer greater than or equal to 1;
  • the second social application client stores n pieces of message data to the data file in units of message blocks, and generates and stores correspondences; each message block Corresponding to at least one piece of message data, and corresponding to at least two pieces of message data, communication messages corresponding to at least two pieces of message data belong to the same session, and the second social application client is of the same type and share the same type as the first social application client
  • the social account; the correspondence includes a correspondence between the message block, the session corresponding to the message block, and the storage location of the message block, and the session corresponding to the message block is the session to which the communication message corresponding to the message data in the message block belongs.
  • a communication message synchronization method for use in a second social application client, the method comprising:
  • each message data is Generating a message type including a communication message and data of the message content generated by the first social application client; each message block corresponds to at least one piece of message data, and when corresponding to at least two pieces of message data, the at least two messages The communication message corresponding to the data belongs to the same session;
  • the correspondence relationship includes a correspondence between a message block, a session corresponding to the message block, and a storage location of the message block, where the session corresponding to the message block is in the message block The session to which the communication message corresponding to the message data belongs.
  • a communication message synchronization apparatus for use in a first social application client, the apparatus comprising:
  • a first acquiring module configured to acquire n pieces of communication messages to be synchronized in the first social application client and message types of each communication message, where n is an integer greater than or equal to 1;
  • Generating a module configured, for each communication message, message data including a message type of the communication message and a message content of the communication message;
  • a synchronization module configured to synchronously generate n pieces of message data in a message block unit to a second social application client;
  • the second social application client stores n pieces of message data to the data file in a message block unit, Generating and saving a correspondence relationship;
  • each message block corresponds to at least one piece of message data, and when corresponding to at least two pieces of message data, communication messages corresponding to at least two pieces of message data belong to the same session, and the second social application client and the first
  • a social application client has the same type and shares the same social account;
  • the correspondence includes a correspondence between a message block, a session corresponding to the message block, and a storage location of the message block, and the session corresponding to the message block is message data in the message block.
  • a communication message synchronization apparatus for use in a second social application client, the apparatus comprising:
  • a first receiving module configured to receive n pieces of message data that are synchronized by the first social application client in a message block unit; the first social application client is the same type as the second social application client and shares the same social account
  • Each piece of message data is a message type including a communication message generated by the first social application client and data of the message content; each message block corresponds to at least one message data, and when corresponding to at least two message data The communication message corresponding to the at least two message data belongs to the same session;
  • a storage module configured to store the n pieces of message data to the data file in units of the message block
  • a generating module configured to generate and save a correspondence relationship, where the corresponding relationship includes a message block, a session corresponding to the message block, and a correspondence between storage locations of the message block, where the session corresponding to the message block is The session to which the communication message corresponding to the message data in the message block belongs.
  • a terminal comprising: a processor and a memory, wherein the memory stores at least one instruction, the instruction is loaded and executed by the processor to implement the following operations :
  • n communication messages to be synchronized in the first social application client and message types of each communication message, where n is an integer greater than or equal to 1;
  • a terminal comprising: a processor and a memory, wherein the memory stores at least one instruction, the instruction is loaded and executed by the processor to implement the following operations :
  • each message data is the a message type of a communication message generated by a social application client and data of the message content; each message block corresponds to at least one piece of message data, and when corresponding to at least two pieces of message data, the at least two message data The corresponding communication message belongs to the same session;
  • the correspondence relationship includes a correspondence between a message block, a session corresponding to the message block, and a storage location of the message block, where the session corresponding to the message block is in the message block The session to which the communication message corresponding to the message data belongs.
  • a computer readable storage medium having stored therein at least one instruction loaded by a processor and executed to implement the first aspect The operations performed in the method.
  • a computer readable storage medium having stored therein at least one instruction loaded by a processor and executed to implement the second aspect The operations performed in the method.
  • message data including the message type and the message content is generated, and the generated n messages are synchronously generated in units of message blocks.
  • the data is sent to the second social application client, so that the second social application client can parse the corresponding communication message according to the received message data, because the message type and the message content are included in each message data;
  • the social application client in other platforms may not be able to recognize the communication message; the effect of synchronizing communication messages across platforms is achieved.
  • a data backup method comprising:
  • the target message record being a message record generated by the target session after the backup deadline
  • the first device is configured to back up a message record of the session.
  • a data backup method is provided, where the method includes:
  • the second device is configured to send a target message record to the first device, where the target message is recorded as the target session after the backup deadline Generated message record;
  • the target message record When the target message record is received, the target message record is stored in a message record of the target session.
  • a data backup apparatus comprising:
  • a first sending module configured to send a data backup request to the first device, where the data backup request is used to indicate a target session to be backed up;
  • a receiving module configured to receive a backup deadline of the target session returned by the first device, where the backup deadline is used to indicate that the first device stores all the target sessions before the backup deadline Message record
  • a determining module configured to determine a target message record according to the backup deadline, the target message record being a message record generated by the target session after the backup deadline;
  • a second sending module configured to send the target message record to the first device, where the first device is configured to back up a message record of the session.
  • a data backup apparatus comprising:
  • An obtaining module configured to: when receiving a data backup request of the second device, obtain a backup deadline corresponding to the target session, where the data backup request is used to indicate a target session to be backed up;
  • a sending module configured to send a backup deadline of the target session to the second device, where The second device is configured to send a target message record to the first device, where the target message record is a message record generated by the target session after the backup deadline;
  • a storage module configured to store the target message record into a message record of the target session when the target message record is received.
  • a data backup device comprising: a processor and a memory, wherein the memory stores at least one instruction, the instruction being loaded and executed by the processor To achieve the following operations:
  • the target message record being a message record generated by the target session after the backup deadline
  • the first device is configured to back up a message record of the session.
  • a data backup device comprising: a processor and a memory, wherein the memory stores at least one instruction, the instruction being loaded and executed by the processor To achieve the following operations:
  • the second device is configured to send a target message record to the first device, where the target message is recorded as the target session after the backup deadline Generated message record;
  • the target message record When the target message record is received, the target message record is stored in a message record of the target session.
  • a computer readable storage medium having stored therein at least one instruction loaded by a processor and executed to implement the ninth aspect The operations performed in the described method.
  • a computer readable storage medium having stored therein at least one instruction loaded by a processor and executed The operations performed in the method as described in the tenth aspect are implemented.
  • FIG. 1 is a schematic diagram of an implementation environment involved in various embodiments of the present invention.
  • FIG. 2 is a flowchart of a method for synchronizing communication messages according to an embodiment of the present invention
  • FIG. 3A is a flowchart of a method for synchronizing communication messages according to an embodiment of the present invention
  • FIG. 3B is a schematic diagram of generated message data according to an embodiment of the present invention.
  • FIG. 3C is a schematic diagram of generated message blocks according to an embodiment of the present invention.
  • FIG. 3D is a schematic diagram of a data file according to an embodiment of the present invention.
  • FIG. 3E is a schematic diagram of a data file and an index file according to an embodiment of the present invention.
  • 4A is a flowchart of a method for synchronizing communication messages according to another embodiment of the present invention.
  • 4B is a schematic diagram of generated message data according to another embodiment of the present invention.
  • FIG. 5 is a schematic diagram of a communication message synchronization apparatus according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of a communication message synchronization apparatus according to an embodiment of the present invention.
  • FIG. 7 is a schematic diagram of a terminal according to an embodiment of the present invention.
  • FIG. 8 is a schematic diagram of device interaction for data backup according to an embodiment of the present invention.
  • 9A is a flowchart of a data backup method according to an embodiment of the present invention.
  • 9B is a flowchart of a data backup method according to an embodiment of the present invention.
  • FIG. 10A is a flowchart of a data backup method according to an embodiment of the present invention.
  • FIG. 10B is a flowchart of a data backup method according to an embodiment of the present invention.
  • FIG. 11 is a block diagram of a data backup apparatus according to an embodiment of the present invention.
  • FIG. 12 is a block diagram of a data backup apparatus according to an embodiment of the present invention.
  • FIG. 13 is a schematic structural diagram of a terminal according to an embodiment of the present disclosure.
  • FIG. 14 is a block diagram of a data backup apparatus according to an embodiment of the present invention.
  • FIG. 1 is a schematic diagram of an implementation environment involved in a method for synchronizing communication messages provided by various embodiments of the present invention.
  • the implementation environment may include a first social application client 110 , a server 120 , and The second social application client 130.
  • the first social application client 110 and the second social application client 130 are the same type of client. For example, both an instant messaging client or a mailbox at the same time. In the various embodiments described below, the first social application client 110 and the second social application client 130 share the same social account.
  • the first social application client 110 is installed in the first terminal
  • the second social application client 130 is installed in the second terminal
  • the first terminal and the second terminal may be, for example, a mobile phone, a tablet, an e-reader.
  • a terminal such as a desktop computer or a notebook computer
  • the difference between the first terminal and the second terminal is that the operating systems used by the two are different.
  • the operating system used by the first terminal may be iOS
  • the operating system used by the second terminal may be Windows
  • the operating system used by the first terminal is Android (Android)
  • the operating system used by the second terminal may be iOS. This embodiment does not limit this.
  • both the first terminal and the second terminal can be connected to the server 120 through a wired or wireless network.
  • the first terminal may also be connected to the second terminal by using Bluetooth, a local area network, a USB (Universal Serial Bus), or NFC (Near Field Communication).
  • the server 120 may be a background server corresponding to the social application client, and the server 120 may be a server or a server cluster composed of multiple servers.
  • the first social application client 110 is a client that needs to synchronize communication messages
  • the second social application client 130 is a client that receives synchronization, unless otherwise specified.
  • the first social application client 110 may actively synchronize the communication message to the second social application client 130, or synchronize the communication message to the second social application client after receiving the synchronization request sent by the second social application client 130.
  • End 130 for example, after the user logs in to the second social application client 130, the second social application client 130 can send a synchronization request to the server 120, and the server forwards the synchronization.
  • the first social application client 110 synchronizes the communication message to the second social application client 130 after receiving the synchronization request.
  • the first social application client 110 may first synchronize the communication message to the server 120, and the server 120 forwards the communication message to the second Social application client 130.
  • the first terminal where the first social application client 110 is located may also establish a direct connection with the second terminal where the second social application client 130 is located, and then directly The communication message is synchronized to the second social application client 130.
  • the first terminal and the second terminal are connected through a local area network.
  • the second social application client 130 can report the IP of the second terminal (Internet Protocol).
  • Address and port to the server 120 the server 120 forwards the IP address and port to the second social application client 130, and the second terminal establishes an IP address and port received between the first terminal and the second terminal according to the second social application client 130.
  • LAN connection the IP address and port received between the first terminal and the second terminal according to the second social application client 130.
  • FIG. 2 is a flowchart of a method for synchronizing a communication message according to an embodiment of the present invention. This embodiment is used in the application scenario shown in FIG.
  • the communication message synchronization method may include:
  • Step 201 The first social application client acquires n communication messages to be synchronized in the first social application client and a message type of each communication message, where n is an integer greater than or equal to 1.
  • the first social application client can save the communication message to the local database.
  • the communication message includes a message sent by the friend social application client to the first social application client, and a message sent by the first social application client to the friend social application client.
  • the first social application client can acquire n communication messages to be synchronized and the message type of each communication message from the local database.
  • the second social application client and the first social application client are of the same type and share the same social account, and the message type is text, picture, audio or video.
  • this step may include the following possible implementation manners:
  • the first social application client acquires a new communication message with the last synchronization time at a predetermined time, and uses the obtained communication message as the n communication messages to be synchronized.
  • the first social application client can synchronize periodically, for example, at 24:00 every day. Or synchronize at 24:00 every Sunday. In this case, the first social application client can obtain a new communication message between the current time and the last synchronization time.
  • the first social application client can obtain a new communication message from 24:00 to 24:00 on the previous day, and use the obtained communication message as n communication messages.
  • the first social application client receives the synchronization signal, and the synchronization signal requests to synchronize the new communication message of the target session within the preset time period; and acquires the newly added communication message of the target session within the preset time period.
  • the user may actively request to synchronize the communication message of a certain session for a certain period of time to the second social application client, that is, the user may apply synchronization in the first social application client.
  • the signal correspondingly, the first social application client can receive the synchronization signal, and after receiving the synchronization signal, acquire a communication message specifying the session within a specified time period.
  • the user consults the teacher with the first social application client in the mobile phone, in order to be able to view the consultation record in the second social application client of the computer, the user A synchronization signal that synchronizes the communication message during the teacher's session between 10:00 and 12:00 to the second social application client may be applied.
  • the synchronization signal may be applied by the user selecting the target session and the operation of the preset time period.
  • the first social application client provides a synchronization option, and when the user selects the selection operation of the synchronization option, the session list is provided, and the user obtains the session list.
  • the first social application client displays a plurality of communication messages in the target session and a time corresponding to each communication message, and the user determines the preset time period according to the plurality of communication messages.
  • Step 202 For each communication message, the first social application client generates message data including a message type of the communication message and a message content of the communication message.
  • the first social application client After acquiring the n communication messages, the first social application client extracts the fields used in each platform in each communication message, that is, extracts the message content of each communication message, and generates the message content and the message type. Message data.
  • each communication message will contain the message content, and in addition to the content of the message, it may also contain some data suitable for the current platform.
  • the message content can be recognized by multiple platforms, and other data than the message content may only be recognized by the current platform and cannot be recognized by other platforms, so the first social application client can be from the communication message. Extract message content for multiple platforms to generate message data.
  • Step 203 The first social application client synchronizes the generated n pieces of message data to the second social application client in units of message blocks.
  • Each message block corresponds to at least one piece of message data, and when corresponding to at least two pieces of message data, communication messages corresponding to at least two pieces of message data belong to the same session.
  • the first social application client synchronizes the generated n pieces of message data to the server in units of message blocks, and the server forwards the n pieces of message data to the second social application in units of message blocks. Client.
  • the first terminal where the first social application client is located and the second terminal where the second social application client is located may establish a direct connection, and the first social application client directly uses the message block as The unit synchronizes the n pieces of message data to the second social application client.
  • the first terminal can establish a connection with the second terminal by means of a Bluetooth, an NFC, a USB, a local area network, etc., which is not limited in this embodiment.
  • the second social application client if the second social application client is not online, the synchronization fails, and the first social application client generates the prompt information to prompt the user to the current second social application client. Not online, synchronization is not possible, and this is not limited.
  • Step 204 The second social application client receives n pieces of message data that the first social application client synchronizes in units of message blocks.
  • Step 205 The second social application client stores n pieces of message data to the data file in units of message blocks.
  • Step 206 The second social application client determines a storage location of each message block in the data file.
  • Step 207 The second social application client generates and saves the correspondence.
  • the correspondence relationship includes a correspondence between the message block, the session corresponding to the message block, and the storage location of the message block.
  • the session corresponding to the message block is the session to which the communication message corresponding to the message data in the message block belongs.
  • the communication message synchronization method generates a message type and a message content for each communication message after acquiring the n communication messages to be synchronized and the message type of each communication message.
  • the message data parses out the corresponding communication message; solves the problem that the social application client in other platforms may not recognize the communication message after synchronizing the communication message to other platforms in the related art; and the cross-platform communication message can be realized The effect of synchronization.
  • step 202 may include the following two possible implementations:
  • the first type if the message type is text, generates message data including a message type and message content; if the message type is a picture or audio and video, generates a message body including a message type and a data identifier, and generates media data including the message content.
  • the data identifier is used to point to the media data, and the message body and the media data constitute the message data. Since the data volume of pictures, audio and video is generally larger than text, and the picture or audio and video are independent of the message body, and the media data is separately generated, the data volume of the message body can be prevented from being too large.
  • FIG. 3A is a flowchart of a method for synchronizing a communication message according to an embodiment of the present invention.
  • the method is used in the application scenario shown in FIG. 1 and is generated by using the first generation manner.
  • the message data is exemplified.
  • the communication message synchronization method may include:
  • Step 301 The first social application client acquires n communication messages to be synchronized in the first social application client and a message type of each communication message, where n is an integer greater than or equal to 1.
  • This step is similar to step 201 and will not be described here.
  • Step 302 For each communication message, if the message type is text, the first social application client generates message data including a message type and message content; if the message type is a picture or audio and video, the first social application client generates The message body including the message type and the data identifier is generated, and media data including the message content is generated, the data identifier is used to point to the media data, and the message body and the media data constitute the message data.
  • the data identifier uniquely points to the media data.
  • the first social application client After acquiring the n communication messages, the first social application client extracts a field that is used in each platform in each communication message, that is, extracts the message content of each communication message, and generates a message according to the message content and the message type. data.
  • the n communication messages include 4 chat messages chat with Xiao Ming, 18 chat messages chat with Xiaohua, and 5 chat messages chat with Xiaogang.
  • 4 chat messages chat with Xiao Ming are used as an example.
  • the first social application client For each chat message, the first social application client generates the message data shown in the figure.
  • message data including the message type "text" and the message content "in” is generated, and the message type is audio chat.
  • the day message generates a message body including the message type "audio” and the data identifier "audio ID1”, and generates media data including "audio message 1", the message body and the media data constitute message data, and the data identifier "audio ID1" Point to "Audio Message 1".
  • Step 303 n communication messages are from m sessions, and for each session, the first social application client generates a message block.
  • the first social application client may generate at least one message block for the session according to the total size of the message data corresponding to each piece of communication message in the session, and/or the number of communication messages in the session.
  • the generating, by the first social application client, the at least one message block for the session according to the total size of the message data corresponding to each piece of the communication message in the session may include: the first social application client according to the media data in each piece of message data.
  • the total size generates at least one message block.
  • the maximum size of the total media data corresponding to the message block is 80M
  • the total size of the media data in the message data corresponding to each communication message in the session is 200M
  • the first social application client can Three message blocks are generated for the session, and the total size of the media data corresponding to each message block does not exceed 80M.
  • the first social application client generates a message block according to the number of communication messages in the session, and assumes that the maximum number of communication messages that can be stored in each message block is 10, and the number of communication messages in a certain session is 35.
  • the first social application client can generate 4 message blocks for the session, and no more than 10 communication messages are stored in each message block.
  • Step 304 For any communication message i in any session, if the message data of the communication message i includes the message body and the media data, the first social application client stores the message body of the communication message i in a preset order to the communication. The message i belongs to the message block corresponding to the session.
  • the preset order is a sequence of receiving the pieces of communication messages in the session.
  • Each message block corresponds to at least one piece of message data, and when corresponding to at least two pieces of message data, communication messages corresponding to at least two pieces of message data belong to the same session.
  • the first social application client stores the message data in a preset order into the message block corresponding to the session to which the communication message i belongs.
  • the first social application client can obtain the message block shown in FIG. 3C.
  • the method before storing the message data of the communication message i, the method further includes:
  • the storage condition includes: the media data corresponding to the data identifier in the message block and the total size of the media data in the message data of the communication message i fail to reach a preset size, and the message data in the message block The number of bars does not reach the preset number or both.
  • the preset size is the size set by the system or the user-defined size.
  • the preset size is 80M of the system setting.
  • the preset number can also be set by the system or the number of user-defined ones.
  • the preset number can be 2000 items set by the system.
  • the storage device includes the media data corresponding to the data identifier in the message block and the total size of the media data in the message data of the communication message i that does not reach the preset size.
  • the first social application client may obtain each of the message blocks.
  • the data identifier stored in the message body is used to count the total size of the media data in the message data corresponding to each data identifier and the message data in the communication message i, and whether the total size obtained by the statistics reaches a preset size. Wherein, if the media data is not included in the message data of the communication message i, the size of the media data in the message data of the communication message i is 0.
  • the first social application client can count the number of communication messages corresponding to the message block in the message block, and the number of the statistics obtained in the message block is up to the limit.
  • the number of presets can count the number of communication messages corresponding to the message block in the message block, and the number of the statistics obtained in the message block is up to the limit. The number of presets.
  • the first social application client can perform the foregoing two types of detections at the same time, which is not limited in this embodiment.
  • the message data corresponding to the communication message i includes the message type and the message content
  • the message data is stored to the message block
  • the message data corresponding to the communication message i includes the message body and the message.
  • the message body is stored to the message block.
  • the first social application client may store.
  • the message data is sent to the next message block corresponding to the session; when the message data corresponding to the communication message i includes the message body and the message content, the message body is stored to the next message block corresponding to the session.
  • the first social application client detects After storing the 15th message data, the total size of the media data corresponding to the message block exceeds 80M. At this time, the first social application client may store the message data corresponding to the chat message of the 15th and subsequent messages to the next.
  • the message block is stored in a similar manner to the above.
  • the step 304 is performed after the step 303 is performed first.
  • the step 303 and the step 304 may be performed crosswise.
  • the first social application client can be a message block, and when the message cannot continue to store data, a new message block is generated, and the data is stored to the newly generated message block.
  • the specific implementation manner is not limited.
  • Step 305 The first social application client synchronizes the media data corresponding to each message block and the data identifier in each message block to the second social application client.
  • the first social application client may first synchronize each message block and the media data corresponding to the data identifier in each message block to the server, and forward it to the second social application client by the server; or, A social application client is directly synchronized to the second social application client, which is not limited in this embodiment.
  • Step 306 The second social application client receives each message block synchronized by the first social application client and the media data corresponding to the data identifier in each message block.
  • Step 307 The second social application client stores each message block to the message file, and stores the media data corresponding to the data identifier in the message block to the media file, where the message file and the media file constitute a data file.
  • the size of the file is set by the terminal device when the file is read by the terminal device, and the size of the message file is set to a maximum of 2G.
  • the media file is also set with a size threshold, such as 2G. That is to say, when storing each message block to the message file, before storing a certain message block to the message file, detecting whether the sum of the size of the message file and the size of the message block reaches a size threshold, if not, then The message block is stored in the message file; if the size threshold is reached, the message block is stored to the newly generated message file, which is not limited in this embodiment.
  • the media data is not limited to the newly generated media file.
  • FIG. 3D illustrates a possible schematic diagram of message files and media files obtained by the second social application client.
  • the message file may have one or at least two, and the number of the message file is not limited in this embodiment; similarly, the media file may have one or at least two, which is also Not limited.
  • Step 308 the second social application client determines a storage location of each message block in the data file.
  • the second social application client can determine the storage location of each message block in the message file.
  • the storage location may be represented by a starting storage location and a length of the message block in the message file, or by a starting storage location of the message block in the message file and an ending storage location, which is used in this embodiment. Not limited.
  • Step 309 The second social application client determines a storage location of each media data in the media file.
  • the storage location in the media file can be represented by the starting storage location and length of the media data in the media file, or by the initial storage location of the media data in the media file and the ending storage location. This embodiment does not limit this.
  • Step 310 The second social application client generates and saves the correspondence.
  • the correspondence relationship includes a correspondence between the message block, the session corresponding to the message block, and the storage location of the message block, and the correspondence between the data identifier and the storage location of the media data in the media file, and the session corresponding to the message block is a message.
  • the starting position 2 the starting position 1 + the length 1
  • the starting position 3 the starting position 2+ the length 2
  • the starting position 4 the starting position 3 + the length 3.
  • the index file is a file for storing each correspondence.
  • FIG. 3E shows a schematic diagram of data files and index files stored by the second social application client in this embodiment.
  • the communication message synchronization method generates a message type and a message content for each communication message after acquiring the n communication messages to be synchronized and the message type of each communication message.
  • the problem of the message the effect of synchronizing the communication messages across platforms is achieved.
  • the message block By detecting whether the message block satisfies the storage condition before storing the message data, if the total size of the media data corresponding to the message block is too large, or the message block is too large, the message is resynchronized after the message block synchronization fails.
  • the network resources required for the block and the media data corresponding to the message block are not required.
  • the above method avoids the problem that a certain network resource is required in the synchronization process due to the packet header used in the package when the message data is synchronized each time.
  • FIG. 4A is a flowchart of a method for synchronizing a communication message according to an embodiment of the present invention. This embodiment is used in the application scenario shown in FIG. 1 as an example, as shown in FIG. 4A.
  • the communication message synchronization method may include:
  • Step 401 The first social application client acquires n communication messages to be synchronized in the first social application client and a message type of each communication message, where n is an integer greater than or equal to 1.
  • This step is similar to step 201 and will not be described here.
  • Step 402 For each communication message, the first social application client generates message data including a message type and message content.
  • step 302 The difference between this step and step 302 is that, in this embodiment, regardless of the message type, the first social application client directly generates message data including the message type and the message content.
  • the first social application client may generate the four pieces of message data shown in FIG. 4B.
  • n communication messages are from m sessions, and for each session, the first social application client generates a message block.
  • Step 404 For any communication message i in any session, store the message data of the communication message i in a preset order into the message block corresponding to the session to which the communication message i belongs.
  • This step is similar to the step 304. The difference is that, in the step 304, the message body is stored to the message block, and the message data is directly stored in the message block in the embodiment, and details are not described herein again.
  • Step 405 The first social application client synchronizes each message block to the second social application client.
  • Step 406 The second social application client receives each message block of the first social application client synchronization.
  • step 407 the second social application client stores each message block to the data file.
  • Step 408 The second social application client determines a storage location of each message block in the data file.
  • Step 409 The second social application client generates and saves the correspondence.
  • the communication message synchronization method generates a message type and a message content for each communication message after acquiring the n communication messages to be synchronized and the message type of each communication message.
  • the message data parses out the corresponding communication message; solves the problem that the social application client in other platforms may not recognize the communication message after synchronizing the communication message to other platforms in the related art; and the cross-platform communication message can be realized The effect of synchronization.
  • the problem of requiring a certain amount of network resources in the synchronization process due to the packet header used in the encapsulation is avoided every time the message data is synchronized.
  • the first social application client may perform the following steps before the first social application client synchronizes the message data corresponding to the message block to the second social application client:
  • the starting time of the time information is the receiving time of the communication message corresponding to the first message data in the message block, and the ending time of the time information is the last message data in the message block.
  • the receiving time of the corresponding communication message is the receiving time of the corresponding communication message.
  • the time information corresponding to the message block is the time for receiving the communication message, which is not limited in this embodiment.
  • the four chat messages chat with Xiao Ming are taken as an example.
  • the time of the first chat message is 15:31:20
  • the time of the fourth chat message is 15:33:35, then the message corresponding to the 4 chat messages.
  • the time information of block 1 is 15:31:20 to 15:33:35.
  • the time information corresponding to the message block is synchronized to the second social application client.
  • the generated first correspondence includes a message block, a session corresponding to the message block, a storage location of the message block, and a time period corresponding to the message block. Correspondence between the two.
  • the second social application client may perform the following steps:
  • the second social application client determines the timestamp information of each session according to the saved correspondence, and the timestamp information is the communication corresponding to the last message data in each session determined by the second social application client according to the saved correspondence. The time the message was received.
  • the second social interaction is included in the correspondence relationship stored in the second social application client, including the message block, the session corresponding to the message block, the time information corresponding to the message block, and the corresponding storage location of the message block.
  • the application client can determine the timestamp information of each session according to each corresponding relationship stored.
  • the second social application client determines that the timestamp information obtained is 9:30:37.
  • the second social application client sends the timestamp information to the first social application client.
  • the first social application client receives the timestamp information of each session sent by the second social application client.
  • the first social application client acquires each piece of communication message in the session received after the timestamp information according to the timestamp information of the session, and acquires the message type of each piece of communication message.
  • the user logs in to the second social application client in a PC (Personal Computer), and the second social application client reports the IP address and port of the PC to the server; the server detects the first in the mobile phone.
  • the social application client is online, if online, send The IP address and port of the PC are connected to the mobile phone, and the mobile phone establishes a direct connection with the PC after receiving the IP address and port.
  • the PC determines the timestamp information of each session according to the locally stored index file, and sends the timestamp information to the mobile phone through the established direct connection. After receiving the timestamp information, the mobile phone obtains the timestamp information in each session according to each timestamp information.
  • the communication message is added, and the message data corresponding to each communication message is generated, and the generated n pieces of message data are synchronously generated in the message block unit to the second social application client.
  • the second social application client After receiving the second social application client, the second social application client stores the data file, creates and saves the corresponding relationship. If the detection result of the server is that the first social application client is not online, the second social application client is prompted to fail the synchronization at this time.
  • the first social application client may also assign a serial number to each communication message, and synchronize the message block to the second social application client. And synchronizing the sequence number range corresponding to the message block to the second social application client. That is, the sequence number of the last communication message in each message block may be saved in the second social application client, so that after the second social application client goes online, the second social application client may send the last communication message of each session.
  • the serial number is sent to the first social application client, and the first social application client obtains, according to the serial number, each communication message whose sequence number is after the serial number, and the specific implementation of the embodiment is not limited.
  • the second point that needs to be added is that the first social application client can also obtain session information of each session, such as a nickname, a comment, and the like of the session, and then synchronize the message data to the second social application client in units of message blocks.
  • the session information corresponding to the message block is synchronized to the second social application client.
  • the second social application client can receive the session message and store the session information in the index file, which is not limited in this embodiment.
  • the third point that needs to be added is that before the first social application client synchronizes the n pieces of message data to the second social application client, in order to ensure the security of the data transmission, the first social application client may also first n pieces.
  • the message data is encrypted.
  • the first social application client may send a key acquisition request to the server, receive a key returned by the server, and encrypt the message data according to the received key. After the social application client of the different account sends the key acquisition request to the server, the obtained key may be different.
  • the first social application client may further store the public key, and send a key acquisition request carrying the public key when the key acquisition request is sent, and the server acquires the key acquisition request after receiving the key acquisition request.
  • the encryption method corresponding to the public key, and the obtained encryption method is fed to the A social application client, the first social application client performs encryption according to the received encryption method.
  • the first social application client may encrypt the n message data in units of message blocks, which is not limited thereto. In this way, when the second social application client needs to re-establish the communication message corresponding to the message data, the second social application client also needs to obtain the decryption key from the server or obtain the decryption method in a similar manner. Not limited.
  • the foregoing communication message synchronization method may further include the following steps:
  • the second social application client reconstructs each communication message corresponding to each message block according to the saved correspondence.
  • the second social application client may read the content in the message block corresponding to the session according to the saved correspondence, and include in the message block.
  • the corresponding media data is read from the media file according to the correspondence between the data identifier and the storage location of the media data in the media file, and thereafter, each piece of communication message can be reconstructed.
  • the second social application client may first read the corresponding relationship from the index file storing the corresponding relationship, and then re-establish the communication message according to the read correspondence, which is not limited in this embodiment.
  • the second social application client can find the storage location of the corresponding message block 1 as the starting position 1+length 1 according to the session 'Xiaoming'. And reading the content of the message block 1 from the storage location, that is, the content shown in FIG. 3C, and thereafter, according to the correspondence between the data identifier and the storage location of the media data, the content can be read from the media file.
  • the audio message 1 and the audio message 2 in Fig. 3C in this way, the chat record with Xiao Ming can be recovered.
  • the correspondence also includes a correspondence between the message block and the data identifier in the message body in the message block.
  • the second social application client can also generate the correspondence shown in the following table.
  • the corresponding media data can be read without waiting for the individual entries in the message block to be traversed.
  • the problem that the reconstruction efficiency of the communication message is low is that the data identifier can be directly read according to the stored correspondence relationship, and the corresponding media data is quickly loaded, thereby improving the reconstruction efficiency of the communication message.
  • the second social application client can display the communication message corresponding to the session in the session window.
  • the second social application client may sort the communication messages in a sequence from the morning to the night according to the receiving time of each communication message, and when the second social application client opens the session window, the receiving time is from early to early.
  • the late sequence displays each communication message, and the user triggers the up and down sliding operation, and can also switch the displayed communication message so that the user can browse different communication messages.
  • the fifth point that needs to be added is that the foregoing is only the second social application client directly storing the message data to the data file in units of message blocks.
  • the second social application client may also receive the received
  • the message data in the unit of the message block is divided into smaller-sized message blocks, or merged into a larger-sized message block.
  • the merging into the same session corresponds to one message block, which is not limited in this embodiment.
  • the sixth point of the supplementary description is that the step of the first social application client side in the foregoing embodiment may be separately implemented as the communication message synchronization method of the first social application client side, and regarding the second social application client side.
  • the step may be separately implemented as a communication message synchronization method on the client side of the second social application.
  • FIG. 5 is a schematic structural diagram of a communication message synchronization apparatus according to an embodiment of the present invention.
  • the communication message synchronization apparatus is used in the first social application client shown in FIG. 1.
  • the communication message synchronization apparatus may include: a first acquisition module 510, a generation module 520, and a synchronization module 530.
  • the first obtaining module 510 is configured to acquire n pieces of communication messages to be synchronized in the first social application client and message types of each communication message, where n is an integer greater than or equal to 1;
  • a generating module 520 configured to generate, for each communication message, message data including a message type of the communication message and a message content of the communication message;
  • the synchronization module 530 is configured to synchronously generate the n pieces of message data to the second social application client in units of message blocks; the second social application client stores the n pieces of message data to the data file in units of message blocks, and generates and saves the corresponding a relationship; each message block corresponds to at least one piece of message data, and when corresponding to at least two pieces of message data, communication messages corresponding to at least two pieces of message data belong to the same session, and the second social application client and the first social application client
  • the end types are the same and share the same social account; the correspondence includes the correspondence between the message block, the session corresponding to the message block, and the storage location of the message block.
  • the session corresponding to the message block is the session to which the communication message corresponding to the message data in the message block belongs.
  • the communication message synchronization apparatus generates a message type and a message content for each communication message after acquiring the n communication messages to be synchronized and the message type of each communication message.
  • the message data parses out the corresponding communication message; solves the problem that the social application client in other platforms may not recognize the communication message after synchronizing the communication message to other platforms in the related art; and the cross-platform communication message can be realized The effect of synchronization.
  • the generating module 520 is further configured to generate a message body including the message type and the data identifier, and generate Media data including the message content, the data identifier is used to point to the media data, and the message body and the media data constitute the message data.
  • the synchronization module 530 includes:
  • a synchronization unit for any communication message i in any session, if the message data of the communication message i includes a message body and media data, storing the message body of the communication message i in a preset order to the In the message block corresponding to the session to which the communication message i belongs, when synchronizing the message data of the communication message i, synchronizing the message block corresponding to the session to which the communication message i belongs and the media data of the communication message i to the second
  • the preset order is a sequence of receiving communication messages.
  • the synchronization module 530 includes:
  • a synchronization unit configured to store the message data of the communication message i in a preset order to a message block corresponding to the session to which the communication message i belongs, for any communication message i in any session, in synchronizing the communication
  • the message block corresponding to the session to which the communication message i belongs is synchronized to the second social application client, and the preset sequence is a sequence of receiving the communication message.
  • the generating unit is further configured to: according to the message corresponding to each piece of communication message in the session The total size of the data, and/or the number of communication messages in the session, generates at least one message block for the session.
  • the device further includes:
  • a second acquiring module configured to acquire time information corresponding to each message block, where a start time of the time information is a receiving time of a communication message corresponding to the first message data in the message block, and the time information The ending time is the receiving time of the communication message corresponding to the last message data in the message block;
  • the synchronization module 530 is further configured to synchronize time information corresponding to the message block to the second social application client when synchronizing each message block to the second social application client.
  • the first obtaining module 510 includes:
  • a receiving unit configured to receive timestamp information of each session sent by the second social application client, where the timestamp information is a last message in each session determined by the second social application client according to the saved correspondence relationship The receiving time of the communication message corresponding to the data;
  • an obtaining unit configured to acquire, according to the timestamp information of the session, each piece of communication messages in the session received after the timestamp information, and obtain a message type of each piece of communication message, for each session.
  • FIG. 6 is a schematic structural diagram of a communication message synchronization apparatus according to an embodiment of the present invention.
  • the communication message synchronization apparatus is used in the second social application client shown in FIG. 1 .
  • the communication message synchronization apparatus may include: a first receiving module 610, a storage module 620, and a generating module 630.
  • the first receiving module 610 is configured to receive n pieces of message data that are synchronized by the first social application client in a message block unit; the first social application client is the same type as the second social application client and shares the same social An account number; each piece of message data is a message type including a communication message generated by the first social application client and data of the message content; each message block corresponds to at least one message data, and corresponds to at least two message data The communication message corresponding to the at least two message data belongs to the same session;
  • the storage module 620 is configured to store the n pieces of message data to the data file in units of the message block;
  • a generating module 630 configured to generate and save a correspondence relationship, where the correspondence relationship includes a message block, a session corresponding to the message block, and a correspondence between storage locations of the message block, the message
  • the session corresponding to the block is the session to which the communication message corresponding to the message data in the message block belongs.
  • the communication message synchronization apparatus generates a message type and a message content for each communication message after acquiring the n communication messages to be synchronized and the message type of each communication message.
  • the message data parses out the corresponding communication message; solves the problem that the social application client in other platforms may not recognize the communication message after synchronizing the communication message to other platforms in the related art; and the cross-platform communication message can be realized The effect of synchronization.
  • the communication message synchronization device provided according to the above embodiment, optionally,
  • the first receiving module 610 is further configured to receive, by the first social application client, each message block that is synchronized by the first social application client and the media data corresponding to the data identifier in the message block, where the message block includes a message body, The message body includes a message type of the communication message and a data identifier, where the media data includes a message content of the communication message, and the data identifier points to the media data;
  • the storage module 620 is further configured to store each message block to the message file, and store the media data corresponding to the data identifier in the message block to the media file, where the message file and the media file constitute the data file;
  • the correspondence further includes a correspondence between the data identifier and a storage location of the media data in the media file.
  • the correspondence further includes a correspondence between the message block and the data identifier in the message body in the message block.
  • the device further includes:
  • a second receiving module configured to receive time information corresponding to each message block that is synchronized by the first social application client; a start time of the time information is corresponding to a first message data in the message block a receiving time of the communication message, where the ending time of the time information is a receiving time of the communication message corresponding to the last message data in the message block;
  • the correspondence further includes a correspondence between the message block and time information corresponding to the message block.
  • the device further includes:
  • a determining module configured to determine timestamp information of each session according to the saved correspondence, where the timestamp information is determined by the second social application client according to the saved correspondence relationship The receiving time of the communication message corresponding to the last message data in the sentence;
  • a sending module configured to send the timestamp information to the first social application client.
  • the communication message synchronization device provided by the foregoing embodiment is only illustrated by the division of each functional module. In an actual application, the function distribution may be completed by different functional modules as needed, that is, the social application client. The internal structure of the end is divided into different functional modules to perform all or part of the functions described above.
  • the embodiment of the communication message synchronization device and the communication message synchronization method provided by the foregoing embodiments are in the same concept, and the specific implementation process is described in detail in the method embodiment, and details are not described herein again.
  • the embodiment of the present invention further provides a computer readable storage medium, which may be a computer readable storage medium included in the memory in the above embodiment; or may exist separately and not assembled into the terminal.
  • Computer readable storage medium stores one or more programs that are used by one or more processors to perform a communication message synchronization method.
  • FIG. 7 is a block diagram of a terminal 700 according to an embodiment of the present invention.
  • the terminal may include a radio frequency (RF) circuit 701, a memory 702 including one or more computer readable storage media, and an input unit 703.
  • RF radio frequency
  • the terminal structure shown in FIG. 7 does not constitute a limitation to the terminal, and may include more or less components than those illustrated, or a combination of certain components, or different component arrangements. among them:
  • the RF circuit 701 can be used for transmitting and receiving information or during a call, and receiving and transmitting signals. Specifically, after receiving downlink information of the base station, the downlink information is processed by one or more processors 708. In addition, the data related to the uplink is sent to the base station. .
  • the RF circuit 701 includes, but is not limited to, an antenna, at least one amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, and a low noise amplifier (LNA, Low Noise Amplifier), duplexer, etc. In addition, the RF circuit 701 can also communicate with the network and other devices through wireless communication.
  • SIM Subscriber Identity Module
  • LNA Low Noise Amplifier
  • the wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (GSM), General Packet Radio Service (GPRS, General Packet Radio Service), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), e-mail, short message service (SMS, Short Messaging Service), etc.
  • GSM Global System of Mobile communication
  • GPRS General Packet Radio Service
  • CDMA Code Division Multiple Access
  • WCDMA Wideband Code Division Multiple Access
  • LTE Long Term Evolution
  • SMS Short Messaging Service
  • the memory 702 can be used to store software programs and modules, and the processor 708 executes various functional applications and data processing by running software programs and modules stored in the memory 702.
  • the memory 702 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application required for at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may be stored according to Data created by the use of the terminal (such as audio data, phone book, etc.).
  • memory 702 can include high speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, memory 702 may also include a memory controller to provide access to memory 702 by processor 708 and input unit 703.
  • the input unit 703 can be configured to receive input numeric or character information and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.
  • input unit 703 can include a touch-sensitive surface as well as other input devices.
  • Touch-sensitive surfaces also known as touch screens or trackpads, collect touch operations on or near the user (such as the user using a finger, stylus, etc., any suitable object or accessory on a touch-sensitive surface or touch-sensitive Operation near the surface), and drive the corresponding connecting device according to a preset program.
  • the touch sensitive surface may include two parts of a touch detection device and a touch controller.
  • the touch detection device detects the touch orientation of the user, and detects a signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts the touch information into contact coordinates, and sends the touch information.
  • the processor 708 is provided and can receive commands from the processor 708 and execute them.
  • touch-sensitive surfaces can be implemented in a variety of types, including resistive, capacitive, infrared, and surface acoustic waves.
  • the input unit 703 can also include other input devices. Specifically, other input devices may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control buttons, switch buttons, etc.), trackballs, mice, joysticks, and the like.
  • Display unit 704 can be used to display information entered by the user or information provided to the user, as well as various graphical user interfaces of the terminal, which can be composed of graphics, text, icons, video, and any combination thereof.
  • the display unit 704 can include a display panel.
  • a liquid crystal display (LCD) or an organic light emitting diode (OLED, Organic) can be used.
  • the touch-sensitive surface can cover the display panel, and when the touch-sensitive surface detects a touch operation thereon or nearby, it is transmitted to the processor 708 to determine the type of the touch event, and then the processor 708 displays the type according to the type of the touch event.
  • a corresponding visual output is provided on the panel.
  • the touch-sensitive surface and display panel are implemented as two separate components to perform input and input functions, in some embodiments, the touch-sensitive surface can be integrated with the display panel to implement input and output functions.
  • the terminal may also include at least one type of sensor 705, such as a light sensor, motion sensor, and other sensors.
  • the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel according to the brightness of the ambient light, and the proximity sensor may close the display panel and/or the backlight when the terminal moves to the ear.
  • the gravity acceleration sensor can detect the magnitude of acceleration in all directions (usually three axes). When it is stationary, it can detect the magnitude and direction of gravity.
  • the terminal can also be configured with gyroscopes, barometers, hygrometers, thermometers, infrared sensors and other sensors, no longer Narration.
  • the audio circuit 706, the speaker, and the microphone provide an audio interface between the user and the terminal.
  • the audio circuit 706 can transmit the converted electrical signal of the audio data to the speaker, and convert it into a sound signal output by the speaker; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 706 and then converted.
  • the audio data is then processed by the audio data output processor 708, sent via RF circuitry 701 to, for example, another terminal, or the audio data is output to memory 702 for further processing.
  • the audio circuit 706 may also include an earbud jack to provide communication between the peripheral earphone and the terminal.
  • WiFi is a short-range wireless transmission technology.
  • the terminal can help users to send and receive emails, browse web pages, and access streaming media through the WiFi module 707. It provides wireless broadband Internet access for users.
  • FIG. 7 shows the WiFi module 707, it can be understood that it does not belong to the necessary configuration of the terminal, and may be omitted as needed within the scope of not changing the essence of the invention.
  • the processor 708 is the control center of the terminal, which connects various portions of the entire handset using various interfaces and lines, by executing or executing software programs and/or modules stored in the memory 702, and invoking data stored in the memory 702, executing The various functions of the terminal and processing data to monitor the mobile phone as a whole.
  • the processor 709 may include one or more processing cores; preferably, the processor 708 may integrate an application processor and a modem processor, where the application processor mainly processes an operating system, a user interface, an application, and the like.
  • the modem processor primarily handles wireless communications. Understand The above modem processor may also not be integrated into the processor 708.
  • the terminal also includes a power source 709 (such as a battery) that supplies power to the various components.
  • the power source can be logically coupled to the processor 709 through the power management system to manage functions such as charging, discharging, and power management through the power management system.
  • the power supply 709 can also include any one or more of a DC or AC power source, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.
  • the terminal may further include a camera, a Bluetooth module, and the like, and details are not described herein again.
  • the processor 708 in the terminal runs one or more program instructions stored in the memory 702, thereby implementing the communication message synchronization method provided in the foregoing various method embodiments.
  • FIG. 8 is a schematic diagram of device interaction for data backup according to an embodiment of the present invention.
  • the device includes a first device and a second device, where the first device is a data backup target device, and the second device is data.
  • the source device of the backup is a data backup target device.
  • the second device may be a mobile phone, a tablet computer, a desktop computer, or the like.
  • the second device is installed with an application, and the application may be a social application, a multimedia application, or the like, and the application generates various data during the use process.
  • the first device may be a terminal such as a mobile phone, a tablet computer, or a desktop computer, and the first device may also be a server.
  • the first device may also be installed with the same application as the second device, or the first device may be installed with an application having the application backup function.
  • the operating system of the first device and the second device may be the same or different, which is not limited by the embodiment of the present invention.
  • the data backup in this embodiment is used to back up the data applied on the second device.
  • the application that needs to be backed up on the second device is referred to as a target application.
  • the data flow required to be backed up in this embodiment may be from the terminal to the terminal, or from the terminal to the server.
  • FIG. 9A For detailed data backup process, refer to the specific implementation provided in FIG. 9A below. example.
  • FIG. 9A is a flowchart of a data backup method according to an embodiment of the present invention.
  • an interaction entity involves a first device and a second device, where the method includes:
  • the second device acquires device information of the first device, and establishes a connection with the first device according to the device information.
  • the first device and the second device when both the first device and the second device are terminals, the first device and the second device may be in the same local area network, and the two may establish a connection by using a wired or wireless manner.
  • the wired connection method includes a USB connection, a direct connection of a network cable, and the like.
  • Wireless connection method includes WiFi (Wireless Fidelity, Wi-Fi connection, Bluetooth connection, etc.
  • the first device may be installed with the target application in the same manner as the second device, or may not be installed with the target application.
  • the user can trigger the data backup process by using the first device.
  • a data backup option for implementing data backup can be provided on the function interface of the target application, so that the user can click the data backup.
  • the first device may be installed with a specified application that provides a backup service for the target application, and the designated application has a data backup option of the target application backup, so that the user can click the data. Backup options to trigger the data backup process.
  • the user can also trigger the data backup process by using the second device.
  • the second device detects the triggering operation of the data backup option of the target application
  • the user displays a session list of the target application, and the user can select a required list in the session list.
  • the target session of the backup when the second device detects the selection confirmation operation of the target session, the data backup process is triggered.
  • the user can select session 1 and session 2 as the target session in the conversation list.
  • the second device may automatically trigger the backup according to the preset period.
  • the preset period may be preset or changed by the server or the second device, which is not limited in this embodiment.
  • the first device detects whether a connection has been established with the second device, and if the connection is not established, performs a process of establishing a connection with the second device. If the connection has been established, the backup instruction is sent to the second device, and after the backup command is received by the second device, step 902 is performed.
  • the second device After the data backup process is triggered on the first device, the second device needs to establish a connection with the first device to perform data backup.
  • the second device may establish a connection with the first device by acquiring the device information of the first device.
  • the device information of the first device includes an IP address of the first device and a port number that provides a data backup service.
  • the manner in which the second device acquires the device information of the first device may include any one of the following three types:
  • the second device acquires device information of the first device by using a server.
  • the server sends a backup process initiation message to the server, where the backup process initiation message carries the device information of the first device and the first account of the login target application.
  • the server sends a backup process initiation indication to the second device that is logged in to the same account according to the first account, where the backup process initiation indication carries the device information of the first device, thereby making the second device Get the device information of the first device.
  • the backup process initiation indication may also not carry the device information of the first device, but the device information of the first device is pulled from the server after receiving the indication of the backup process by the second device, which is used by the embodiment of the present invention. Not limited.
  • the second device acquires device information of the first device by using a device information broadcast message of the first device.
  • the first device may be installed with or without the target application.
  • the device information is broadcasted in the local area network, and when the second device is in the same local area network as the first device, the device information can be monitored through the local area network. Broadcasting a message, thereby extracting device information of the first device from the device information broadcast message.
  • the second device acquires device information of the first device by using the two-dimensional code scan.
  • the first device may be installed with or without the target application.
  • the two-dimensional code is generated according to the device information of the first device.
  • the second device acquires device information of the first device by scanning the two-dimensional code.
  • the data backup process can be regarded as a process of target application data synchronization.
  • the second device may also obtain the first account of the first device login target application.
  • the first device may also broadcast the first account, so that the second device obtains the first account.
  • the second account generated by the first device may include the first account, and the second device obtains the first account by scanning the two-dimensional code.
  • the second device After obtaining the first account, the second device compares with the second account of the local login target application, and if the two are the same, establish a connection with the first device; if not, refuse to establish a connection with the first device, and at the same time, The second device may display different prompt information of the account to prompt the user that the data backup may be at risk.
  • the second device may establish a direct connection with the first device in the same local area network by using a wired or wireless manner.
  • the process of establishing the connection may be: the second device is configured according to the IP address of the first device. Address, sending a data connection request to the first device. If the first device receives the data connection request, it will return a response message to the second device. If the second device receives the response message of the first device, it indicates that the two devices are in the same local area network, and the connection can be established directly, and the second device establishes a connection with the first device. If the second device does not receive the response message of the first device, it is determined that the first device is not in the same local area network, and the direct connection cannot be established.
  • the second device displays the network connection prompt information, and the network connection prompt information is used to indicate that the second device is in a different local area network than the first device, for example, the network connection prompt information may be, for example, “ Please connect the two devices to the same LAN and other information.
  • the first device may not receive the data of the second device because of a network failure (such as the network cable is not plugged in, or the router is faulty).
  • the connection request is made, or the second device does not receive the response message that the first device has returned. Therefore, in order to reflect the true connection situation to the user, to improve the success rate of the connection, the second device may perform the following steps when the response message is not received: according to the IP address and the local IP address of the first device, Whether the two devices are on the same local area network. For example, the second device detects whether the IP address of the first device and the network number of the local IP address are the same.
  • the first device is in the same local area network.
  • the network number is used to indicate the local area network identifier of the device IP address.
  • the device information of the first device may further include the first device.
  • the second device can determine whether it is on the same local area network as the first device by comparing the SSID of the first device with the local SSID. For example, when the SSIDs of the two are different, it is determined that the two are not in the same local area network. At this time, the second device displays the network connection prompt information.
  • the network connection prompt information may be used to indicate that the device is connected to the same WiFi, for example.
  • Such information as "Please connect two devices to the same WiFi", such a prompt can make some users who do not understand the LAN concept, can also connect the two devices to the same LAN through prompts, improve the data backup
  • the universality of the method enhances operability.
  • the second device in the second manner of acquiring the device information of the first device, because the device information of the first device is broadcasted through the local area network, when the second device receives the device information of the first device, It can be determined that the first device is in the same local area network, and the connection can be established directly with the first device according to the obtained device information.
  • the data transmission speed in the data backup process is greatly improved, the efficiency of data backup is improved, and the network stability is good because the local area network is not susceptible to external interference. Therefore, the reliability of data transmission is improved, and the problem of reduced backup efficiency due to packet loss is avoided.
  • FIG. 9B shows a flow chart of data backup based on the above first manner, in FIG. 9B as the first
  • the device detects the triggering operation of the data backup option
  • the device sends a backup process initiation message to the server, where the backup process initiation message carries the device information of the first device and the first account of the login target application.
  • the other flow of Figure 9B will be described in a subsequent step.
  • the data exchanged between the first device and the second device is encrypted data.
  • the first device detects whether the local key buffer is stored. The key, if the key is not stored locally, the first device can obtain the key from the server. The second device may also obtain the same key from the server, and the first device and the second device may use the key to encrypt data sent to the peer end, and when receiving the data of the peer end, the key may be used. Decrypt.
  • the first device and the second device may also exchange a password for password verification.
  • the password verification process may be: the second device sends a password authentication message (Packet Authenticate Request) to the first device.
  • the password verification message carries the first password to be verified (such as a hello password).
  • the first device detects that the first password is stored locally, and confirms that the password verification for the second device is successful.
  • a password authentication success message (Packet Authenticate Response) to the second device, and carrying a second password (such as an ok password) to be verified in the password verification success message, after the second device receives the second password, if it detects If the second password is stored locally, it is confirmed that the password verification of the first device is successful, and the password verification success message is returned to the first device, and the password verification success message may also be carried by the Packet Authenticate Request message.
  • the first device may return a password verification confirmation message to indicate that the verification process ends, and the confirmation message may also be carried by the Packet Authenticate Response message.
  • the first password and the second password may be respectively configured by the server to the second device and the first device.
  • the first device (or the second device) provided in this embodiment may further perform data backup based on the progress of the backup when the transmission is interrupted during the data backup process;
  • data recovery can be provided, and data recovery resumes based on the progress of the interrupt recovery when a transmission interruption occurs during data recovery.
  • a corresponding function option may be provided on the first device (or the second device), or a corresponding function option may be provided on the function interface of the target application, so that the user can trigger the corresponding process.
  • the second device When the user triggers a certain process by using the first device, in order to make the second device clear which process is currently triggered, after the first device and the second device establish a connection, send a process type indication (Backup Command Request) to the second device, where The process type indication is used to indicate data backup, continue backup, data recovery, and resume recovery. One of the complex ones.
  • the second device returns a confirmation response message (Backup Command Response) after receiving the flow type indication.
  • the second device may further send a ready indication to the first device, where the ready indication may also be carried by the Backup Command Request message, and the first device returns the confirmation response message after receiving the ready indication ( Backup Command Response).
  • the second device sends a data backup request to the first device, where the data backup request is used to indicate the target session to be backed up.
  • the second device may perform data transmission with the first device. It should be noted that the data transmission in the step and the subsequent step are based on the connection, and the description in the subsequent steps is not repeated.
  • the second device After determining that the connection with the first device is successfully established, the second device enters a data backup process. For example, the second device may display a target session selection interface, where the target session selection interface includes a session list of the target application, where the session list includes multiple Session options, each session option includes the session ID, avatar and selection box of the session, and the user can select the target session to be backed up by clicking the selection box.
  • the session list displayed in the target session selection interface may include only sessions in which the message record is not zero, and further, corresponding to each, because there is no need to back up the session with the message record of zero.
  • the session can also display the size of the message record contained in the session, such as 5M.
  • the second device may also send a backup start message to the first device before the data backup request is sent, after the first device returns a confirmation start message (Backup Start Response). And then send a data backup request, the data backup request can be carried by the Backup Request Session message.
  • the number of the target sessions may be one or more, which is not limited in this embodiment.
  • the data backup request is sent to the first device, and the data backup request may include the session identifier of the target session.
  • the session identifier may be a nickname, an account number, and the like of the peer end.
  • the session identifier may be a group name or the like.
  • the message record of the session refers to data such as text, picture, voice, and video that are exchanged between the session end and the session peer.
  • Each message record includes the generation time of the message record, and the type of the message record includes a text message record and a media message record.
  • media message records include pictures, voice and video.
  • the media message record includes the corresponding media message itself and description information thereof, and the description information is used to describe the message identifier, media type, generation time, and media of the corresponding media message. Volume message size, etc.
  • the first device receives the data backup request of the second device, obtain a backup deadline corresponding to the target session.
  • the first device stores a correspondence between a backup deadline of the backup message record and the session identifier.
  • the first device may query the stored correspondence according to the session identifier of the target session to obtain a backup deadline of the target session.
  • the correspondence can be as shown in Table 1.
  • the storage relationship of the session identifier corresponding session may be stored in the correspondence, so that the first device can directly determine the storage area of a session by using the corresponding relationship.
  • the first device sends a backup deadline of the target session to the second device.
  • the first device returns a backup deadline corresponding to the session for each session.
  • the target session includes only one session as an example.
  • the backup deadline of the target session may be carried by the backup request session (Reply Request Session Response), and the specific bearer mode is not limited in the embodiment of the present invention.
  • the second device determines a target message record according to a backup deadline of the target session, where the target message records a message record generated by the target session after the backup deadline.
  • the message records included in the session are arranged in order of generation time from first to last.
  • the second device extracts the message record generated after the backup deadline according to the backup deadline of the target session. Specifically, the second device may compare the generation time of the message record in the target session with the backup deadline according to the generation time from the first to the last, until the first message with the generation time later than the backup deadline is obtained. The record determines the first message record and the subsequent message record as the target message record. Of course, the second device may also compare the generation time of the message record in the target session with the backup deadline according to the order of the generation time until the generation time is equal to or earlier than the backup deadline. The second message record determines the message record after the second message record as the target message record.
  • the second device determines that the target session does not generate after the backup deadline
  • the new message record determines that the target session has no data to be backed up.
  • the second device may send a backup completion message to the first device to end the backup process. If the number of the target sessions is multiple, the second device determines that each target session does not generate a new message record after the corresponding backup deadline, and sends a backup completion message to the first device to end the backup process.
  • the backup completion message may be carried by a Backup Finish Request message. If the second device acquires the target message record of the target session, the target message record is sent to the first device, the process comprising the following steps 906 to 908.
  • the second device divides the target message record into at least one message set according to a generation time of the message record from first to last.
  • the second device can divide the message record to be backed up into one or more message sets.
  • the message set may include a text message set and a media message set.
  • the text message set includes description information of the text message record and the media message record, and each description information is used to indicate the corresponding media message record.
  • Media message records are included in the media message collection.
  • the second device combines the description information of the text message record and the media message record in the target message into a text message set according to the generation time from the first to the last, and combines the media message records into the media message set. For example, the second device acquires each message record in the target message record in a first-to-last order according to the generation time. If the message record is a text message record, the text message record is added to the text message set, if the message record For the media message record, the description information of the media message record is added to the text message set, and the media message record is added to the media message set.
  • the message set can be divided in the following two ways on the basis of chronological order:
  • the first way is to divide the message set based on the preset size.
  • the preset size may be configured or changed in advance, which is not limited in this embodiment.
  • the preset size may be 80M, so that the second device may divide the text message record into multiple text message sets, and divide the media message record into multiple media message sets.
  • the division of the message set is divided into two cases:
  • the text message record is added to Before the text message set, comparing the total size of the text message set and the media message record indicated by the text message set with the preset size, if the total size is less than the preset size, adding the text message record Go to the text message collection; otherwise, add the text message record to a new text message collection.
  • the second device may also record a media message as a set of media messages, which is not limited in this embodiment.
  • the message set is divided based on the preset number of messages.
  • the number of the preset messages may be configured or changed in advance, which is not limited in this embodiment.
  • the preset number may be 2000, and the division of the message set is further divided into two cases according to different types of message records:
  • the second device detects whether the number of message records included in the text message set is less than the preset message number, if If less than, the text message record is added to the text message collection; otherwise, the text message record is added to a new text message collection.
  • the second device detects whether the number of message records included in the text message set is less than the preset. The number of messages, if less, the description information of the media message record is added to the text message set, and the media message record is added to the corresponding media message set; otherwise, the description information of the media message record is added to the In the new text message collection, add the media message record to a new media message collection.
  • the second device may also record a media message as a set of media messages, which is not limited in this embodiment.
  • the description information of the media message record in the text message set also represents a message record
  • the text message is also counted when the number of message records included in the statistical text message set is counted.
  • the number of descriptive information for the media message record in the collection is also counted.
  • the second device may use the file as a carrier to transmit the message set, thereby Row data backup.
  • the plurality of message collections may be combined into one text message file, and the plurality of media message sets may be combined into one media message file.
  • the second device determines message indication information of the message set, where the message indication information is used to indicate a generation time of the last message record in the message set.
  • the second device can determine the generation time of the last message record in the message set.
  • the second device sends the at least one message set and its message indication information to the first device.
  • the message indication information of the message set is sent to the first device.
  • the second device may package each message set into multiple data packets in a sequence from the first to the last of the message record generation time, and send each data packet (Packet Backup Data Push) to the first device in sequence.
  • the second device sends the packet backup information (Packet Backup Data Tag) of the message set to the first device. The second device then sends the next message set to the first device.
  • the first device may also feed back the packet success or the packet failure (Packet Backup Data Push Response) to the second device.
  • the second device After receiving the success message of the first device, the second device continues to send the next data packet to the first device.
  • the first device may further perform data integrity verification on the received message set.
  • the message indication information of the message set may further include summary information of the message set, and the first device verifies the message according to the summary information of the message set. Whether the collection is successfully received.
  • the summary information of the message set may be a message identifier of all the message records included in the message set, and the first device verifies the received message record according to the message identifier in the summary information, if the summary information indication has been received.
  • the second device After all the message records, it is determined that the message set is successfully received, and a Packet Backup Data Tag Response is sent to the second device. After receiving the verification success message of the message set, the second device sends the next message set to the first device. When the message set corresponding to the target message record is sent, the second device may send a Backup Finish Request to the first device, so that the first device determines that the backup process ends.
  • the embodiment further provides a large media message record for the data volume.
  • the verification mechanism the process may include the following steps 908a to 908f:
  • Step 908a For each message set in the at least one message set, the second device detects whether the specified message record is included in the message set.
  • the specified message record refers to a message record in the message set whose size exceeds a preset threshold.
  • the preset threshold may be pre-configured or changed.
  • the preset threshold may be 500M, which is not limited in this embodiment.
  • Step 908b If the message set contains the specified message record, the second device sends a backup verification request (Packet SvrID Request) to the first device, where the backup verification request carries the message identifier of the specified message record.
  • a backup verification request Packet SvrID Request
  • Step 908c After receiving the backup verification request, the first device determines, according to the message identifier recorded by the specified message, whether the specified message record has been stored.
  • Step 908d If the specified message record is not stored, the first device sends a non-backup indication message to the second device, and step 908e is performed. If the first device has stored the specified message record, the backup indication message is sent to the second device. Step 908f is performed.
  • the unbacked message indication and the backed up message indication may be carried by the Packet Svr ID Response message.
  • Step 908e If the second device receives the non-backup indication message, the second message is sent to the first device.
  • Step 908f The first device stores the specified message record to a storage area corresponding to the target session in the preset backup directory, thereby completing the backup of the specified message record.
  • the preset backup directory is used to store a message record of the session.
  • the preset backup directory may store a default directory for the message record for the target application.
  • the second device encrypts the message record that needs to be sent and then sends it to the first device, for example, encrypts each data packet sent to the first device.
  • the data can be encrypted using a specified key.
  • the user's application data cannot be stolen by other users, and a user's account may correspond to a unique key, which may be used by the user when logging in to the target application using his own account. Obtain the key, so that other users cannot obtain the key of the user, even after obtaining the encrypted data of the user. It is also impossible to decrypt, thus ensuring the security of the user's application data.
  • the first device stores the received at least one message set and the message indication information of each message set to a storage area corresponding to the target session in the preset backup directory.
  • the first device For each received message set, the first device stores the message indication information, the target session, and the message set corresponding to the message set, that is, the generation time of the last message record of the message set, the target session, and the message set.
  • the storage for example, adds an entry of a storage address of the message set in Table 1 to establish the correspondence.
  • the message indication information and the target session of the message set may be stored as an index of the message set.
  • the index of the message set may further include a storage offset location of the message set in the message file, for example, adding a storage address table entry of the message file and a message set in Table 1. An entry of the offset address to enable the first device to accurately locate each message set.
  • the first device and the second device may continue to back up the message record of the target session after the backup of the target session is interrupted.
  • the process of continuing the backup may be triggered by the user on the first device, or may be triggered by the user on the second device, which may be classified into the following three cases:
  • the user triggers the backup by the first device.
  • the prompt information indicating whether to continue the backup is displayed. If the trigger operation for continuing the backup is detected, the second breakpoint resume command is triggered, and the first device receives the second breakpoint resume transmission.
  • the command is sent, the first breakpoint resume request is sent to the second device, and the first breakpoint resume request is used to indicate the backup interruption time of the target session when the backup is interrupted.
  • the backup interrupt time refers to when the data transmission is interrupted.
  • the second device sends the unreviewed target message record of the target session to the first device according to the backup interruption time. For example, the second device determines, according to the backup interruption time, the unbacked message set from the at least one message set, to the first device.
  • the unbacked message set is sent, and the received set of messages is stored by the first device corresponding to the target session.
  • the user triggers the backup by the second device.
  • the prompt information indicating whether to continue the backup is displayed. If the trigger operation for continuing the backup is detected, the first breakpoint resume command is triggered, and the second device receives the first breakpoint resume transmission.
  • the second breakpoint resume request is sent to the first device, and the second breakpoint resume request is used to indicate that the target session is resumed.
  • the first device determines a backup interruption time of the target session, and returns the backup interruption time to the second device.
  • Second setting The device sends a target message record that is not backed up by the target session to the first device according to the backup interruption time. For example, the second device determines the unbacked message set from the at least one message set according to the backup interruption time, and sends the unreviewed message set to the first device.
  • the set of backup messages is stored by the first device corresponding to the target session.
  • the user triggers the backup by the second device, and the second device records the backup interruption time of the target session when the backup is interrupted.
  • the prompt information indicating whether to continue the backup is displayed. If the trigger operation for continuing the backup is detected, the first breakpoint resume command is triggered, and the second device receives the first breakpoint resume transmission. And instructing, according to the recorded backup interruption time, to send, to the first device, a target message record that is not backed up by the target session, for example, the second device determines, from the at least one message set, the unbacked message set according to the backup interruption time, to the first device. The unbacked message set is sent, and the received set of messages is stored by the first device corresponding to the target session.
  • the entire backup process still needs to be started from the beginning when the data transmission is interrupted, and the data to be backed up that has been transmitted needs to be retransmitted again.
  • the method provided in this embodiment only needs to follow the original backup when the data connection is interrupted. The process continues to send the data that needs to be backed up, without transferring the data that has already been backed up, and realizing the breakpoint of the data.
  • the backup deadline is used to distinguish the backed up message records and the unbacked message records in the target session, so that when the target session is backed up, only the unbacked message records need to be transmitted, without having to transmit Backup message records improve the efficiency of data backup.
  • steps 901 to 909 are only described by taking the data backup process of backing up the data of the target application to the first device by the second device as an example.
  • the data of the target application backed up on the first device may also be restored to the second device, and the process of data recovery may be regarded as the reverse process of the data backup, as shown in FIG. 10A.
  • the data recovery process can include the following steps 1001 through 1009:
  • the second device acquires device information of the first device, and establishes a connection with the first device according to the device information.
  • FIG. 10B is a flowchart of data recovery shown in the embodiment, and in FIG. 10B, when the first device detects the data recovery option.
  • a recovery process initiation message is sent to the server, where the backup process initiation message carries the device information of the first device and the first account of the login target application.
  • the password verification may also be performed in the process of establishing the connection between the first device and the second device.
  • the process of the password verification is the same as the step 901.
  • the password verification message and the password verification success message of the second device may also be performed by the Packet Authenticate Request.
  • the message is carried, and the password verification success message and the password verification confirmation message returned by the first device may be carried by the Packet Authenticate Response message.
  • the process type can also be exchanged between the first device and the second device, and the process is the same as the process of interacting with the process type in step 901.
  • the process type indication of the first device and the ready indication of the second device may be carried by the Backup Command Request message, and the acknowledgement response message returned by the second device and the acknowledgement response message of the first device may be carried by the Backup Command Response message.
  • the first device may further send a Backup Start Request to the second device, and the second device returns a Backup Start Response message.
  • the first device sends a data recovery request to the second device, where the data recovery request is used to indicate the target session to be restored.
  • the data recovery request can be carried by the Backup Request Session message.
  • the second device determines a recovery start time of the target session, and sends the recovery start time to the first device.
  • the recovery start time can be the generation time of the first message record in the target session. It should be noted that the recovery start time of the target session may be carried by a data backup response (Backup Request Session Response), and the specific bearer mode of the embodiment of the present invention is not limited.
  • the first device determines, according to the received recovery start time, a target message set from at least one message set of the backup target session, where the target message set refers to a time when the last message record is generated earlier than the recovery start. A collection of time messages.
  • the first device sends the target message set to the second device.
  • the first device may package the target message set into multiple data packets in chronological order, and send each data packet (Packet Backup Data Push) to the second device in turn.
  • the second device can return a packet success or a packet failure (Packet Backup Data Push Response).
  • the first device sends a packet backup information (Packet Backup Data Tag) of the message set to the second device.
  • the message set indication includes the summary information of the message set
  • the second device may further perform integrity verification on the message set, and if the verification is successful, return a verification success message (Packet Backup Data Tag Response), after receiving the verification success message by the first device, sending the next message set.
  • the first device may also detect the specified message record of the larger data volume, and if the specified message record whose size exceeds the preset threshold is detected, send a resume verification request to the second device ( Packet SvrID Request), after the second device verifies the locally stored message record, returns an unrecovered message indication or a resumed message indication.
  • the unrecovered message indication and the recovered message indication may be carried by the Packet Svr ID Response message.
  • the first device After the first device sends all the data that needs to be restored, it sends a Backup Finish Request to the second device.
  • the second device stores the received target message set to a storage area corresponding to the target session.
  • the message indication information of the message set is also used to indicate the generation time of the first message record in the message set. That is, the message indication information is used to indicate the time range corresponding to the message record included in the message set.
  • the first device stores the message indication information, the target session, and the message set of the message set correspondingly, that is, stores the time range, the target session, and the message set corresponding to the message set.
  • the index of the message set is the time range and target session corresponding to the message set.
  • the user may select the target time period of the target session to be restored in the data recovery interface during the process of triggering the data recovery process by the first device. Then, after step 1001, the data recovery process may also be:
  • the first device detects the data recovery instruction of the target session, determining the target message set from the at least one target message set according to the target time period carried in the data recovery instruction and the message indication information of the at least one message set of the target session.
  • the target message set refers to a message set whose time range corresponding to the message record falls within the target time period.
  • the first device transmits the target message set to the second device.
  • the data recovery instruction may be triggered by a click operation of the data recovery option provided by the first device by the user; when the data recovery process is triggered by the second device, the data recovery instruction may be The second device sends to the first device.
  • the message collection is such that when data recovery is performed on the target session, only the message records not stored in the target device need to be transmitted, and the message records stored in the target device need not be transmitted, thereby improving the efficiency of data recovery.
  • FIG. 11 is a block diagram of a data backup apparatus according to an embodiment of the present invention.
  • the apparatus includes a first transmitting module 1101, a receiving module 1102, a determining module 1103, and a second transmitting module 1104.
  • the first sending module 1101 is connected to the receiving module 1102, and is configured to send a data backup request to the first device, where the data backup request is used to indicate a target session to be backed up;
  • the receiving module 1102 is connected to the determining module 1103, and configured to receive the data.
  • a backup deadline of the target session returned by the first device the backup deadline is used to indicate that the first device stores all the message records of the target session before the backup deadline;
  • the determining module 1103 is connected to the second sending module 1104.
  • the target message record is determined according to the backup deadline, the target message is recorded as a message record generated by the target session after the backup deadline;
  • the second sending module 1104 is configured to send the target message record to the first device.
  • the first device is used to back up the message record of the session.
  • the second sending module 1104 is configured to divide the target message record into at least one message set in a first-to-last order according to a generation time of the message record; for each of the at least one message set a message set, the message indication information of the message set is determined, the message indication information is used to indicate a generation time of the last message record in the message set; and the at least one message set and its message indication information are sent to the first device.
  • the second sending module 1104 is configured to detect, for each message set in the at least one message set, whether the specified message record is included in the message set, where the specified message record refers to a size exceeding a preset. a message record of the threshold; if the specified message record is included in the message set, sending a backup verification request to the first device, the backup verification request carrying a message identifier of the specified message record, the first device is configured to The message identifier of the message record determines that the specified message record is not stored, and returns a non-backup indication message; if the non-backup indication message is received, the specified message record is sent to the first device.
  • the message indication information is further used to indicate summary information of the message set
  • the second sending module 1104 is further configured to send the message set for each message set in the at least one message set. Up to the first device; sending the message indication information of the message set to the first device, where the first device is configured to return after verifying that the message set is successfully received according to the summary information Receiving a success message; when receiving the reception success message of the message set, sending the next message set to the first device.
  • the message indication information is further used to indicate a generation time of the first message record in the message set.
  • the receiving module is further configured to receive a first breakpoint resuming request of the first device after the backup of the target session is interrupted, where the first breakpoint resume request is used to indicate The backup interruption time of the target session; the second sending module is further configured to send the unbacked target message record of the target session to the first device based on the backup interruption time; or the first sending module is further used for the target After the backup of the session is interrupted, if the first breakpoint resume command is received, the second breakpoint resume request is sent to the first device, and the second breakpoint resume request is used to indicate that the target session is broken.
  • the second sending module is further configured to send, according to the backup interruption time of the target session returned by the first device, the unbacked target message record of the target session to the first device; or the second sending module And if, after receiving the interruption of the backup of the target session, if the first breakpoint resuming instruction is received, determining the unbacked target message record of the target session, sending the unsent to the first device Certain parts of the message record.
  • the device further includes:
  • An obtaining module configured to acquire device information of the first device
  • connection module configured to establish a connection with the first device according to the device information.
  • the acquiring module is configured to acquire device information of the first device from the server; or, by scanning the two-dimensional code, acquiring device information of the first device, where the two-dimensional code is used to indicate the device of the first device And receiving the device information broadcast message of the first device, and extracting the device information of the first device from the device information broadcast message.
  • the device information includes an IP address of the first device
  • the connection module is configured to send a data connection request to the first device according to the IP address of the first device, where the first device is configured to receive the data connection. If the request is received, a response message is returned; if a response message is received, a connection is established with the first device in the local area network.
  • the acquiring module is further configured to acquire a first account that is logged in the first device, and if the first account is consistent with the second account that is logged in locally, perform the The step of establishing a connection by a device.
  • the data that interacts with the first device is encrypted data.
  • FIG. 12 is a block diagram of a data backup apparatus according to an embodiment of the present invention.
  • the package The device includes an acquisition module 1201, a transmission module 1202, and a storage module 1203.
  • the obtaining module 1201 is connected to the sending module 1202, and configured to: when receiving the data backup request of the second device, obtain a backup deadline corresponding to the target session, where the data backup request is used to indicate the target session to be backed up; 1202 is connected to the storage module 1203, configured to send a backup deadline of the target session to the second device, where the second device is configured to send a target message record to the first device, where the target message is recorded as the target session in the backup a message record generated after the deadline; the storage module 1203 is configured to store the target message record in the message record of the target session when the target message record is received.
  • the storage module 1203 is configured to store the at least one message set of the second device and the message indication information of each message set to a storage area corresponding to the target session in the preset backup directory.
  • the preset backup directory is used to store a message record of the session, and the message indication information of each message set is used to indicate the generation time of the last message record in the message set.
  • the message indication information of each message set is further used to indicate summary information of the message set, and the apparatus further includes:
  • a verification module configured to verify, according to the summary information of the message set, whether the message set is successfully received for each of the message sets;
  • the sending module is further configured to send a receiving success message to the second device if the verification result is that the receiving is successful.
  • the message indication information of each message set is further used to indicate a generation time of the first message record in the message set, and the apparatus further includes:
  • a determining module configured to: when the data recovery instruction of the target session is detected, determine a target message set from the at least one message set according to the target time period and message indication information of the at least one message set, where the data recovery instruction is to be carried
  • the target time segment of the recovery, the target message set refers to a message set of the first message record generation time and the last message record generation time falling within the target time period;
  • the sending module is further configured to send the target message set to the first device.
  • the device further includes:
  • a judging module configured to: if the backup verification request is received, determine, according to the message identifier of the specified message, whether the specified message record is stored, and the backup verification request carries the message identifier of the specified message record;
  • the sending module is further configured to: if the specified message record is not stored, send the message to the second device.
  • the backup indication message is sent to the second device if the specified message record is stored, and the specified message record is stored in the storage area corresponding to the target session in the preset backup directory, the preset backup The directory is used to store message records for the session.
  • the sending module is further configured to send a first breakpoint resuming request to the second device after receiving the second breakpoint resuming instruction after the backup of the target session is interrupted, the first disconnecting The point resume request is used to indicate the backup interruption time of the target session; the storage module is further configured to store the unbacked target message record of the received target session; or, the sending module is further configured to: after the backup of the target session is interrupted, If the second breakpoint resuming request of the target session is received, sending a backup interruption time of the target session to the second device; the storage module is further configured to store the unbacked target message record of the received target session; or, store The module is also used to store the unbacked message records of the received target session after the backup of the target session is interrupted.
  • the data backup device provided by the foregoing embodiment is only illustrated by the division of each functional module. In actual applications, the function distribution may be completed by different functional modules as needed. The internal structure of the device is divided into different functional modules to perform all or part of the functions described above.
  • the data backup device and the data backup method embodiment provided by the foregoing embodiments are in the same concept, and the specific implementation process is described in detail in the method embodiment, and details are not described herein again.
  • FIG. 13 is a schematic structural diagram of a terminal according to an embodiment of the present invention.
  • the terminal may be used to perform the data backup method provided in the foregoing embodiments.
  • the terminal 1300 includes:
  • the terminal 1300 may include an RF (Radio Frequency) circuit 110, a memory 120 including one or more computer readable storage media, an input unit 130, a display unit 140, a sensor 150, an audio circuit 160, and a WiFi (Wireless Fidelity, wireless).
  • the fidelity module 170 includes a processor 180 having one or more processing cores, and a power supply 190 and the like. It will be understood by those skilled in the art that the terminal structure shown in FIG. 13 does not constitute a limitation to the terminal, and may include more or less components than those illustrated, or a combination of certain components, or different component arrangements. among them:
  • the RF circuit 110 can be used for transmitting and receiving information or during a call, and receiving and transmitting signals. Specifically, after receiving downlink information of the base station, the downlink information is processed by one or more processors 180. In addition, the data related to the uplink is sent to the base station. .
  • RF circuitry 110 includes, but is not limited to, an antenna, at least one amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, Coupler, LNA (Low Noise Amplifier), duplexer, etc. In addition, RF circuitry 110 can also communicate with the network and other devices via wireless communication.
  • SIM Subscriber Identity Module
  • LNA Low Noise Amplifier
  • the wireless communication may use any communication standard or protocol, including but not limited to GSM (Global System of Mobile communication), GPRS (General Packet Radio Service), CDMA (Code Division Multiple Access). , Code Division Multiple Access), WCDMA (Wideband Code Division Multiple Access), LTE (Long Term Evolution), e-mail, SMS (Short Messaging Service), and the like.
  • GSM Global System of Mobile communication
  • GPRS General Packet Radio Service
  • CDMA Code Division Multiple Access
  • WCDMA Wideband Code Division Multiple Access
  • LTE Long Term Evolution
  • e-mail Short Messaging Service
  • the memory 120 can be used to store software programs and modules, and the processor 180 executes various functional applications and data processing by running software programs and modules stored in the memory 120.
  • the memory 120 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application required for at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may be stored according to The data created by the use of the terminal 1300 (such as audio data, phone book, etc.) and the like.
  • memory 120 can include high speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, memory 120 may also include a memory controller to provide access to memory 120 by processor 180 and input unit 130.
  • the input unit 130 can be configured to receive input numeric or character information and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.
  • input unit 130 can include touch-sensitive surface 131 as well as other input devices 132.
  • Touch-sensitive surface 131 also referred to as a touch display or trackpad, can collect touch operations on or near the user (such as a user using a finger, stylus, etc., on any suitable object or accessory on touch-sensitive surface 131 or The operation near the touch-sensitive surface 131) and driving the corresponding connecting device according to a preset program.
  • the touch-sensitive surface 131 can include two portions of a touch detection device and a touch controller.
  • the touch detection device detects the touch orientation of the user, and detects a signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts the touch information into contact coordinates, and sends the touch information.
  • the processor 180 is provided and can receive commands from the processor 180 and execute them.
  • the touch-sensitive surface 131 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves.
  • the input unit 130 can also include other input devices 132.
  • other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control buttons, switch buttons, etc.), trackballs, mice, joysticks, and the like.
  • the display unit 140 can be used to display information input by the user or information provided to the user and various graphical user interfaces of the terminal 1300, which can be composed of graphics, text, icons, video, and any combination thereof.
  • the display unit 140 may include a display panel 141.
  • the display panel 141 may be configured in the form of an LCD (Liquid Crystal Display), an OLED (Organic Light-Emitting Diode), or the like.
  • the touch-sensitive surface 131 may cover the display panel 141, and when the touch-sensitive surface 131 detects a touch operation thereon or nearby, it is transmitted to the processor 180 to determine the type of the touch event, and then the processor 180 according to the touch event The type provides a corresponding visual output on display panel 141.
  • touch-sensitive surface 131 and display panel 141 are implemented as two separate components to implement input and input functions, in some embodiments, touch-sensitive surface 131 can be integrated with display panel 141 for input. And output function.
  • Terminal 1300 can also include at least one type of sensor 150, such as a light sensor, motion sensor, and other sensors.
  • the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 141 according to the brightness of the ambient light, and the proximity sensor may close the display panel 141 when the terminal 1300 moves to the ear. / or backlight.
  • the gravity acceleration sensor can detect the magnitude of acceleration in all directions (usually three axes). When it is stationary, it can detect the magnitude and direction of gravity.
  • the terminal 1300 can also be configured with gyroscopes, barometers, hygrometers, thermometers, infrared sensors and other sensors, not here Let me repeat.
  • the audio circuit 160, the speaker 161, and the microphone 162 can provide an audio interface between the user and the terminal 1300.
  • the audio circuit 160 can transmit the converted electrical data of the received audio data to the speaker 161 for conversion to the sound signal output by the speaker 161; on the other hand, the microphone 162 converts the collected sound signal into an electrical signal by the audio circuit 160. After receiving, it is converted into audio data, and then processed by the audio data output processor 180, transmitted to the terminal, for example, via the RF circuit 110, or outputted to the memory 120 for further processing.
  • the audio circuit 160 may also include an earbud jack to provide communication of the peripheral earphones with the terminal 1300.
  • WiFi is a short-range wireless transmission technology
  • the terminal 1300 can help users to send and receive emails, browse web pages, and access streaming media through the WiFi module 170, which provides wireless broadband Internet access for users.
  • FIG. 13 shows the WiFi module 170, it can be understood that it does not belong to the essential configuration of the terminal 1300, and may be omitted as needed within the scope of not changing the essence of the invention.
  • the processor 180 is a control center of the terminal 1300 that connects various portions of the entire handset with various interfaces and lines, by running or executing software programs and/or modules stored in the memory 120, and recalling data stored in the memory 120, The various functions and processing data of the terminal 1300 are performed to perform overall monitoring of the mobile phone.
  • the processor 180 may include one or more processing cores; preferably, the processor 180 may integrate an application processor and a modem processor, where the application processor mainly processes an operating system, a user interface, an application, and the like.
  • the modem processor primarily handles wireless communications. It can be understood that the above modem processor may not be integrated into the processor 180.
  • the terminal 1300 also includes a power source 190 (such as a battery) for powering various components.
  • the power source can be logically coupled to the processor 180 through a power management system to manage functions such as charging, discharging, and power management through the power management system.
  • Power supply 190 may also include any one or more of a DC or AC power source, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.
  • the terminal 1300 may further include a camera, a Bluetooth module, and the like, and details are not described herein again.
  • the display unit of the terminal is a touch screen display
  • the terminal further includes a memory, and one or more programs, wherein one or more programs are stored in the memory and configured to be processed by one or more Execution.
  • the one or more programs include executable instructions, and the terminal 1300 is configured to execute instructions to perform the method performed by the terminal in the above-described call alert method embodiment.
  • non-transitory computer readable storage medium comprising instructions, such as a memory comprising instructions executable by a processor in a terminal to perform the data backup method of the above embodiments.
  • the non-transitory computer readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device.
  • FIG. 14 is a block diagram of a data backup apparatus according to an embodiment of the present invention.
  • device 1400 can be provided as a server.
  • apparatus 1400 includes a processing component 1422 that further includes one or more processors, and memory resources represented by memory 1432 for storing instructions executable by processing component 1422, such as an application.
  • the application stored in the memory 1432 may include one or more modules each corresponding to a set of instructions.
  • processing component 1422 is configured to execute instructions to perform the methods performed by the server in the data backup method embodiments described above.
  • Apparatus 1400 can also include a power supply component 1426 configured to perform power management of apparatus 1400, a wired or wireless network interface 1450 configured to connect apparatus 1400 to the network, and an input/output (I/O) interface 1458.
  • Apparatus 1400 may operate based on an operating system stored in the memory 1432, for example, Windows Server TM, Mac OS X TM , Unix TM, Linux TM, FreeBSD TM or the like.
  • non-transitory computer readable storage medium comprising instructions, such as a memory comprising instructions executable by a processor in a server to perform the data backup method of the above embodiments.
  • the non-transitory computer readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device.
  • a person skilled in the art may understand that all or part of the steps of implementing the above embodiments may be completed by hardware, or may be instructed by a program to execute related hardware, and the program may be stored in a computer readable storage medium.
  • the storage medium mentioned may be a read only memory, a magnetic disk or an optical disk or the like.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本发明实施例公开了一种通信消息同步方法、数据备份方法、设备及存储介质,属于互联网技术领域。所述方法包括:获取第一社交应用客户端中待同步的n条通信消息以及每条通信消息的消息类型;对于每条通信消息,生成包括通信消息的消息类型以及通信消息的消息内容的消息数据;以消息块为单位同步生成的n条消息数据至第二社交应用客户端;每个消息块对应于至少一条消息数据,且在对应于至少两条消息数据时,至少两条消息数据所对应的通信消息属于同一会话,第二社交应用客户端与第一社交应用客户端类型相同且共用同一社交帐号;解决了相关技术中在同步通信消息至其他平台之后,其他平台中的社交应用客户端可能无法识别该通信消息的问题。

Description

通信消息同步方法、数据备份方法、设备及存储介质
本申请要求于2016年11月25日提交国家知识产权局、申请号为201611056492.1、发明名称为“通信消息同步方法及装置”的中国专利申请,以及于2016年11月25日提交国家知识产权局、申请号为201611055670.9、发明名称为“数据备份方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明实施例涉及互联网技术领域,特别涉及一种通信消息同步方法、数据备份方法、设备及存储介质。
背景技术
相关技术中,用户可以在不同社交应用客户端中登录自己的社交帐号,比如,用户可以在手机的社交应用客户端中登录自己的社交帐号,也可以在电脑的社交应用客户端中登录自己的社交帐号。
实际实现时,当用户需要在第二社交应用客户端中查看第一社交应用客户端中的通信消息时,第一社交应用客户端可以获取存储的待同步的通信消息,将获取到的通信消息同步至第二社交应用客户端。这样,用户即可在第二社交应用客户端中查看接收到的通信消息。
然而,当第一社交应用客户端和第二社交应用客户端是运行在不同平台中的客户端,比如,第一社交应用客户端运行在Android***的手机中,而第二社交应用客户端运行在Windows***的电脑中时,由于不同平台对数据的封装格式不同,因此在第一社交应用客户端同步通信消息至第二社交应用客户端之后,第二社交应用客户端可能并不能解析该通信消息。
发明内容
本发明实施例提供了一种通信消息同步方法、数据备份方法、设备及存储介质,可以解决相关技术中存在的问题。技术方案如下:
根据本发明实施例的第一方面,提供一种通信消息同步方法,用于第一社 交应用客户端中,该方法包括:
获取所述第一社交应用客户端中待同步的n条通信消息以及每条通信消息的消息类型,n为大于等于1的整数;
对于每条通信消息,生成包括所述通信消息的消息类型以及所述通信消息的消息内容的消息数据;
以消息块为单位同步生成的n条消息数据至第二社交应用客户端;第二社交应用客户端以消息块为单位存储n条消息数据至数据文件,生成并保存对应关系;每个消息块对应于至少一条消息数据,且在对应于至少两条消息数据时,至少两条消息数据所对应的通信消息属于同一会话,第二社交应用客户端与第一社交应用客户端类型相同且共用同一社交帐号;对应关系包括消息块、消息块所对应的会话以及消息块的存储位置之间的对应关系,消息块所对应的会话为消息块中的消息数据所对应的通信消息所属的会话。
根据本发明实施例的第二方面,提供一种通信消息同步方法,用于第二社交应用客户端中,该方法包括:
接收第一社交应用客户端以消息块为单位同步的n条消息数据;所述第一社交应用客户端与所述第二社交应用客户端类型相同且共用同一社交帐号;每条消息数据为所述第一社交应用客户端生成的包括一条通信消息的消息类型以及消息内容的数据;每个消息块对应于至少一条消息数据,且在对应于至少两条消息数据时,所述至少两条消息数据所对应的通信消息属于同一会话;
以所述消息块为单位存储所述n条消息数据至数据文件;
生成并保存对应关系;所述对应关系包括消息块、所述消息块所对应的会话以及所述消息块的存储位置之间的对应关系,所述消息块所对应的会话为所述消息块中的消息数据所对应的通信消息所属的会话。
根据本发明实施例的第三方面,提供一种通信消息同步装置,用于第一社交应用客户端中,该装置包括:
第一获取模块,用于获取所述第一社交应用客户端中待同步的n条通信消息以及每条通信消息的消息类型,n为大于等于1的整数;
生成模块,用于对于每条通信消息,生成包括所述通信消息的消息类型以及所述通信消息的消息内容的消息数据;
同步模块,用于以消息块为单位同步生成的n条消息数据至第二社交应用客户端;第二社交应用客户端以消息块为单位存储n条消息数据至数据文件, 生成并保存对应关系;每个消息块对应于至少一条消息数据,且在对应于至少两条消息数据时,至少两条消息数据所对应的通信消息属于同一会话,第二社交应用客户端与第一社交应用客户端类型相同且共用同一社交帐号;对应关系包括消息块、消息块所对应的会话以及消息块的存储位置之间的对应关系,消息块所对应的会话为消息块中的消息数据所对应的通信消息所属的会话。
根据本发明实施例的第四方面,提供一种通信消息同步装置,用于第二社交应用客户端中,该装置包括:
第一接收模块,用于接收第一社交应用客户端以消息块为单位同步的n条消息数据;所述第一社交应用客户端与所述第二社交应用客户端类型相同且共用同一社交帐号;每条消息数据为所述第一社交应用客户端生成的包括一条通信消息的消息类型以及消息内容的数据;每个消息块对应于至少一条消息数据,且在对应于至少两条消息数据时,所述至少两条消息数据所对应的通信消息属于同一会话;
存储模块,用于以所述消息块为单位存储所述n条消息数据至数据文件;
生成模块,用于生成并保存对应关系;所述对应关系包括消息块、所述消息块所对应的会话以及所述消息块的存储位置之间的对应关系,所述消息块所对应的会话为所述消息块中的消息数据所对应的通信消息所属的会话。
根据本发明实施例的第五方面,提供一种终端,所述终端包括:处理器和存储器,所述存储器中存储有至少一条指令,所述指令由所述处理器加载并执行以实现如下操作:
获取第一社交应用客户端中待同步的n条通信消息以及每条通信消息的消息类型,n为大于等于1的整数;
对于每条通信消息,生成包括所述通信消息的消息类型以及所述通信消息的消息内容的消息数据;
以消息块为单位同步生成的n条消息数据至第二社交应用客户端;所述第二社交应用客户端以所述消息块为单位存储所述n条消息数据至数据文件,生成并保存对应关系;每个消息块对应于至少一条消息数据,且在对应于至少两条消息数据时,所述至少两条消息数据所对应的通信消息属于同一会话,所述第二社交应用客户端与所述第一社交应用客户端类型相同且共用同一社交帐号;所述对应关系包括消息块、所述消息块所对应的会话以及所述消息块的存储位置之间的对应关系,所述消息块所对应的会话为所述消息块中的消息数据 所对应的通信消息所属的会话。
根据本发明实施例的第六方面,提供一种终端,所述终端包括:处理器和存储器,所述存储器中存储有至少一条指令,所述指令由所述处理器加载并执行以实现如下操作:
接收第一社交应用客户端以消息块为单位同步的n条消息数据;所述第一社交应用客户端与第二社交应用客户端类型相同且共用同一社交帐号;每条消息数据为所述第一社交应用客户端生成的包括一条通信消息的消息类型以及消息内容的数据;每个消息块对应于至少一条消息数据,且在对应于至少两条消息数据时,所述至少两条消息数据所对应的通信消息属于同一会话;
以所述消息块为单位存储所述n条消息数据至数据文件;
生成并保存对应关系;所述对应关系包括消息块、所述消息块所对应的会话以及所述消息块的存储位置之间的对应关系,所述消息块所对应的会话为所述消息块中的消息数据所对应的通信消息所属的会话。
根据本发明实施例的第七方面,提供一种计算机可读存储介质,所述计算机可读存储介质中存储有至少一条指令,所述指令由处理器加载并执行以实现如第一方面所述的方法中所执行的操作。
根据本发明实施例的第八方面,提供一种计算机可读存储介质,所述计算机可读存储介质中存储有至少一条指令,所述指令由处理器加载并执行以实现如第二方面所述的方法中所执行的操作。
本发明实施例提供的技术方案带来的有益效果是:
通过在获取到待同步的n条通信消息以及每条通信消息的消息类型之后,对于每条通信消息,生成包括消息类型以及消息内容的消息数据,并以消息块为单位同步生成的n条消息数据至第二社交应用客户端,这样,由于每条消息数据中包括消息类型和消息内容,所以第二社交应用客户端可以根据接收到的消息数据解析出对应的通信消息;解决了相关技术中在同步通信消息至其他平台之后,其他平台中的社交应用客户端可能无法识别该通信消息的问题;达到了可以实现跨平台的通信消息同步的效果。
根据本发明实施例的第九方面,提供了一种数据备份方法,所述方法包括:
向第一设备发送数据备份请求,所述数据备份请求用于指示待备份的目标会话;
接收所述第一设备返回的所述目标会话的备份截止时间,所述备份截止时间用于指示所述第一设备存储有所述目标会话在所述备份截止时间之前的全部消息记录;
根据所述备份截止时间确定目标消息记录,所述目标消息记录为所述目标会话在所述备份截止时间之后产生的消息记录;
向所述第一设备发送所述目标消息记录,所述第一设备用于对会话的消息记录进行备份。
根据本发明实施例的第十方面,提供了一种数据备份方法,所述方法包括:
当接收到第二设备的数据备份请求时,获取与目标会话对应的备份截止时间,所述数据备份请求用于指示待备份的目标会话;
将所述目标会话的备份截止时间发送至所述第二设备,所述第二设备用于向第一设备发送目标消息记录,所述目标消息记录为所述目标会话在所述备份截止时间之后产生的消息记录;
当接收到所述目标消息记录时,将所述目标消息记录存储至所述目标会话的消息记录中。
根据本发明实施例的第十一方面,提供了一种数据备份装置,所述装置包括:
第一发送模块,用于向第一设备发送数据备份请求,所述数据备份请求用于指示待备份的目标会话;
接收模块,用于接收所述第一设备返回的所述目标会话的备份截止时间,所述备份截止时间用于指示所述第一设备存储有所述目标会话在所述备份截止时间之前的全部消息记录;
确定模块,用于根据所述备份截止时间确定目标消息记录,所述目标消息记录为所述目标会话在所述备份截止时间之后产生的消息记录;
第二发送模块,用于向所述第一设备发送所述目标消息记录,所述第一设备用于对会话的消息记录进行备份。
根据本发明实施例的第十二方面,提供了一种数据备份装置,所述装置包括:
获取模块,用于当接收到第二设备的数据备份请求时,获取与目标会话对应的备份截止时间,所述数据备份请求用于指示待备份的目标会话;
发送模块,用于将所述目标会话的备份截止时间发送至所述第二设备,所 述第二设备用于向第一设备发送目标消息记录,所述目标消息记录为所述目标会话在所述备份截止时间之后产生的消息记录;
存储模块,用于当接收到所述目标消息记录时,将所述目标消息记录存储至所述目标会话的消息记录中。
根据本发明实施例的第十三方面,提供了一种数据备份设备,所述设备包括:处理器和存储器,所述存储器中存储有至少一条指令,所述指令由所述处理器加载并执行以实现如下操作:
向第一设备发送数据备份请求,所述数据备份请求用于指示待备份的目标会话;
接收所述第一设备返回的所述目标会话的备份截止时间,所述备份截止时间用于指示所述第一设备存储有所述目标会话在所述备份截止时间之前的全部消息记录;
根据所述备份截止时间确定目标消息记录,所述目标消息记录为所述目标会话在所述备份截止时间之后产生的消息记录;
向所述第一设备发送所述目标消息记录,所述第一设备用于对会话的消息记录进行备份。
根据本发明实施例的第十四方面,提供了一种数据备份设备,所述设备包括:处理器和存储器,所述存储器中存储有至少一条指令,所述指令由所述处理器加载并执行以实现如下操作:
当接收到第二设备的数据备份请求时,获取与目标会话对应的备份截止时间,所述数据备份请求用于指示待备份的目标会话;
将所述目标会话的备份截止时间发送至所述第二设备,所述第二设备用于向第一设备发送目标消息记录,所述目标消息记录为所述目标会话在所述备份截止时间之后产生的消息记录;
当接收到所述目标消息记录时,将所述目标消息记录存储至所述目标会话的消息记录中。
根据本发明实施例的第十五方面,提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有至少一条指令,所述指令由处理器加载并执行以实现如第九方面所述的方法中所执行的操作。
根据本发明实施例的第十六方面,提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有至少一条指令,所述指令由处理器加载并执行以 实现如第十方面所述的方法中所执行的操作。
本发明实施例提供的技术方案带来的有益效果是:
通过采用备份截止时间来区分目标会话中已备份的消息记录和未备份的消息记录,使得在对目标会话进行备份时,仅需传输未备份的消息记录即可,而无需传输已备份的消息记录,提高了数据备份的效率。
附图说明
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本发明各个实施例所涉及的实施环境的示意图;
图2是本发明一个实施例提供的通信消息同步方法的流程图;
图3A是本发明一个实施例提供的通信消息同步方法的流程图;
图3B是本发明一个实施例提供的生成的消息数据的示意图;
图3C是本发明一个实施例提供的生成的消息块的示意图;
图3D是本发明一个实施例提供的数据文件的示意图;
图3E是本发明一个实施例提供的数据文件和索引文件的示意图;
图4A是本发明另一个实施例提供的通信消息同步方法的流程图;
图4B是本发明另一个实施例提供的生成的消息数据的示意图;
图5是本发明一个实施例提供的通信消息同步装置的示意图;
图6是本发明一个实施例提供的通信消息同步装置的示意图;
图7是本发明一个实施例提供的终端的示意图;
图8是本发明实施例提供的一种用于数据备份的设备交互示意图;
图9A是本发明实施例提供的一种数据备份方法的流程图;
图9B是本发明实施例提供的一种数据备份方法的流程图;
图10A是本发明实施例提供的一种数据备份方法的流程图;
图10B是本发明实施例提供的一种数据备份方法的流程图;
图11是本发明实施例提供的一种数据备份装置的框图;
图12是本发明实施例提供的一种数据备份装置的框图;
图13是本发明实施例提供的一种终端的结构示意图;
图14是本发明实施例提供的一种数据备份装置的框图。
具体实施方式
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合附图对本发明实施方式作进一步地详细描述。
请参考图1,其示出了本发明各个实施例提供的通信消息同步方法所涉及的实施环境的示意图,如图1所示,该实施环境可以包括第一社交应用客户端110、服务器120和第二社交应用客户端130。
第一社交应用客户端110和第二社交应用客户端130为同种类型的客户端。比如,同时为即时通信客户端或者同时为邮箱等等。在下述各个实施例中,第一社交应用客户端110和第二社交应用客户端130共用同一社交帐号。
实际实现时,第一社交应用客户端110安装在第一终端中,第二社交应用客户端130安装在第二终端中,第一终端和第二终端可以为诸如手机、平板电脑、电子阅读器、台式电脑或者笔记本电脑之类的终端,第一终端和第二终端的不同之处在于,两者使用的操作***不同。比如,第一终端使用的操作***可以为iOS,第二终端使用的操作***可以为Windows;又比如,第一终端使用的操作***为Android(安卓),第二终端使用的操作***可以为iOS,本实施例对此并不做限定。
实际实现时,第一终端和第二终端均可以通过有线或者无线网络与服务器120连接。并且,第一终端还可以通过蓝牙、局域网、USB(Universal Serial Bus,通用串行总线)或者NFC(Near Field Communication,近距离无线通信技术)与第二终端连接。
服务器120可以为社交应用客户端所对应的后台服务器,该服务器120可以为一台服务器,也可以为由多台服务器组成的服务器集群。
在下述各个实施例中,除特殊说明外,第一社交应用客户端110为需要同步通信消息的客户端,第二社交应用客户端130为接收同步的客户端。具体的,第一社交应用客户端110可以主动同步通信消息至第二社交应用客户端130,或者,在接收到第二社交应用客户端130发送的同步请求之后同步通信消息至第二社交应用客户端130,比如,用户在登录第二社交应用客户端130之后,第二社交应用客户端130可以发送同步请求至服务器120,服务器转发该同步 请求至第一社交应用客户端110,第一社交应用客户端110接收到同步请求之后同步通信消息至第二社交应用客户端130。
实际实现时,第一社交应用客户端110在同步通信消息至第二社交应用客户端120时,第一社交应用客户端110可以先同步通信消息至服务器120,由服务器120转发通信消息至第二社交应用客户端130。
可选地,作为另一种实现方式,第一社交应用客户端110所处的第一终端还可以先建立与第二社交应用客户端130所处的第二终端之间的直连,然后直接同步通信消息至第二社交应用客户端130。以第一终端和第二终端通过局域网连接为例,第二社交应用客户端130在登录之后,第二社交应用客户端130可以上报第二终端的IP(Internet Protocol,网络之间互联的协议)地址以及端口至服务器120,服务器120转发该IP地址和端口至第二社交应用客户端130,第二终端根据第二社交应用客户端130接收到的IP地址和端口建立与第一终端之间的局域网连接。
请参考图2,其示出了本发明一个实施例提供的通信消息同步方法的方法流程图,本实施例以该方法用于图1所示的应用场景中来举例说明,如图2所示,该通信消息同步方法可以包括:
步骤201,第一社交应用客户端获取第一社交应用客户端中待同步的n条通信消息以及每条通信消息的消息类型,n为大于等于1的整数。
用户使用第一社交应用客户端与好友通信时,第一社交应用客户端可以保存通信消息至本地数据库。其中,通信消息包括好友社交应用客户端发送至第一社交应用客户端的消息,以及第一社交应用客户端发送至好友社交应用客户端的消息。
当需要同步通信消息至第二社交应用客户端时,第一社交应用客户端可以从本地数据库中获取待同步的n条通信消息以及每条通信消息的消息类型。其中,第二社交应用客户端和第一社交应用客户端同种类型且共用同一社交帐号,消息类型为文本、图片、音频或者视频。
可选地,本步骤可以包括如下可能的实现方式:
第一种,第一社交应用客户端在预定时刻获取与上一个同步时刻之间新增的通信消息,将获取到的通信消息作为待同步的n条通信消息。
实际实现时,第一社交应用客户端可以定时同步,比如,在每天24:00, 或者每周日24:00执行同步。对于此种情况,第一社交应用客户端可以获取当前时刻与上一个同步时刻之间新增的通信消息。
比如,以每天24:00同步为例,第一社交应用客户端可以获取从前一天24:00至当天24:00时新增的通信消息,将获取到的通信消息作为n条通信消息。
第二种,第一社交应用客户端接收同步信号,该同步信号请求同步目标会话在预设时间段内新增的通信消息;获取目标会话在预设时间段内新增的通信消息。
用户使用第一社交应用客户端的过程中,用户可以主动请求同步某一会话在某一时间段内的通信消息至第二社交应用客户端,也即用户可以在第一社交应用客户端中施加同步信号,相应的,第一社交应用客户端可以接收到该同步信号,并在接收到同步信号之后,获取指定会话在指定时间段内的通信消息。
比如,在10:00~12:00期间用户使用手机中的第一社交应用客户端向自己的老师咨询了一些问题,则为了能够在电脑的第二社交应用客户端中查看该咨询记录,用户可以施加将与老师的会话中在10:00~12:00期间的通信消息同步至第二社交应用客户端的同步信号。
其中,该同步信号可以由用户选择目标会话以及预设时间段的操作施加,例如第一社交应用客户端提供同步选项,当检测到用户对同步选项的选择操作时,提供会话列表,由用户从中选择目标会话,之后第一社交应用客户端显示目标会话中的多条通信消息以及每条通信消息对应的时间,由用户根据该多条通信消息确定预设时间段。
步骤202,对于每条通信消息,第一社交应用客户端生成包括通信消息的消息类型以及通信消息的消息内容的消息数据。
第一社交应用客户端在获取到n条通信消息之后,提取每条通信消息中在各个平台中均有用的字段,也即提取出每条通信消息的消息内容,生成包括消息内容和消息类型的消息数据。
实际应用中,每条通信消息会包含消息内容,且除该消息内容之外,还可能会包含一些适用于当前所在平台的数据。针对多个平台,该消息内容可以被多个平台识别,而除该消息内容以外的其他数据可能仅能被当前平台识别,不能被其他平台识别,因此第一社交应用客户端可以从通信消息中提取适用于多个平台的消息内容来生成消息数据。
步骤203,第一社交应用客户端以消息块为单位同步生成的n条消息数据至第二社交应用客户端。
每个消息块对应于至少一条消息数据,且在对应于至少两条消息数据时,至少两条消息数据所对应的通信消息属于同一会话。
可选地,作为一种可能的实现方式,第一社交应用客户端以消息块为单位同步生成的n条消息数据至服务器,服务器以消息块为单位转发该n条消息数据至第二社交应用客户端。
作为另一种可能的实现方式,第一社交应用客户端所处的第一终端和第二社交应用客户端所处的第二终端可以建立直连,第一社交应用客户端直接以消息块为单位同步该n条消息数据至该第二社交应用客户端。其中,第一终端可以通过蓝牙、NFC、USB、局域网等方式与第二终端建立连接,本实施例对此并不做限定。
另外,在同步消息数据至第二社交应用客户端的过程中,若第二社交应用客户端不在线,则同步失败,第一社交应用客户端生成提示信息,以提示用户当前第二社交应用客户端不在线,无法进行同步,对此并不做限定。
步骤204,第二社交应用客户端接收第一社交应用客户端以消息块为单位同步的n条消息数据。
步骤205,第二社交应用客户端以消息块为单位存储n条消息数据至数据文件。
步骤206,第二社交应用客户端确定每个消息块在数据文件中的存储位置。
步骤207,第二社交应用客户端生成并保存对应关系。
对应关系包括消息块、消息块所对应的会话以及消息块的存储位置之间的对应关系,消息块所对应的会话为消息块中的消息数据所对应的通信消息所属的会话。
综上所述,本实施例提供的通信消息同步方法,通过在获取到待同步的n条通信消息以及每条通信消息的消息类型之后,对于每条通信消息,生成包括消息类型以及消息内容的消息数据,并以消息块为单位同步生成的n条消息数据至第二社交应用客户端,这样,由于每条消息数据中包括消息类型和消息内容,所以第二社交应用客户端可以根据接收到的消息数据解析出对应的通信消息;解决了相关技术中在同步通信消息至其他平台之后,其他平台中的社交应用客户端可能无法识别该通信消息的问题;达到了可以实现跨平台的通信消息 同步的效果。
在上述实施例中,步骤202可以包括如下两种可能的实现方式:
第一种,若消息类型为文本,则生成包括消息类型和消息内容的消息数据;若消息类型为图片或者音视频,生成包括消息类型以及数据标识的消息体,并生成包括消息内容的媒体数据,数据标识用于指向媒体数据,消息体和媒体数据构成消息数据。由于图片和音视频的数据量一般要大于文本,将图片或音视频独立于消息体之外,单独生成媒体数据,可以避免消息体的数据量过大。
第二种,生成包括消息类型以及消息内容的消息数据。
因此,下述将在不同实施例中分别对上述两种情况做说明。
请参考图3A,其示出了本发明一个实施例提供的通信消息同步方法的方法流程图,本实施例以该方法用于图1所示的应用场景且以通过上述第一种生成方式生成消息数据来举例说明,如图3A所示,该通信消息同步方法可以包括:
步骤301,第一社交应用客户端获取第一社交应用客户端中待同步的n条通信消息以及每条通信消息的消息类型,n为大于等于1的整数。
本步骤与步骤201类似,在此不再赘述。
步骤302,对于每条通信消息,若消息类型为文本,则第一社交应用客户端生成包括消息类型和消息内容的消息数据;若消息类型为图片或者音视频,则第一社交应用客户端生成包括消息类型以及数据标识的消息体,并生成包括消息内容的媒体数据,数据标识用于指向媒体数据,消息体和媒体数据构成消息数据。
其中,数据标识唯一指向媒体数据。
第一社交应用客户端在获取到n条通信消息之后,提取每条通信消息中在各个平台中均有用的字段,也即提取出每条通信消息的消息内容,根据消息内容和消息类型生成消息数据。
比如,n条通信消息中包括与小明聊天的4条聊天消息、与小花聊天的18条聊天消息以及与小刚聊天的5条聊天消息,则以与小明聊天的4条聊天消息为例,请参考图3B,对于每条聊天消息,第一社交应用客户端生成图中所示的消息数据。参见图3B,针对消息类型为文本的聊天消息“在么”,会生成包括消息类型“文本”和消息内容“在么”的消息数据,针对消息类型为音频的聊 天消息,会生成包括消息类型“音频”和数据标识“音频ID1”的消息体,并生成包括“音频消息1”的媒体数据,消息体和媒体数据构成消息数据,且数据标识“音频ID1”指向“音频消息1”。
需要说明的是,上述实施例只是以消息数据中包括上述内容来举例,可选地,消息数据中还可以包括其他内容,本实施例对此并不做限定。
步骤303,n条通信消息来自m个会话,对于每个会话,第一社交应用客户端生成消息块。
可选地,第一社交应用客户端可以根据会话中的各条通信消息所对应的消息数据的总大小,和/或,会话中的通信消息的条数,为会话生成至少一个消息块。
其中,第一社交应用客户端根据会话中的各条通信消息所对应的消息数据的总大小为会话生成至少一个消息块可以包括:第一社交应用客户端根据各条消息数据中的媒体数据的总大小生成至少一个消息块。比如,消息块所对应的各条媒体数据的总大小的最大值为80M,会话中的各条通信消息所对应的消息数据中的媒体数据的总大小为200M,则第一社交应用客户端可以为该会话生成3个消息块,每个消息块所对应的媒体数据的总大小不超过80M。
以第一社交应用客户端根据会话中的通信消息的条数生成消息块来举例,假设每个消息块最多能存储的通信消息的条数为10条,某一会话中的通信消息有35条,则第一社交应用客户端可以为该会话生成4个消息块,每个消息块中存储的通信消息不超过10条。
步骤304,对于任一会话中的任一通信消息i,如果通信消息i的消息数据包括消息体和媒体数据,则第一社交应用客户端将通信消息i的消息体按预设顺序存储至通信消息i所属会话对应的消息块中。
其中,预设顺序为接收到会话中的各条通信消息的先后顺序。每个消息块对应于至少一条消息数据,且在对应于至少两条消息数据时,至少两条消息数据所对应的通信消息属于同一会话。
可选地,若通信消息i的消息数据包括消息类型和消息内容,则第一社交应用客户端将该消息数据按预设顺序存储至通信消息i所属会话对应的消息块中。
比如,以存储与小明的4条聊天消息所对应的消息数据为例,第一社交应用客户端可以得到图3C所示的消息块。
可选地,在存储通信消息i的消息数据之前,还包括:
检测消息块是否满足存储条件,存储条件包括:消息块中的数据标识所对应的媒体数据以及通信消息i的消息数据中的媒体数据的总大小未达到预设大小、消息块中的消息数据的条数未达到预设条数或者同时包括上述两者。
预设大小为***设置的大小或者用户自定义的大小,比如预设大小为***设置的80M。预设条数也可以为***设置或者用户自定义的条数,比如,预设条数可以为***设置的2000条。
以存储条件包括消息块中的数据标识所对应的媒体数据以及通信消息i的消息数据中的媒体数据的总大小未达到预设大小为例,第一社交应用客户端可以获取消息块中的各个消息体中存储的数据标识,统计各个数据标识所对应的媒体数据与通信消息i的消息数据中的媒体数据的总大小,检测统计得到的总大小是否达到预设大小。其中,若通信消息i的消息数据中不包括媒体数据,则通信消息i的消息数据中的媒体数据的大小即为0。
以存储条件包括消息块中的消息数据的条数未达到预设条数为例,第一社交应用客户端可以统计消息块中所对应的通信消息的条数,检测统计得到的条数是否达到预设条数。
若存储条件同时包括上述两者,则第一社交应用客户端可以同时执行上述两种检测,本实施例对此并不做限定。
若检测结果为消息块满足存储条件,则在通信消息i所对应的消息数据包括消息类型和消息内容时,存储该消息数据至消息块;在通信消息i所对应的消息数据包括消息体和消息内容时,存储消息体至该消息块。
而若检测结果为消息块不满足存储条件,则说明该消息块中不能继续存储数据,此时在通信消息i所对应的消息数据包括消息类型和消息内容时,第一社交应用客户端可以存储该消息数据至该会话所对应的下一个消息块;在通信消息i所对应的消息数据包括消息体和消息内容时,存储消息体至该会话所对应的下一个消息块。
比如,以预设大小为80M,且存储与小花聊天的18条聊天消息为例,在按照聊天的先后顺序存储至第15条聊天消息所对应的消息数据时,第一社交应用客户端检测到在存储第15条消息数据之后,消息块所对应的媒体数据的总大小超过80M,此时,第一社交应用客户端可以存储第15条及其以后的聊天消息所对应的消息数据至下一个消息块,其具体存储方式与上述类似。
需要说明的是,本实施例只是以先执行步骤303后执行步骤304为例,可选地,步骤303和步骤304还可以交叉执行。比如,对于每个会话,第一社交应用客户端可以先生成一个消息块,并在该消息快中不能继续存储数据时,生成新的消息块,并存储数据至新生成的消息块,本实施例对其具体实现方式并不做限定。
步骤305,第一社交应用客户端同步每个消息块以及每个消息块中的数据标识所对应的媒体数据至第二社交应用客户端。
与上述实施例类似,第一社交应用客户端可以先同步每个消息块以及每个消息块中的数据标识所对应的媒体数据至服务器,由服务器转发至第二社交应用客户端;或者,第一社交应用客户端直接同步至第二社交应用客户端,本实施例对此并不做限定。
步骤306,第二社交应用客户端接收第一社交应用客户端同步的每个消息块以及每个消息块中的数据标识所对应的媒体数据。
步骤307,第二社交应用客户端存储每个消息块至消息文件,并存储消息块中的数据标识所对应的媒体数据至媒体文件,消息文件和媒体文件构成数据文件。
可选地,受终端设备读取文件时对文件大小的需求,消息文件设置有大小阈值,如最大为2G,类似的,媒体文件也设置有大小阈值,如同样为2G。这也就是说,在存储各个消息块至消息文件时,在存储某一消息块至消息文件之前,检测该消息文件的大小与该消息块的大小的总和是否达到大小阈值,若未达到,则存储该消息块至该消息文件;而若达到大小阈值,则存储该消息块至新生成的消息文件,本实施例对此并不做限定。
类似的,在存储媒体数据至媒体文件之前,检测媒体文件的大小与媒体数据的大小的总和是否达到大小阈值,若未达到,则存储该媒体数据至该媒体文件,而若达到,则存储该媒体数据至新生成的媒体文件,本实施例对此并不做限定。
请参考图3D,其示出了第二社交应用客户端得到的消息文件和媒体文件的一种可能的示意图。
需要说明的是,实际实现时,消息文件可以有一个也可以有至少两个,本实施例对其个数并不做限定;类似的,媒体文件也可以有一个或者至少两个,对此也不做限定。
步骤308,第二社交应用客户端确定每个消息块在数据文件中的存储位置。
实际实现时,由于消息块存储在数据文件中的消息文件中,因此,第二社交应用客户端可以确定每个消息块在消息文件中的存储位置。其中,该存储位置可以通过消息块在消息文件中的起始存储位置和长度来表示,或者,通过消息块在消息文件中的起始存储位置以及结束存储位置来表示,本实施例对此并不做限定。
步骤309,第二社交应用客户端确定各个媒体数据在媒体文件中的存储位置。
与步骤308类似,在媒体文件中的存储位置可以通过媒体数据在媒体文件中的起始存储位置和长度来表示,或者,通过媒体数据在媒体文件中的起始存储位置以及结束存储位置来表示,本实施例对此并不做限定。
步骤310,第二社交应用客户端生成并保存对应关系。
对应关系包括消息块、消息块所对应的会话以及消息块的存储位置之间的对应关系以及数据标识与媒体数据在媒体文件中的存储位置之间的对应关系,消息块所对应的会话为消息块中的消息数据所对应的通信消息所属的会话。
请参考下表,其示出了一种可能的消息块、消息块所对应的会话以及消息块的存储位置之间的对应关系。其中,起始位置2=起始位置1+长度1,起始位置3=起始位置2+长度2,起始位置4=起始位置3+长度3。
消息块 消息块所对应的会话 存储位置
消息块1 小明 起始位置1+长度1
消息块2 小花 起始位置2+长度2
消息块3 小花 起始位置3+长度3
消息块4 小刚 起始位置4+长度4
第二社交应用客户端生成对应关系之后,可以保存生成的对应关系至索引文件。其中,该索引文件为用于存储各个对应关系的文件。比如,请参考图3E,其示出了在本实施例中第二社交应用客户端存储的数据文件和索引文件的示意图。
综上所述,本实施例提供的通信消息同步方法,通过在获取到待同步的n条通信消息以及每条通信消息的消息类型之后,对于每条通信消息,生成包括消息类型以及消息内容的消息数据,并以消息块为单位同步生成的n条消息数据至第二社交应用客户端,这样,由于每条消息数据中包括消息类型和消息内 容,所以第二社交应用客户端可以根据接收到的消息数据解析出对应的通信消息;解决了相关技术中在同步通信消息至其他平台之后,其他平台中的社交应用客户端可能无法识别该通信消息的问题;达到了可以实现跨平台的通信消息同步的效果。
通过在存储消息数据之前,先检测消息块是否满足存储条件,降低了在消息块所对应的媒体数据的总大小过大,或者消息块过大时,在消息块同步失败后,重新同步该消息块以及该消息块所对应的媒体数据时所需耗费的网络资源。
当消息块对应于至少两条消息数据时,上述方法避免了每次同步一条消息数据时,由于封装时使用的包头而导致同步过程中需要耗费一定的网络资源的问题。
请参考图4A,其示出了本发明一个实施例提供的通信消息同步方法的方法流程图,本实施例以该方法用于图1所示的应用场景中来举例说明,如图4A所示,该通信消息同步方法可以包括:
步骤401,第一社交应用客户端获取第一社交应用客户端中待同步的n条通信消息以及每条通信消息的消息类型,n为大于等于1的整数。
本步骤与步骤201类似,在此不再赘述。
步骤402,对于每条通信消息,第一社交应用客户端生成包括消息类型以及消息内容的消息数据。
本步骤与步骤302的区别在于,在本实施例中,不论消息类型如何,第一社交应用客户端均直接生成包括消息类型以及消息内容的消息数据。
比如,对于图3B所示的与小明的聊天消息,请参考图4B,第一社交应用客户端可以生成图4B所示的4条消息数据。
步骤403,n条通信消息来自m个会话,对于每个会话,第一社交应用客户端生成消息块。
步骤404,对于任一会话中的任一通信消息i,将通信消息i的消息数据按预设顺序存储至通信消息i所属会话对应的消息块中。
本步骤与步骤304类似,不同的是,步骤304中,存储消息体至消息块,而在本实施例中直接存储消息数据至消息块,在此不再赘述。
步骤405,第一社交应用客户端同步每个消息块至第二社交应用客户端。
步骤406,第二社交应用客户端接收第一社交应用客户端同步的各个消息块。
步骤407,第二社交应用客户端存储每个消息块至数据文件。
步骤408,第二社交应用客户端确定每个消息块在数据文件中的存储位置。
步骤409,第二社交应用客户端生成并保存对应关系。
综上所述,本实施例提供的通信消息同步方法,通过在获取到待同步的n条通信消息以及每条通信消息的消息类型之后,对于每条通信消息,生成包括消息类型以及消息内容的消息数据,并以消息块为单位同步生成的n条消息数据至第二社交应用客户端,这样,由于每条消息数据中包括消息类型和消息内容,所以第二社交应用客户端可以根据接收到的消息数据解析出对应的通信消息;解决了相关技术中在同步通信消息至其他平台之后,其他平台中的社交应用客户端可能无法识别该通信消息的问题;达到了可以实现跨平台的通信消息同步的效果。
当消息块对应于至少两条消息数据时,避免了每次同步一条消息数据时,由于封装时使用的包头而导致同步过程中需要耗费一定的网络资源的问题。
在上述各个实施例中,需要补充说明的一点是,在第一社交应用客户端同步消息块所对应的消息数据至第二社交应用客户端之前,第一社交应用客户端还可以执行如下步骤:
获取每个消息块所对应的时间信息,时间信息的起始时刻为消息块中的首条消息数据所对应的通信消息的接收时间,时间信息的结束时刻为消息块中的最后一条消息数据所对应的通信消息的接收时间。
其中,若消息块只对应于一条通信消息,则该消息块所对应的时间信息为接收该通信消息的时间,本实施例对此并不做限定。
仍然以与小明聊天的4条聊天消息为例,第一条聊天消息的时间为15:31:20,第四条聊天消息的时间为15:33:35,则4条聊天消息所对应的消息块1的时间信息为15:31:20~15:33:35。
在同步消息块所对应的消息数据至第二社交应用客户端时,同步消息块所对应的时间信息至第二社交应用客户端。
第二社交应用客户端接收到该时间信息之后,生成的第一对应关系包括消息块、消息块所对应的会话、消息块的存储位置以及消息块所对应的时间段之 间的对应关系。
Figure PCTCN2017107471-appb-000001
此后,第二社交应用客户端需要触发第一社交应用客户端执行同步时,第二社交应用客户端可以执行如下步骤:
第一,第二社交应用客户端根据保存的对应关系确定各个会话的时间戳信息,时间戳信息为第二社交应用客户端根据保存的对应关系确定的各个会话中最后一条消息数据所对应的通信消息的接收时间。
由于第二社交应用客户端中存储的对应关系中包括消息块、消息块所对应的会话、消息块所对应的时间信息以及消息块所对应的存储位置之间的对应关系,因此,第二社交应用客户端可以根据存储的各个对应关系确定每个会话的时间戳信息。
比如,对于与小明的会话,第二社交应用客户端确定得到的时间戳信息为9:30:37。
第二,第二社交应用客户端发送时间戳信息至第一社交应用客户端。
相应的,第一社交应用客户端接收第二社交应用客户端发送的各个会话的时间戳信息。
此后,对于每个会话,第一社交应用客户端根据会话的时间戳信息获取在时间戳信息之后接收到的会话中的各条通信消息,并获取各条通信消息的消息类型。
在一个实际应用场景中,用户在PC(Personal Computer,个人电脑)中登录第二社交应用客户端,第二社交应用客户端上报PC的IP地址和端口至服务器;服务器检测在手机中的第一社交应用客户端是否在线,若在线,则发送 PC的IP地址和端口至手机,手机接收到IP地址和端口之后建立与PC之间的直连。PC根据本地存储的索引文件确定各个会话的时间戳信息,通过建立的直连发送时间戳信息至手机,手机接收到各个时间戳信息之后,根据各个时间戳信息获取各个会话中在该时间戳信息之后增加的通信消息,并生成每条通信消息所对应的消息数据,以消息块为单位同步生成的n条消息数据至第二社交应用客户端。第二社交应用客户端接收到之后,存储至数据文件,创建并保存对应关系。其中,若服务器的检测结果为第一社交应用客户端不在线,则此时提示第二社交应用客户端本次同步失败。
上述实施例只是以通过时间信息来标记通信消息的同步进度来举例,实际实现时,第一社交应用客户端还可以为每条通信消息分配序号,并在同步消息块至第二社交应用客户端时,同步该消息块所对应的序号范围至第二社交应用客户端。也即,第二社交应用客户端中可以保存各个消息块中最后一条通信消息的序号,这样,在第二社交应用客户端上线之后,第二社交应用客户端可以发送各个会话的最后一条通信消息的序号至第一社交应用客户端,而第一社交应用客户端根据该序号获取会话中序号在该序号之后的各条通信消息,本实施例对其具体实现并不做限定。
需要补充说明的第二点是,第一社交应用客户端还可以获取每个会话的会话信息,比如,会话的昵称、备注等等,然后以消息块为单位同步消息数据至第二社交应用客户端时,同步消息块所对应的会话信息至第二社交应用客户端。相应的,第二社交应用客户端可以接收该会话消息,并在索引文件中存储该会话信息,本实施例对此并不做限定。
需要补充说明的第三点是,在第一社交应用客户端同步n条消息数据至第二社交应用客户端之前,为了保证数据传输的安全性,第一社交应用客户端还可以先对n条消息数据进行加密。可选地,第一社交应用客户端可以发送密钥获取请求至服务器,接收服务器返回的密钥,根据接收到的密钥对消息数据进行加密。其中,不同帐号的社交应用客户端发送密钥获取请求至服务器之后,获取到的密钥可以不同。可选地,第一社交应用客户端中还可以存储有公钥,并在发送密钥获取请求时发送携带有该公钥的密钥获取请求,服务器接收到该密钥获取请求之后,获取该公钥对应的加密方法,反馈获取到的加密方法至第 一社交应用客户端,第一社交应用客户端根据接收到的加密方法执行加密。其中,第一社交应用客户端可以对n条消息数据以消息块为单位进行加密,对此并不做限定。这样,第二社交应用客户端在需要对消息数据所对应的通信消息进行重建时,第二社交应用客户端也需要采用类似方法从服务器获取解密密钥或者获取解密方法,本实施例对此并不做限定。
需要补充说明的第四点是,在上述各个实施例中,在第二客户端需要重建会话中的通信消息时,上述通信消息同步方法还可以包括如下步骤:
第二社交应用客户端根据保存的对应关系重建各个消息块所对应的各条通信消息。
此后,第二社交应用客户端在对会话中的通信消息进行重建时,第二社交应用客户端可以根据保存的对应关系读取到会话所对应的消息块中的内容,并在消息块中包括数据标识时,根据数据标识与媒体数据在媒体文件中的存储位置之间的对应关系从媒体文件中读取对应的媒体数据,此后,即可重建出各条通信消息。可选地,第二社交应用客户端可以从存储对应关系的索引文件中先读取出对应关系,然后再根据读取到的对应关系重建通信消息,本实施例对此并不做限定。
比如,结合图3B,以重建与小明的聊天消息为例,第二社交应用客户端可以根据会话‘小明’查找到对应的消息块1的存储位置为起始位置1+长度1。并从该存储位置中读取出该消息块1的内容,也即图3C所示的内容,此后,根据数据标识与媒体数据的存储位置之间的对应关系即可从媒体文件中读取到图3C中音频消息1以及音频消息2,这样,即可恢复出与小明的聊天记录。
需要补充说明的是,对应关系还包括消息块与消息块中的消息体中的数据标识之间的对应关系。以消息块1为例,第二社交应用客户端还可以生成下表所示的对应关系。
消息块1 音频ID1,音频ID2
通过生成包括消息块与消息块中的消息体中的数据标识之间的对应关系,使得在根据消息块进行通信消息重建时,无需等待遍历消息块中的各个条目之后才能读取对应的媒体数据,通信消息的重建效率较低的问题,达到了可以根据存储的上述对应关系直接读取到数据标识,进而快速加载对应的媒体数据,提高通信消息的重建效率的效果。
重建通信消息时,第二社交应用客户端可以在会话窗口中显示会话对应的通信消息。可选地,第二社交应用客户端可以按照每条通信消息的接收时间从早到晚的顺序对通信消息进行排序,当第二社交应用客户端打开该会话窗口时,按照接收时间从早到晚的顺序显示每条通信消息,且用户触发上下滑动的操作,还可以切换显示的通信消息,以便用户对不同的通信消息进行浏览。
需要补充说明的第五点是,上述只是以第二社交应用客户端直接以消息块为单位存储消息数据至数据文件为例,可选地,第二社交应用客户端还可以将接收到的以消息块为单位的n条消息数据划分为粒度更小的消息块,或者合并为粒度更大的消息块,比如,合并为同一会话对应于一个消息块,本实施例对此并不做限定。
需要补充说明的第六点是,上述实施例中关于第一社交应用客户端侧的步骤可以单独实现成为第一社交应用客户端侧的通信消息同步方法,而关于第二社交应用客户端侧的步骤可以单独实现成为第二社交应用客户端侧的通信消息同步方法。
请参考图5,其示出了本发明一个实施例提供的通信消息同步装置的结构示意图,该通信消息同步装置用于图1所示的第一社交应用客户端中。如图5所示,该通信消息同步装置可以包括:第一获取模块510、生成模块520和同步模块530。
第一获取模块510,用于获取所述第一社交应用客户端中待同步的n条通信消息以及每条通信消息的消息类型,n为大于等于1的整数;
生成模块520,用于对于每条通信消息,生成包括所述通信消息的消息类型以及所述通信消息的消息内容的消息数据;
同步模块530,用于以消息块为单位同步生成的n条消息数据至第二社交应用客户端;第二社交应用客户端以消息块为单位存储n条消息数据至数据文件,生成并保存对应关系;每个消息块对应于至少一条消息数据,且在对应于至少两条消息数据时,至少两条消息数据所对应的通信消息属于同一会话,第二社交应用客户端与第一社交应用客户端类型相同且共用同一社交帐号;对应关系包括消息块、消息块所对应的会话以及消息块的存储位置之间的对应关 系,消息块所对应的会话为消息块中的消息数据所对应的通信消息所属的会话。
综上所述,本实施例提供的通信消息同步装置,通过在获取到待同步的n条通信消息以及每条通信消息的消息类型之后,对于每条通信消息,生成包括消息类型以及消息内容的消息数据,并以消息块为单位同步生成的n条消息数据至第二社交应用客户端,这样,由于每条消息数据中包括消息类型和消息内容,所以第二社交应用客户端可以根据接收到的消息数据解析出对应的通信消息;解决了相关技术中在同步通信消息至其他平台之后,其他平台中的社交应用客户端可能无法识别该通信消息的问题;达到了可以实现跨平台的通信消息同步的效果。
基于上述实施例提供的通信消息同步装置,可选的,若所述消息类型为图片或者音视频,所述生成模块520,还用于生成包括所述消息类型以及数据标识的消息体,并生成包括所述消息内容的媒体数据,所述数据标识用于指向所述媒体数据,所述消息体和所述媒体数据构成所述消息数据。
可选的,所述同步模块530,包括:
生成单元,用于所述n条通信消息来自m个会话,对于每个会话,生成消息块,m为正整数;
同步单元,用于对于任一会话中的任一通信消息i,如果所述通信消息i的消息数据包括消息体和媒体数据,则将所述通信消息i的消息体按预设顺序存储至所述通信消息i所属会话对应的消息块中,在同步所述通信消息i的消息数据时,同步所述通信消息i所属会话对应的消息块及所述通信消息i的媒体数据至所述第二社交应用客户端,所述预设顺序为接收到通信消息的先后顺序。
可选的,所述同步模块530,包括:
生成单元,用于所述n条通信消息来自m个会话,对于每个会话,生成消息块,m为正整数;
同步单元,用于对于任一会话中的任一通信消息i,将所述通信消息i的消息数据按预设顺序存储至所述通信消息i所属会话对应的消息块中,在同步所述通信消息i的消息数据时,同步所述通信消息i所属会话对应的消息块至所述第二社交应用客户端,所述预设顺序为接收到通信消息的先后顺序。
可选的,所述生成单元,还用于根据会话中的各条通信消息所对应的消息 数据的总大小,和/或,所述会话中的通信消息的条数,为所述会话生成至少一个消息块。
可选的,所述装置还包括:
第二获取模块,用于获取每个消息块所对应的时间信息,所述时间信息的起始时刻为所述消息块中的首条消息数据所对应的通信消息的接收时间,所述时间信息的结束时刻为所述消息块中的最后一条消息数据所对应的通信消息的接收时间;
所述同步模块530,还用于在同步每个消息块至所述第二社交应用客户端时,同步所述消息块所对应的时间信息至所述第二社交应用客户端。
可选的,所述第一获取模块510,包括:
接收单元,用于接收所述第二社交应用客户端发送的各个会话的时间戳信息,所述时间戳信息为所述第二社交应用客户端根据保存的对应关系确定的各个会话中最后一条消息数据所对应的通信消息的接收时间;
获取单元,用于对于每个会话,根据所述会话的时间戳信息获取在所述时间戳信息之后接收到的所述会话中的各条通信消息,并获取各条通信消息的消息类型。
请参考图6,其示出了本发明一个实施例提供的通信消息同步装置的结构示意图,该通信消息同步装置用于图1所示的第二社交应用客户端中。如图6所示,该通信消息同步装置可以包括:第一接收模块610、存储模块620、和生成模块630。
第一接收模块610,用于接收第一社交应用客户端以消息块为单位同步的n条消息数据;所述第一社交应用客户端与所述第二社交应用客户端类型相同且共用同一社交帐号;每条消息数据为所述第一社交应用客户端生成的包括一条通信消息的消息类型以及消息内容的数据;每个消息块对应于至少一条消息数据,且在对应于至少两条消息数据时,所述至少两条消息数据所对应的通信消息属于同一会话;
存储模块620,用于以所述消息块为单位存储所述n条消息数据至数据文件;
生成模块630,用于生成并保存对应关系;所述对应关系包括消息块、所述消息块所对应的会话以及所述消息块的存储位置之间的对应关系,所述消息 块所对应的会话为所述消息块中的消息数据所对应的通信消息所属的会话。
综上所述,本实施例提供的通信消息同步装置,通过在获取到待同步的n条通信消息以及每条通信消息的消息类型之后,对于每条通信消息,生成包括消息类型以及消息内容的消息数据,并以消息块为单位同步生成的n条消息数据至第二社交应用客户端,这样,由于每条消息数据中包括消息类型和消息内容,所以第二社交应用客户端可以根据接收到的消息数据解析出对应的通信消息;解决了相关技术中在同步通信消息至其他平台之后,其他平台中的社交应用客户端可能无法识别该通信消息的问题;达到了可以实现跨平台的通信消息同步的效果。
基于上述实施例提供的通信消息同步装置,可选的,
所述第一接收模块610,还用于接收所述第一社交应用客户端同步的每个消息块以及消息块中的数据标识所对应的媒体数据;其中,消息块中包括消息体,所述消息体中包括通信消息的消息类型以及数据标识,所述媒体数据中包括所述通信消息的消息内容,所述数据标识指向所述媒体数据;
所述存储模块620,还用于存储每个消息块至消息文件,并存储所述消息块中的数据标识所对应的媒体数据至媒体文件,所述消息文件和所述媒体文件构成所述数据文件;
所述对应关系还包括数据标识与媒体数据在所述媒体文件中的存储位置之间的对应关系。
可选的,所述对应关系还包括消息块与消息块中的消息体中的数据标识之间的对应关系。
可选的,所述装置还包括:
第二接收模块,用于接收所述第一社交应用客户端同步的每个消息块所对应的时间信息;所述时间信息的起始时刻为所述消息块中的首条消息数据所对应的通信消息的接收时间,所述时间信息的结束时刻为所述消息块中的最后一条消息数据所对应的通信消息的接收时间;
所述对应关系还包括消息块与所述消息块所对应的时间信息之间的对应关系。
可选的,所述装置还包括:
确定模块,用于根据保存的对应关系确定各个会话的时间戳信息,所述时间戳信息为所述第二社交应用客户端根据所述保存的对应关系确定的各个会 话中最后一条消息数据所对应的通信消息的接收时间;
发送模块,用于发送所述时间戳信息至所述第一社交应用客户端。
需要说明的是:上述实施例提供的通信消息同步装置,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将社交应用客户端的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的通信消息同步装置和通信消息同步方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。
本发明实施例还提供了一种计算机可读存储介质,该计算机可读存储介质可以是上述实施例中的存储器中所包含的计算机可读存储介质;也可以是单独存在,未装配入终端中的计算机可读存储介质。该计算机可读存储介质存储有一个或者一个以上程序,该一个或者一个以上程序被一个或者一个以上的处理器用来执行通信消息同步方法。
图7其示出了本发明一个实施例提供的终端700的框图,该终端可以包括射频(RF,Radio Frequency)电路701、包括有一个或一个以上计算机可读存储介质的存储器702、输入单元703、显示单元704、传感器705、音频电路706、无线保真(WiFi,Wireless Fidelity)模块707、包括有一个或者一个以上处理核心的处理器708、以及电源709等部件。本领域技术人员可以理解,图7中示出的终端结构并不构成对终端的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。其中:
RF电路701可用于收发信息或通话过程中,信号的接收和发送,特别地,将基站的下行信息接收后,交由一个或者一个以上处理器708处理;另外,将涉及上行的数据发送给基站。通常,RF电路701包括但不限于天线、至少一个放大器、调谐器、一个或多个振荡器、用户身份模块(SIM,Subscriber Identity Module)卡、收发信机、耦合器、低噪声放大器(LNA,Low Noise Amplifier)、双工器等。此外,RF电路701还可以通过无线通信与网络和其他设备通信。所述无线通信可以使用任一通信标准或协议,包括但不限于全球移动通讯***(GSM,Global System of Mobile communication)、通用分组无线服务(GPRS, General Packet Radio Service)、码分多址(CDMA,Code Division Multiple Access)、宽带码分多址(WCDMA,Wideband Code Division Multiple Access)、长期演进(LTE,Long Term Evolution)、电子邮件、短消息服务(SMS,Short Messaging Service)等。
存储器702可用于存储软件程序以及模块,处理器708通过运行存储在存储器702的软件程序以及模块,从而执行各种功能应用以及数据处理。存储器702可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作***、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据终端的使用所创建的数据(比如音频数据、电话本等)等。此外,存储器702可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。相应地,存储器702还可以包括存储器控制器,以提供处理器708和输入单元703对存储器702的访问。
输入单元703可用于接收输入的数字或字符信息,以及产生与用户设置以及功能控制有关的键盘、鼠标、操作杆、光学或者轨迹球信号输入。具体地,在一个具体的实施例中,输入单元703可包括触敏表面以及其他输入设备。触敏表面,也称为触摸显示屏或者触控板,可收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触敏表面上或在触敏表面附近的操作),并根据预先设定的程式驱动相应的连接装置。可选的,触敏表面可包括触摸检测装置和触摸控制器两个部分。其中,触摸检测装置检测用户的触摸方位,并检测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸检测装置上接收触摸信息,并将它转换成触点坐标,再送给处理器708,并能接收处理器708发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触敏表面。除了触敏表面,输入单元703还可以包括其他输入设备。具体地,其他输入设备可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆等中的一种或多种。
显示单元704可用于显示由用户输入的信息或提供给用户的信息以及终端的各种图形用户接口,这些图形用户接口可以由图形、文本、图标、视频和其任意组合来构成。显示单元704可包括显示面板,可选的,可以采用液晶显示器(LCD,Liquid Crystal Display)、有机发光二极管(OLED,Organic  Light-Emitting Diode)等形式来配置显示面板。进一步的,触敏表面可覆盖显示面板,当触敏表面检测到在其上或附近的触摸操作后,传送给处理器708以确定触摸事件的类型,随后处理器708根据触摸事件的类型在显示面板上提供相应的视觉输出。虽然在图7中,触敏表面与显示面板是作为两个独立的部件来实现输入和输入功能,但是在某些实施例中,可以将触敏表面与显示面板集成而实现输入和输出功能。
终端还可包括至少一种传感器705,比如光传感器、运动传感器以及其他传感器。具体地,光传感器可包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板的亮度,接近传感器可在终端移动到耳边时,关闭显示面板和/或背光。作为运动传感器的一种,重力加速度传感器可检测各个方向上(一般为三轴)加速度的大小,静止时可检测出重力的大小及方向,可用于识别手机姿态的应用(比如横竖屏切换、相关游戏、磁力计姿态校准)、振动识别相关功能(比如计步器、敲击)等;至于终端还可配置的陀螺仪、气压计、湿度计、温度计、红外线传感器等其他传感器,在此不再赘述。
音频电路706、扬声器,传声器可提供用户与终端之间的音频接口。音频电路706可将接收到的音频数据转换后的电信号,传输到扬声器,由扬声器转换为声音信号输出;另一方面,传声器将收集的声音信号转换为电信号,由音频电路706接收后转换为音频数据,再将音频数据输出处理器708处理后,经RF电路701以发送给比如另一终端,或者将音频数据输出至存储器702以便进一步处理。音频电路706还可能包括耳塞插孔,以提供外设耳机与终端的通信。
WiFi属于短距离无线传输技术,终端通过WiFi模块707可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图7示出了WiFi模块707,但是可以理解的是,其并不属于终端的必须构成,完全可以根据需要在不改变发明的本质的范围内而省略。
处理器708是终端的控制中心,利用各种接口和线路连接整个手机的各个部分,通过运行或执行存储在存储器702内的软件程序和/或模块,以及调用存储在存储器702内的数据,执行终端的各种功能和处理数据,从而对手机进行整体监控。可选的,处理器709可包括一个或多个处理核心;优选的,处理器708可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作***、用户界面和应用程序等,调制解调处理器主要处理无线通信。可以理解 的是,上述调制解调处理器也可以不集成到处理器708中。
终端还包括给各个部件供电的电源709(比如电池),优选的,电源可以通过电源管理***与处理器709逻辑相连,从而通过电源管理***实现管理充电、放电、以及功耗管理等功能。电源709还可以包括一个或一个以上的直流或交流电源、再充电***、电源故障检测电路、电源转换器或者逆变器、电源状态指示器等任意组件。
尽管未示出,终端还可以包括摄像头、蓝牙模块等,在此不再赘述。具体在本实施例中,终端中的处理器708会运行存储在存储器702中的一个或一个以上的程序指令,从而实现上述各个方法实施例中所提供的通信消息同步方法。
图8是本发明实施例提供的一种用于数据备份的设备交互示意图,如图8所示,包括第一设备和第二设备,第一设备为数据备份的目标设备,第二设备为数据备份的源设备。
其中,第二设备可以为手机、平板电脑、台式电脑等终端,第二设备上安装有应用,该应用可以为社交应用、多媒体应用等,应用在使用的过程中会产生各种数据。第一设备可以为手机、平板电脑、台式电脑等终端,第一设备还可以为服务器。当第一设备为终端时,第一设备上也可以与第二设备安装有相同的应用,或者第一设备安装有具有应用备份功能的应用。其中,第一设备和第二设备的操作***可以相同也可以不同,本发明实施例对此不作限定。
本实施例的数据备份用于对第二设备上应用的数据进行备份,为了便于描述,将第二设备上需要备份的应用称之为目标应用。基于上述第一设备和第二设备的介绍,本实施例中所需备份的数据流向可以为从终端到终端,或者为从终端到服务器,详细数据备份流程参见下述图9A所提供的具体实施例。
图9A是本发明实施例提供的一种数据备份方法的流程图,参见图9A,交互主体涉及第一设备和第二设备,该方法流程包括:
901、第二设备获取第一设备的设备信息,根据该设备信息与第一设备建立连接。
本实施例中,当第一设备和第二设备均为终端时,第一设备和第二设备可以处于同一个局域网内,二者可以通过有线或者无线的方式建立连接。其中,有线连接方式包括USB连接、网线直连等。无线连接方式包括WiFi(Wireless  Fidelity,无线保真)连接、蓝牙连接等。当第一设备为服务器时可以跳过该步骤901直接执行步骤902。
其中,第一设备可以与第二设备同样安装有目标应用,也可以未安装有目标应用。用户可以通过第一设备触发数据备份流程,比如,当第一设备安装有目标应用时,可以在目标应用的功能界面上提供有用于实现数据备份的数据备份选项,使得用户可以通过点击该数据备份选项来触发数据备份流程。另外,在未安装有目标应用时,第一设备可以安装有为目标应用提供备份服务的指定应用,该指定应用的功能界面上提供有目标应用备份的数据备份选项,使得用户可以通过点击该数据备份选项来触发数据备份流程。
当然,用户也可以通过第二设备触发数据备份流程,比如,当第二设备检测到对目标应用的数据备份选项的触发操作时,显示目标应用的会话列表,用户可以在该会话列表中选择需要备份的目标会话;当第二设备检测到目标会话的选取确认操作时,触发数据备份流程。比如,用户可以在会话列表中选取会话1和会话2作为目标会话等。此外,第二设备也可以根据预设周期自动触发备份,该预设周期可以由服务器或者第二设备预先设置或更改,本实施例对此不作限定。在触发备份流程之后,第一设备检测是否与第二设备已经建立连接,如果未建立连接,则执行与第二设备建立连接的过程。如果已建立连接,则向第二设备发送备份指令,由第二设备接收到备份指令后,执行步骤902。
下面以用户通过第一设备触发数据备份流程为例,对第二设备与第一设备建立连接的过程进行介绍:
在第一设备上触发数据备份流程之后,第二设备需要与第一设备建立连接,从而进行数据备份。例如,第二设备可以通过获取的第一设备的设备信息来和第一设备建立连接。其中,第一设备的设备信息包括第一设备的IP地址和提供数据备份服务的端口号。第二设备获取第一设备的设备信息的方式可以包括以下三种中的任一种:
第一种方式、第二设备通过服务器获取第一设备的设备信息。
该种方式中,第一设备与第二设备同样安装有目标应用,且登录有相同的账号。当第一设备检测到该数据备份选项的触发操作时,向服务器发送备份流程发起消息,该备份流程发起消息携带第一设备的设备信息和登录目标应用的第一账号。服务器根据第一账号,向登录有相同账号的第二设备发送备份流程发起指示,该备份流程发起指示中携带第一设备的设备信息,从而使得第二设 备获取到第一设备的设备信息。当然,该备份流程发起指示还可以不携带第一设备的设备信息,而是由第二设备接收到该备份流程发起指示后从服务器拉取该第一设备的设备信息,本发明实施例对此不作限定。
第二种方式、第二设备通过第一设备的设备信息广播消息获取第一设备的设备信息。
该种方式中,第一设备可以安装有目标应用,也可以未安装有目标应用。当第一设备检测到对目标应用的数据备份选项的触发操作时,在局域网内广播自身的设备信息,当第二设备与第一设备处于同一个局域网时,便可通过局域网监听到该设备信息广播消息,从而从该设备信息广播消息中提取出第一设备的设备信息。
第三种方式、第二设备通过二维码扫描获取第一设备的设备信息。
该种方式中,第一设备可以安装有目标应用,也可以未安装有目标应用。当第一设备检测到对目标应用的数据备份选项的触发操作时,根据自身的设备信息,生成二维码。第二设备通过扫描该二维码来获取第一设备的设备信息。
对于上述第二种方式和第三种方式,当第一设备上安装有目标应用时,该数据备份的流程可以看作为目标应用数据同步的过程。为了保证数据备份的安全性,避免将一个账号的数据同步至另一个账号,第二设备还可以获取第一设备登录目标应用的第一账号。比如,针对上述第二种情况,第一设备还可以将第一账号进行广播,使得第二设备获取到该第一账号。针对上述第三种情况,第一设备生成的二维码中可以包括该第一账号,第二设备通过扫描二维码获取到第一账号。第二设备获取到第一账号后,与本地登录目标应用的第二账号进行对比,如果二者相同,则与第一设备建立连接;如果不相同,则拒绝与第一设备建立连接,同时,第二设备可以显示账号不同提示信息,以提示用户数据备份可能存在风险。
第二设备获取到第一设备的设备信息后,可以通过有线或者无线的方式与第一设备在同一个局域网内建立直接连接,该建立连接的过程可以为:第二设备根据第一设备的IP地址,向第一设备发送数据连接请求。如果第一设备接收到该数据连接请求,则会向第二设备返回一个应答消息。如果第二设备接收到第一设备的应答消息,则说明二者处于同一个局域网内,能够直接建立连接,则第二设备与第一设备建立连接。如果第二设备没有接收到第一设备的应答消息,则确定与第一设备不处于同一个局域网内,不能建立直接连接。此时,为 了保证能够成功为用户进行数据备份,第二设备显示网络连接提示信息,该网络连接提示信息用于指示第二设备与第一设备处于不同的局域网内,比如该网络连接提示信息可以为诸如“请将两个设备连接到同一个局域网”等信息。
当然,有的时候即使第一设备和第二设备处于同一个局域网,也有可能因为网络故障(比如网线没插好,或者路由器故障等)等原因,使得第一设备未接收到第二设备的数据连接请求,或者使得第二设备未接收到第一设备已返回的应答消息。因此,为了向用户反映真实的连接情况,以提高连接的成功率,第二设备在未接收到应答消息时,还可以执行以下步骤:根据第一设备的IP地址和本地IP地址,判断与第二设备是否处于同一局域网。比如,第二设备检测第一设备的IP地址和本地IP地址的网络号是否相同,如果相同,则确定与第一设备处于同一局域网。此时,可以提示用户检查一下网络是存在故障,比如,查看网络线路连接是否正常等。其中,网络号用于指示设备IP地址的局域网标识。
另外,由于不同的无线局域网通常具有不同的SSID(Service Set Identifier,服务集标识),当第一设备或第二设备通过WiFi接入网络时,第一设备的设备信息还可以包括第一设备所处无线局域网的SSID,第二设备可以通过对比第一设备的SSID和本地SSID来确定是否与第一设备处于同一局域网。比如,当二者的SSID不同时,确定二者不处于同一局域网内,此时第二设备显示网络连接提示信息,此时该网络连接提示信息可以用于指示将设备连接至同一WiFi,比如,诸如“请将两个设备连接至同一个WiFi”等信息,这样的提示可以使一些不理解局域网概念的用户,也可以通过提示来将两个设备连接到同一个局域网内,提高了该数据备份方法的普适性,增强了可操作性。
需要说明的是,对于上述获取第一设备的设备信息的第二种方式,由于第一设备的设备信息就是通过局域网广播的,因此,当第二设备接收到第一设备的设备信息时,便可确定与第一设备处于同一局域网内,此时可以直接根据获取到的设备信息与第一设备建立连接。
通过将第一设备和第二设备在同一局域网内建立连接,大大提高了数据备份过程中的数据传输速度,提高了数据备份的效率,同时,由于局域网不容易受到外界干扰,网络稳定性好,因此,提高了数据传输的可靠性,避免了由于丢包而导致备份效率下降的问题。
图9B基于上述第一种方式示出了一种数据备份的流程图,在图9B中当第 一设备检测到数据备份选项的触发操作时,向服务器发送备份流程发起消息,该备份流程发起消息携带第一设备的设备信息和登录目标应用的第一账号。在后续步骤中会对图9B的其他流程进行介绍。
为了保证数据传输的安全性,第一设备和第二设备之间交互的数据为加密数据,具体地,在检测到数据备份流程被触发之后,第一设备检测本地的密钥缓存区是否存储有密钥,如果本地未存储有密钥,则第一设备可以从服务器获取该密钥。第二设备也可以从服务器获取相同的密钥,第一设备和第二设备可以采用该密钥对向对端发送的数据进行加密,而当接收到对端的数据时,可以采用该密钥进行解密。
为了进一步保证建立连接的安全性,第一设备和第二设备还可以交互口令以进行口令验证,该口令验证的过程可以为:第二设备向第一设备发送口令验证消息(Packet Authenticate Request),该口令验证消息中携带待验证的第一口令(比如hello口令);第一设备接收到第一口令后,如果检测到本地存储有该第一口令,则确认对第二设备的口令验证成功,向第二设备发送口令验证成功消息(Packet Authenticate Response),并在该口令验证成功消息中携带待验证的第二口令(比如ok口令),第二设备接收到该第二口令后,如果检测到本地存储有该第二口令,则确认对第一设备的口令验证成功,并向第一设备返回口令验证成功消息,该口令验证成功消息也可由Packet Authenticate Request消息承载。另外,第一设备接收到第二设备的口令验证成功消息后,可以返回口令验证确认消息,以表明验证过程结束,该确认消息也可以由Packet Authenticate Response消息承载。其中,第一口令和第二口令可由服务器分别配置给第二设备和第一设备。
需要说明的是,本实施例提供的第一设备(或第二设备)除了提供数据备份功能之外,还可以在数据备份过程中发生传输中断时,基于中断时备份的进度继续进行数据备份;此外,还可以提供数据恢复功能,并且在数据恢复过程中发生传输中断时,基于中断时恢复的进度继续进行数据恢复。具体实施时,可以在第一设备(或第二设备)上提供相应的功能选项,或者在目标应用的功能界面上提供相应的功能选项,从而使得用户能够触发相应的流程。当用户通过第一设备触发某个流程时,为了使第二设备明确当前触发的哪个流程,第一设备和第二设备建立连接后,向第二设备发送流程类型指示(Backup Command Request),该流程类型指示用于指示数据备份、继续备份、数据恢复、继续恢 复中的一种。第二设备接收到该流程类型指示后返回确认应答消息(Backup Command Response)。后续,第二设备在准备就绪时,还可以向第一设备发送准备就绪指示,该准备就绪指示也可以由Backup Command Request消息承载,由第一设备接收到该准备就绪指示后返回确认应答消息(Backup Command Response)。
902、第二设备向第一设备发送数据备份请求,数据备份请求用于指示待备份的目标会话。
基于步骤901建立的连接,第二设备可以与第一设备进行数据传输,需要说明的是,该步骤以及后续步骤中的数据传输均是基于该连接,后续步骤中不再对此赘述说明。
在确定与第一设备成功建立连接之后,第二设备进入数据备份流程,比如,第二设备可以显示目标会话选择界面,该目标会话选择界面包括目标应用的会话列表,该会话列表中包括多个会话选项,每个会话选项包括会话的会话标识、头像和选择框,用户可以通过点击选择框来选中需要备份的目标会话。其中,由于没有必要对消息记录为零的会话进行备份,因此为了提高数据备份的准确性,目标会话选择界面中展示的会话列表可以仅包括消息记录不为零的会话,进一步地,对应每个会话,还可以显示该会话所包含消息记录的大小,比如5M等。此外,为了保证备份流程有序进行,第二设备还可以在发送数据备份请求之前,向第一设备发送备份开始消息(Backup Start Request),由第一设备返回确认开始消息(Backup Start Response)之后,再发送数据备份请求,该数据备份请求可以由Backup Request Session消息承载。
其中,目标会话的个数可以为一个或多个,本实施例对此不作限定。当第二设备检测到对目标会话的选取确认操作时,向第一设备发送数据备份请求,该数据备份请求可以包括目标会话的会话标识。其中,对于一对一会话,会话标识可以为会话对端的昵称、账号等,对于群组会话,会话标识可以为群组名称等。
在本发明实施例中,会话的消息记录是指会话本端与会话对端之间交互的文字、图片、语音和视频等数据。每条消息记录包括该消息记录的产生时间,消息记录的类型包括文字消息记录和媒体消息记录。其中,媒体消息记录包括图片、语音和视频等。其中,媒体消息记录包括相应媒体消息本身及其描述信息,该描述信息用于描述相应媒体消息的消息标识、媒体类型、产生时间、媒 体消息记录大小等。
903、第一设备接收到第二设备的数据备份请求时,获取与目标会话对应的备份截止时间。
第一设备存储有备份消息记录的备份截止时间与会话标识之间的对应关系。第一设备可以根据目标会话的会话标识查询已存储的对应关系,得到目标会话的备份截止时间。例如,该对应关系可以如表1所示。
表1
会话标识 备份截止时间
会话标识1 2016年11月2日18时23分
会话标识2 2016年11月3日10时02分
会话标识3 2016年11月18日22时03分
当然,该对应关系中还可以存储会话标识对应会话的存储地址,使得第一设备可以通过该对应关系直接确定某个会话的存储区域。
904、第一设备将目标会话的备份截止时间发送至第二设备。
如果目标会话包括多个会话,则第一设备对应每个会话返回与该会话对应的备份截止时间,本实施例仅以目标会话包括一个会话为例进行介绍。
需要说明的是,上述目标会话的备份截止时间可以由数据备份响应(Backup Request Session Response)承载,本发明实施例对其具体承载方式不做限定。
905、第二设备根据目标会话的备份截止时间确定目标消息记录,该目标消息记录为目标会话在备份截止时间之后产生的消息记录。
本实施例中,会话所包括的消息记录按照产生时间从先到后的顺序排列。第二设备根据目标会话的备份截止时间,从目标会话中提取该备份截止时间之后产生的消息记录。具体地,第二设备可以按照产生时间从先到后的顺序,将目标会话中消息记录的产生时间与该备份截止时间进行比对,直至获取到产生时间晚于该备份截止时间的第一消息记录,便将该第一消息记录及其之后的消息记录确定为目标消息记录。当然,第二设备也可以按照产生时间从后到先的顺序,将目标会话中消息记录的产生时间与该备份截止时间进行比对,直至获取到产生时间等于或者早于该备份截止时间的第二消息记录,便将该第二消息记录之后的消息记录确定为目标消息记录。
需要说明的是,如果第二设备确定目标会话在该备份截止时间之后未产生 新的消息记录,则确定该目标会话没有数据需要备份,此时,第二设备可以向第一设备发送备份完成消息,以结束该备份流程。如果目标会话的个数为多个,则第二设备确定每个目标会话均在相应备份截止时间之后未产生新的消息记录,向第一设备发送备份完成消息,以结束该备份流程。其中,备份完成消息可以由Backup Finish Request消息承载。如果第二设备获取到目标会话的目标消息记录,则向第一设备发送目标消息记录,该过程包括下述步骤906至908。
906、第二设备按照消息记录的产生时间从先到后的顺序,将该目标消息记录划分为至少一个消息集合。
本实施例中,为了更细粒度的对目标应用的消息记录进行处理,而不是将目标应用的消息记录看作一个整体,以实现消息记录的增量备份以及备份过程中的断点传输,在数据备份时,第二设备可以将待备份的消息记录划分为一个或多个消息集合。
其中,针对消息记录的不同类型,消息集合可以包括文字消息集合和媒体消息集合。其中,文字消息集合中包括文字消息记录和媒体消息记录的描述信息,每一个描述信息用于指示相应的媒体消息记录。媒体消息集合中包括媒体消息记录。
具体地,第二设备按照产生时间从先到后的顺序,将目标消息中文字消息记录和媒体消息记录的描述信息组合成文字消息集合,将媒体消息记录组合成媒体消息集合。例如,第二设备按照产生时间从先到后的顺序获取目标消息记录中的每条消息记录,如果该消息记录为文字消息记录,则将该文字消息记录添加到文字消息集合,如果该消息记录为媒体消息记录,则将该媒体消息记录的描述信息添加到文字消息集合,将该媒体消息记录添加到媒体消息集合。
其中,为了更细粒度的划分消息集合,还可以在基于时间顺序的基础上,采用如下两种方式来划分消息集合:
第一种方式、基于预设大小来划分消息集合。
其中,预设大小可以预先进行配置或更改,本实施例对此不作限定。比如,该预设大小可以为80M,使得第二设备可以将文字消息记录划分至多个文字消息集合中,将媒体消息记录划分至多个媒体消息集合中。具体地,根据消息记录类型的不同,该消息集合的划分又分为两种情况:
第一种情况、当消息记录为文字消息记录时,在将该文字消息记录添加到 该文字消息集合之前,将该文字消息集合和该文字消息集合所指示的媒体消息记录的总大小与该预设大小进行比较,如果该总大小小于该预设大小,则将该文字消息记录添加到该文字消息集合中;否则,将该文字消息记录添加到一个新的文字消息集合。
第二种情况、当消息记录为媒体消息记录时,在将该媒体消息记录的描述信息添加到该文字消息集合之前,将该媒体消息记录、文字消息集合和该文字消息集合所指示的媒体消息记录的总大小与预设大小进行比较,如果该总大小小于该预设大小,则将该媒体消息记录的描述信息添加到该文本消息集合中,将该媒体消息记录添加到相应的媒体消息集合中;否则,将该媒体消息记录的描述信息添加到一个新的文字消息集合,将该媒体消息记录添加到一个新的媒体消息集合。此外,第二设备还可以将一个媒体消息记录作为一个媒体消息集合,本实施例对此不作限定。
第二种方式、基于预设消息数目来划分消息集合。
该预设消息数目可预先进行配置或更改,本实施例对此不作限定。比如,该预设数目可以为2000,则根据消息记录类型的不同,该消息集合的划分又分为两种情况:
第一种情况、当消息记录为文字消息记录时,将该文字消息记录添加到文字消息集合之前,第二设备检测该文字消息集合中所包含的消息记录数目是否小于该预设消息数目,如果小于,则将该文字消息记录添加到该文字消息集合中;否则,将该文字消息记录添加到一个新的文字消息集合中。
第二种情况、当消息记录为媒体消息记录时,则将该媒体消息记录的描述信息添加到文字消息集合之前,第二设备检测该文字消息集合中所包含的消息记录数目是否小于该预设消息数目,如果小于,则将该媒体消息记录的描述信息添加到该文字消息集合中,将该媒体消息记录添加到相应的媒体消息集合中;否则,将该媒体消息记录的描述信息添加到一个新的文字消息集合中,将该媒体消息记录添加到一个新的媒体消息集合中。此外,第二设备还可以将一个媒体消息记录作为一个媒体消息集合,本实施例对此不作限定。
需要说明的是,在第二种方式的两种情况下,文字消息集合中媒体消息记录的描述信息也表示一条消息记录,在统计文字消息集合中所包含的消息记录数目时也会统计文字消息集合中媒体消息记录的描述信息的数目。
本实施例中,第二设备可以采用文件为载体对消息集合进行传输,从而进 行数据备份。其中,多个消息集合可以组成一个消息文件,比如,可以将多个文字消息集合组成一个文字消息文件,将多个媒体消息集合组成一个媒体消息文件。
907、对于至少一个消息集合中每个消息集合,第二设备确定该消息集合的消息指示信息,消息指示信息用于指示该消息集合中最后一条消息记录的产生时间。
对于每个消息集合,根据消息记录的产生时间,第二设备可以确定该消息集合中最后一条消息记录的产生时间。
908、第二设备将至少一个消息集合及其消息指示信息发送至第一设备。
对于每个消息集合,第二设备将该消息集合发送至第一设备之后,将该消息集合的消息指示信息发送至第一设备。具体地,第二设备可以按照消息记录产生时间从先到后的顺序,将每个消息集合打包为多个数据包,将每个数据包(Packet Backup Data Push)依次发送至第一设备。当第二设备将一个消息集合对应的多个数据包发送完毕之后,第二设备将该消息集合的消息指示信息(Packet Backup Data Tag)发送至第一设备。然后,第二设备再向第一设备发送下一个消息集合。
进一步地,为了保证在数据备份的可靠性,第一设备还可以向第二设备反馈数据包的接收成功或者接收失败的消息(Packet Backup Data Push Response)。当第二设备接收到第一设备的接收成功消息后,再继续向第一设备发送下一个数据包。更进一步地,第一设备还可以对接收到的消息集合进行数据完整性验证,具体地,消息集合的消息指示信息还可以包括消息集合的摘要信息,第一设备根据消息集合的摘要信息验证消息集合是否接收成功。比如,消息集合的摘要信息可以为该消息集合中包括的所有消息记录的消息标识,第一设备根据该摘要信息中的消息标识对已接收到的消息记录进行验证,如果已接收到摘要信息指示的全部消息记录,则确定该消息集合接收成功,并向第二设备发送验证成功消息(Packet Backup Data Tag Response)。第二设备接收到消息集合的验证成功消息后,再向第一设备发送下一个消息集合。当目标消息记录所对应的消息集合发送完毕时,第二设备可以向第一设备发送备份完成消息(Backup Finish Request),以使第一设备确定备份流程结束。
需要说明的是,对于一些数据量较大的媒体消息记录,很可能在第一设备和第二设备上均已经存储,比如,在第一设备和第二设备登录有目标应用的相 同账号的情况下,当接收到一个600M大小的视频文件时,第一设备和第二设备上均可以接收并存储该视频文件。因此,为了避免对第一设备已存储有数据量较大的媒体消息记录进行不必要的备份,从而提高数据传输的有效性和备份效率,本实施例还提供了对数据量较大媒体消息记录的验证机制,该过程可以包括以下步骤908a至908f:
步骤908a:对于至少一个消息集合中的每个消息集合,第二设备检测该消息集合中是否包含指定消息记录。
该指定消息记录是指该消息集合中大小超过预设阈值的消息记录。该预设阈值可以进行预先配置或更改,比如,该预设阈值可以为500M,本实施例对此不作限定。
步骤908b:如果消息集合中包含指定消息记录,第二设备向第一设备发送备份验证请求(Packet SvrID Request),该备份验证请求携带指定消息记录的消息标识。
步骤908c:第一设备接收到备份验证请求后,根据指定消息记录的消息标识,判断是否已存储有该指定消息记录。
步骤908d:如果未存储有指定消息记录,第一设备向第二设备发送未备份指示消息,执行步骤908e;如果第一设备已存储有指定消息记录,则向第二设备发送已备份指示消息,执行步骤908f。其中,未备份消息指示和已备份消息指示可以由Packet Svr ID Response消息来承载。
步骤908e:第二设备如果接收到未备份指示消息,则向第一设备发送该指定消息记录。
步骤908f:第一设备将指定消息记录存储至预设备份目录中与目标会话对应的存储区域,从而完成该指定消息记录的备份。
其中,该预设备份目录用于存储会话的消息记录。当第一设备安装有目标应用时,该预设备份目录可以为该目标应用存储消息记录的默认目录。
为了保证数据的安全性,第二设备在将需要发送的消息记录进行加密后再发送至第一设备,比如,对向第一设备发送的每个数据包进行加密。具体地,可以采用指定的密钥对数据进行加密。为了进一步地提高数据的安全性,使得用户的应用数据无法被其他用户窃取,一个用户的账号可以对应一个唯一的密钥,该密钥可以由用户在使用自己的账号登录目标应用时,从服务器获取该密钥,使得其他用户无法获取到该用户的密钥,即使获取到该用户的加密数据后 也无法解密,从而保证了该用户的应用数据的安全性。
909、第一设备将接收到的至少一个消息集合以及每个消息集合的消息指示信息存储至预设备份目录中与目标会话对应的存储区域。
对于接收到的每个消息集合,第一设备将该消息集合的消息指示信息、目标会话和该消息集合对应存储,即将该消息集合的最后一条消息记录的产生时间、目标会话和该消息集合对应存储,比如,在表1中添加消息集合的存储地址的表项,以建立该对应关系。其中,该消息集合的消息指示信息和目标会话可以存储为该消息集合的索引。当采用文件来承载多个消息集合时,该消息集合的索引还可以包括该消息集合在消息文件中的存储偏移位置,比如,在表1中添加消息文件的存储地址表项以及消息集合的偏移地址的表项,以使得第一设备能够准确定位每个消息集合。
需要说明的是,如果数据备份的过程中由于网络中断等原因发生了数据传输中断,则在目标会话的备份发生中断后,第一设备和第二设备还可以继续备份目标会话的消息记录。该继续备份的过程可以由用户在第一设备触发,也可以由用户在第二设备触发,具体可以分为以下三种情况:
第一种情况、用户通过第一设备触发继续备份。
当第一设备检测到网络连接恢复时,显示是否进行继续备份的提示信息,如果检测到继续备份的触发操作,触发第二断点续传指令,第一设备接收到该第二断点续传指令时,向第二设备发送第一断点续传请求,第一断点续传请求用于指示备份中断时目标会话的备份中断时间,具体地,该备份中断时间指发生数据传输中断时,第一设备接收到的最后一个消息集合中最后一条消息记录的产生时间。第二设备根据该备份中断时间,向第一设备发送目标会话的未备份的目标消息记录,比如,第二设备根据该备份中断时间从至少一个消息集合中确定未备份消息集合,向第一设备发送该未备份消息集合,由第一设备对接收到的消息集合与该目标会话对应存储。
第二种情况、用户通过第二设备触发继续备份。
当第二设备检测到网络连接恢复时,显示是否进行继续备份的提示信息,如果检测到继续备份的触发操作,触发第一断点续传指令,第二设备接收到该第一断点续传指令时,向第一设备发送第二断点续传请求,该第二断点续传请求用于指示对该目标会话进行断点续传。第一设备接收到该第二断点续传请求后,确定目标会话的备份中断时间,将该备份中断时间返回第二设备。第二设 备根据该备份中断时间,向第一设备发送目标会话未备份的目标消息记录,比如,第二设备根据该备份中断时间从至少一个消息集合中确定未备份消息集合,向第一设备发送该未备份消息集合,由第一设备对接收到的消息集合与该目标会话对应存储。
第三种情况、用户通过第二设备触发继续备份,第二设备记录有备份中断时目标会话的备份中断时间。
当第二设备检测到网络连接恢复时,显示是否进行继续备份的提示信息,如果检测到继续备份的触发操作,触发第一断点续传指令,第二设备接收到该第一断点续传指令时,根据记录的备份中断时间,向第一设备发送目标会话未备份的目标消息记录,比如,第二设备根据该备份中断时间从至少一个消息集合中确定未备份消息集合,向第一设备发送该未备份消息集合,由第一设备对接收到的消息集合与该目标会话对应存储。
相比于相关技术在发生数据传输中断时整个备份流程仍需从头开始,已经传输过的待备份数据也需要再重新传输,本实施例提供的方法在数据连接发生中断时,只需按照原备份流程继续发送需要备份的数据即可,而无需传输已经备份过的数据,实现了数据的断点续传。
本实施例中,采用备份截止时间来区分目标会话中已备份的消息记录和未备份的消息记录,使得在对目标会话进行备份时,仅需传输未备份的消息记录即可,而无需传输已备份的消息记录,提高了数据备份的效率。
需要说明的是,上述步骤901至909仅以第二设备将目标应用的数据备份至第一设备的数据备份流程为例进行介绍。在另一实施例中,还可以将在第一设备上备份的目标应用的数据恢复至第二设备,该数据恢复的过程可以看作是上述数据备份的逆过程,如图10A所示,该数据恢复过程可以包括以下步骤1001至1009:
1001、第二设备获取第一设备的设备信息,根据该设备信息与第一设备建立连接。
该建立连接的过程与步骤901中建立连接的过程同理,在此不作赘述。当第一设备和第二设备均为终端时,基于步骤901的连接方式,图10B为本实施例示出的一种数据恢复的流程图,在图10B中当第一设备检测到数据恢复选项的触发操作时,向服务器发送恢复流程发起消息,该备份流程发起消息携带第一设备的设备信息和登录目标应用的第一账号。
相应的,第一设备和第二设备建立连接的过程中也可以进行口令验证,该口令验证的过程与步骤901同理,第二设备的口令验证消息和口令验证成功消息也可以由Packet Authenticate Request消息来承载,第一设备返回的口令验证成功消息和口令验证确认消息可以由Packet Authenticate Response消息承载。
相应的,第一设备和第二设备之间还可以交互流程类型,该过程与步骤901中流程类型交互的过程同理。其中,第一设备的流程类型指示和第二设备的准备就绪指示可以由Backup Command Request消息承载,第二设备返回的确认应答消息和第一设备的确认应答消息可以由Backup Command Response消息承载。此外,第一设备还可以向第二设备发送恢复开始消息(Backup Start Request),由第二设备返回确认开始消息(Backup Start Response)。
1002、第一设备向第二设备发送数据恢复请求,该数据恢复请求用于指示待恢复的目标会话。
该步骤与步骤902同理,在此不作赘述。该数据恢复请求可以由Backup Request Session消息承载。
1003、第二设备接收到数据恢复请求时,确定目标会话的恢复起始时间,将该恢复起始时间发送至第一设备。
该恢复起始时间可以为目标会话中第一条消息记录的产生时间。需要说明的是,上述目标会话的恢复起始时间可以由数据恢复响应(Backup Request Session Response)承载,本发明实施例对其具体承载方式不做限定。
1004、第一设备根据接收到的恢复起始时间,从备份的目标会话的至少一个消息集合中,确定目标消息集合,该目标消息集合是指最后一条消息记录的产生时间早于该恢复起始时间的消息集合。
1005、第一设备将目标消息集合发送至第二设备。
对于每个目标消息集合,第一设备可以将目标消息集合按照时间顺序打包成多个数据包,将每个数据包(Packet Backup Data Push)依次发送至第二设备。对于每个数据包,第二设备可以返回一个数据包的接收成功或者接收失败的消息(Packet Backup Data Push Response)。当发送完一个消息集合后,第一设备向第二设备发送该消息集合的消息指示信息(Packet Backup Data Tag)。当该消息集合指示中包括消息集合的摘要信息时,第二设备还可以对该消息集合进行完整性验证,如果验证成功,则返回验证成功消息(Packet Backup  Data Tag Response),由第一设备接收到该验证成功消息后,发送下一个消息集合。
另外,在发送消息集合的过程中,第一设备也可以对较大数据量的指定消息记录进行检测,如果检测到大小超过预设阈值的指定消息记录,则向第二设备发送恢复验证请求(Packet SvrID Request),由第二设备对本地存储的消息记录验证后,返回未恢复消息指示或已恢复消息指示。该未恢复消息指示和已恢复消息指示可以由Packet Svr ID Response消息来承载。
当第一设备发送完毕所有需要恢复的数据后,向第二设备发送恢复完成消息(Backup Finish Request)。
1006、第二设备将接收到的目标消息集合存储至目标会话对应的存储区域。
需要说明的是,为了提高数据恢复的灵活性,在备份过程的步骤907中,消息集合的消息指示信息还用于指示该消息集合中第一条消息记录的产生时间。也即是,消息指示信息用于指示消息集合所包含消息记录所对应的时间范围。相应地,在步骤909中第一设备将消息集合的消息指示信息、目标会话和该消息集合对应存储,即为将消息集合对应的时间范围、目标会话和消息集合对应存储。此时,消息集合的索引便是该消息集合对应的时间范围和目标会话。在消息指示信息包括第一条消息记录的产生时间的情况下,用户在第一设备触发数据恢复流程的过程中,可以在数据恢复界面选取目标会话待恢复的目标时间段。则在步骤1001之后,该数据恢复的流程还可以为:
当第一设备检测到目标会话的数据恢复指令时,根据数据恢复指令中携带的目标时间段和该目标会话至少一个消息集合的消息指示信息,从该至少一个目标消息集合中确定目标消息集合。该目标消息集合是指消息记录对应的时间范围落入该目标时间段内的消息集合。之后,第一设备将目标消息集合发送至第二设备。其中,当通过第一设备触发数据恢复流程时,该数据恢复指令可由用户对第一设备提供的数据恢复选项的点击操作触发;当通过第二设备触发数据恢复流程时,该数据恢复指令可由第二设备发送给第一设备。
需要说明的是,如果数据恢复过程发生中断,也可以实现数据恢复的断点续传,该过程与上述步骤909中备份中断时进行断点续传的过程同理,在此不做赘述。
本实施例中,通过在数据恢复过程中,采用恢复起始时间来确定需要恢复 的消息集合,使得在对目标会话进行数据恢复时,仅需传输目标设备中未存储的消息记录即可,而无需传输目标设备中已存储的消息记录,提高了数据恢复的效率。
图11是本发明实施例提供的一种数据备份装置的框图。参照图11,该装置包括第一发送模块1101,接收模块1102,确定模块1103和第二发送模块1104。
其中,第一发送模块1101与接收模块1102连接,用于向第一设备发送数据备份请求,该数据备份请求用于指示待备份的目标会话;接收模块1102与确定模块1103连接,用于接收该第一设备返回的该目标会话的备份截止时间,该备份截止时间用于指示该第一设备存储有该目标会话在该备份截止时间之前的全部消息记录;确定模块1103与第二发送模块1104连接,用于根据该备份截止时间确定目标消息记录,该目标消息记录为该目标会话在该备份截止时间之后产生的消息记录;第二发送模块1104,用于向该第一设备发送该目标消息记录,该第一设备用于对会话的消息记录进行备份。
在一种可能的实现方式中,该第二发送模块1104用于按照消息记录的产生时间从先到后的顺序,将该目标消息记录划分为至少一个消息集合;对于该至少一个消息集合中每个消息集合,确定该消息集合的消息指示信息,该消息指示信息用于指示该消息集合中最后一条消息记录的产生时间;将该至少一个消息集合及其消息指示信息发送至该第一设备。
在一种可能的实现方式中,该第二发送模块1104用于对于该至少一个消息集合中每个消息集合,检测该消息集合中是否包含指定消息记录,该指定消息记录是指大小超过预设阈值的消息记录;如果该消息集合中包含该指定消息记录,则向该第一设备发送备份验证请求,该备份验证请求携带该指定消息记录的消息标识,该第一设备用于在根据该指定消息记录的消息标识确定未存储该指定消息记录后,返回未备份指示消息;如果接收到该未备份指示消息,向该第一设备发送该指定消息记录。
在一种可能的实现方式中,该消息指示信息还用于指示该消息集合的摘要信息,该第二发送模块1104还用于对于该至少一个消息集合中每个消息集合,将该消息集合发送至该第一设备;将该消息集合的消息指示信息发送至该第一设备,该第一设备用于在根据该摘要信息对该消息集合验证接收成功后,返回 接收成功消息;当接收到该消息集合的接收成功消息时,向该第一设备发送下一个消息集合。
在一种可能的实现方式中,该消息指示信息还用于指示该消息集合中第一条消息记录的产生时间。
在一种可能的实现方式中,该接收模块还用于在该目标会话的备份发生中断后,接收该第一设备的第一断点续传请求,该第一断点续传请求用于指示该目标会话的备份中断时间;该第二发送模块还用于基于该备份中断时间,向该第一设备发送该目标会话的未备份目标消息记录;或,第一发送模块还用于在该目标会话的备份发生中断后,如果接收到第一断点续传指令时,向该第一设备发送第二断点续传请求,该第二断点续传请求用于指示对该目标会话进行断点续传;该第二发送模块还用于基于该第一设备返回的该目标会话的备份中断时间,向该第一设备发送该目标会话的未备份目标消息记录;或,该第二发送模块还用于在该目标会话的备份发生中断后,如果接收到第一断点续传指令时,确定该目标会话的未备份目标消息记录,向该第一设备发送该未备份目标消息记录。
在一种可能的实现方式中,该装置还包括:
获取模块,用于获取该第一设备的设备信息;
连接模块,用于根据该设备信息与该第一设备建立连接。
在一种可能的实现方式中,获取模块用于从服务器获取第一设备的设备信息;或,通过扫描二维码,获取第一设备的设备信息,二维码用于指示第一设备的设备信息;或,接收第一设备的设备信息广播消息,从设备信息广播消息中提取第一设备的设备信息。
在一种可能的实现方式中,设备信息包括第一设备的IP地址,连接模块用于根据第一设备的IP地址,向第一设备发送数据连接请求,第一设备用于如果接收到数据连接请求,则返回应答消息;如果接收到应答消息,则与第一设备在局域网内建立连接。
在一种可能的实现方式中,该获取模块还用于获取该第一设备上登录的第一账号;如果该第一账号与本地登录的第二账号一致,则执行根据该设备信息与该第一设备建立连接的步骤。
在一种可能的实现方式中,与该第一设备交互的数据为加密数据。
图12是本发明实施例提供的一种数据备份装置的框图。参照图12,该装 置包括获取模块1201,发送模块1202和存储模块1203。
其中,获取模块1201与发送模块1202连接,用于当接收到第二设备的数据备份请求时,获取与目标会话对应的备份截止时间,该数据备份请求用于指示待备份的目标会话;发送模块1202与存储模块1203连接,用于将该目标会话的备份截止时间发送至该第二设备,该第二设备用于向第一设备发送目标消息记录,该目标消息记录为该目标会话在该备份截止时间之后产生的消息记录;存储模块1203,用于当接收到该目标消息记录时,将该目标消息记录存储至该目标会话的消息记录中。
在一种可能的实现方式中,该存储模块1203用于将该第二设备的至少一个消息集合以及每个消息集合的消息指示信息存储至预设备份目录中与该目标会话对应的存储区域,该预设备份目录用于存储会话的消息记录,该每个消息集合的消息指示信息用于指示该消息集合中最后一条消息记录的产生时间。
在一种可能的实现方式中,该每个消息集合的消息指示信息还用于指示该消息集合的摘要信息,该装置还包括:
验证模块,用于对于该每个消息集合,根据该消息集合的摘要信息验证该消息集合是否接收成功;
该发送模块还用于如果验证结果为接收成功,则向该第二设备发送接收成功消息。
在一种可能的实现方式中,该每个消息集合的消息指示信息还用于指示该消息集合中第一条消息记录的产生时间,该装置还包括:
确定模块,用于当检测到该目标会话的数据恢复指令时,根据目标时间段和该至少一个消息集合的消息指示信息,从该至少一个消息集合中确定目标消息集合,该数据恢复指令携带待恢复的目标时间段,该目标消息集合是指第一条消息记录的产生时间和最后一条消息记录的产生时间落入该目标时间段内的消息集合;
该发送模块还用于将该目标消息集合发送至该第一设备。
在一种可能的实现方式中,该装置还包括:
判断模块,用于如果接收到备份验证请求,则根据指定消息记录的消息标识,判断是否已存储有该指定消息记录,该备份验证请求携带该指定消息记录的消息标识;
该发送模块还用于如果未存储有该指定消息记录,则向该第二设备发送未 备份指示消息;如果已存储有该指定消息记录,则向该第二设备发送已备份指示消息,将该指定消息记录存储至预设备份目录中与该目标会话对应的存储区域,该预设备份目录用于存储会话的消息记录。
在一种可能的实现方式中,发送模块还用于在目标会话的备份发生中断后,如果接收到第二断点续传指令,向第二设备发送第一断点续传请求,第一断点续传请求用于指示目标会话的备份中断时间;存储模块还用于对接收到的目标会话的未备份目标消息记录进行存储;或,发送模块还用于在目标会话的备份发生中断后,如果接收到目标会话的第二断点续传请求,则向第二设备发送目标会话的备份中断时间;存储模块还用于对接收到的目标会话的未备份目标消息记录进行存储;或,存储模块还用于在目标会话的备份发生中断后,对接收到的目标会话的未备份消息记录进行存储。
需要说明的是:上述实施例提供的数据备份装置在备份数据时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将设备的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的数据备份装置与数据备份方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。
图13是本发明实施例提供的一种终端的结构示意图,该终端可以用于执行上述各个实施例中提供的数据备份方法。参见图13,该终端1300包括:
终端1300可以包括RF(Radio Frequency,射频)电路110、包括有一个或一个以上计算机可读存储介质的存储器120、输入单元130、显示单元140、传感器150、音频电路160、WiFi(Wireless Fidelity,无线保真)模块170、包括有一个或者一个以上处理核心的处理器180、以及电源190等部件。本领域技术人员可以理解,图13中示出的终端结构并不构成对终端的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。其中:
RF电路110可用于收发信息或通话过程中,信号的接收和发送,特别地,将基站的下行信息接收后,交由一个或者一个以上处理器180处理;另外,将涉及上行的数据发送给基站。通常,RF电路110包括但不限于天线、至少一个放大器、调谐器、一个或多个振荡器、用户身份模块(SIM)卡、收发信机、 耦合器、LNA(Low Noise Amplifier,低噪声放大器)、双工器等。此外,RF电路110还可以通过无线通信与网络和其他设备通信。所述无线通信可以使用任一通信标准或协议,包括但不限于GSM(Global System of Mobile communication,全球移动通讯***)、GPRS(General Packet Radio Service,通用分组无线服务)、CDMA(Code Division Multiple Access,码分多址)、WCDMA(Wideband Code Division Multiple Access,宽带码分多址)、LTE(Long Term Evolution,长期演进)、电子邮件、SMS(Short Messaging Service,短消息服务)等。
存储器120可用于存储软件程序以及模块,处理器180通过运行存储在存储器120的软件程序以及模块,从而执行各种功能应用以及数据处理。存储器120可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作***、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据终端1300的使用所创建的数据(比如音频数据、电话本等)等。此外,存储器120可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。相应地,存储器120还可以包括存储器控制器,以提供处理器180和输入单元130对存储器120的访问。
输入单元130可用于接收输入的数字或字符信息,以及产生与用户设置以及功能控制有关的键盘、鼠标、操作杆、光学或者轨迹球信号输入。具体地,输入单元130可包括触敏表面131以及其他输入设备132。触敏表面131,也称为触摸显示屏或者触控板,可收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触敏表面131上或在触敏表面131附近的操作),并根据预先设定的程式驱动相应的连接装置。可选的,触敏表面131可包括触摸检测装置和触摸控制器两个部分。其中,触摸检测装置检测用户的触摸方位,并检测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸检测装置上接收触摸信息,并将它转换成触点坐标,再送给处理器180,并能接收处理器180发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触敏表面131。除了触敏表面131,输入单元130还可以包括其他输入设备132。具体地,其他输入设备132可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆等中的一种或多种。
显示单元140可用于显示由用户输入的信息或提供给用户的信息以及终端1300的各种图形用户接口,这些图形用户接口可以由图形、文本、图标、视频和其任意组合来构成。显示单元140可包括显示面板141,可选的,可以采用LCD(Liquid Crystal Display,液晶显示器)、OLED(Organic Light-Emitting Diode,有机发光二极管)等形式来配置显示面板141。进一步的,触敏表面131可覆盖显示面板141,当触敏表面131检测到在其上或附近的触摸操作后,传送给处理器180以确定触摸事件的类型,随后处理器180根据触摸事件的类型在显示面板141上提供相应的视觉输出。虽然在图13中,触敏表面131与显示面板141是作为两个独立的部件来实现输入和输入功能,但是在某些实施例中,可以将触敏表面131与显示面板141集成而实现输入和输出功能。
终端1300还可包括至少一种传感器150,比如光传感器、运动传感器以及其他传感器。具体地,光传感器可包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板141的亮度,接近传感器可在终端1300移动到耳边时,关闭显示面板141和/或背光。作为运动传感器的一种,重力加速度传感器可检测各个方向上(一般为三轴)加速度的大小,静止时可检测出重力的大小及方向,可用于识别手机姿态的应用(比如横竖屏切换、相关游戏、磁力计姿态校准)、振动识别相关功能(比如计步器、敲击)等;至于终端1300还可配置的陀螺仪、气压计、湿度计、温度计、红外线传感器等其他传感器,在此不再赘述。
音频电路160、扬声器161,传声器162可提供用户与终端1300之间的音频接口。音频电路160可将接收到的音频数据转换后的电信号,传输到扬声器161,由扬声器161转换为声音信号输出;另一方面,传声器162将收集的声音信号转换为电信号,由音频电路160接收后转换为音频数据,再将音频数据输出处理器180处理后,经RF电路110以发送给比如另一终端,或者将音频数据输出至存储器120以便进一步处理。音频电路160还可能包括耳塞插孔,以提供外设耳机与终端1300的通信。
WiFi属于短距离无线传输技术,终端1300通过WiFi模块170可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图13示出了WiFi模块170,但是可以理解的是,其并不属于终端1300的必须构成,完全可以根据需要在不改变发明的本质的范围内而省略。
处理器180是终端1300的控制中心,利用各种接口和线路连接整个手机的各个部分,通过运行或执行存储在存储器120内的软件程序和/或模块,以及调用存储在存储器120内的数据,执行终端1300的各种功能和处理数据,从而对手机进行整体监控。可选的,处理器180可包括一个或多个处理核心;优选的,处理器180可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作***、用户界面和应用程序等,调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器180中。
终端1300还包括给各个部件供电的电源190(比如电池),优选的,电源可以通过电源管理***与处理器180逻辑相连,从而通过电源管理***实现管理充电、放电、以及功耗管理等功能。电源190还可以包括一个或一个以上的直流或交流电源、再充电***、电源故障检测电路、电源转换器或者逆变器、电源状态指示器等任意组件。
尽管未示出,终端1300还可以包括摄像头、蓝牙模块等,在此不再赘述。具体在本实施例中,终端的显示单元是触摸屏显示器,终端还包括有存储器,以及一个或者一个以上的程序,其中一个或者一个以上程序存储于存储器中,且经配置以由一个或者一个以上处理器执行。所述一个或者一个以上程序包含可执行指令,终端1300被配置为执行指令,以执行上述来电提示方法实施例中终端所执行的方法。
在示例性实施例中,还提供了一种包括指令的非临时性计算机可读存储介质,例如包括指令的存储器,上述指令可由终端中的处理器执行以完成上述实施例中数据备份方法。例如,所述非临时性计算机可读存储介质可以是ROM、随机存取存储器(RAM)、CD-ROM、磁带、软盘和光数据存储设备等。
图14是本发明实施例提供的一种数据备份装置的框图。例如,装置1400可以被提供为一服务器。参照图14,装置1400包括处理组件1422,其进一步包括一个或多个处理器,以及由存储器1432所代表的存储器资源,用于存储可由处理部件1422的执行的指令,例如应用程序。存储器1432中存储的应用程序可以包括一个或一个以上的每一个对应于一组指令的模块。此外,处理组件1422被配置为执行指令,以执行上述数据备份方法实施例中服务器所执行的方法。
装置1400还可以包括一个电源组件1426被配置为执行装置1400的电源 管理,一个有线或无线网络接口1450被配置为将装置1400连接到网络,和一个输入输出(I/O)接口1458。装置1400可以操作基于存储在存储器1432的操作***,例如Windows ServerTM,Mac OS XTM,UnixTM,LinuxTM,FreeBSDTM或类似。
在示例性实施例中,还提供了一种包括指令的非临时性计算机可读存储介质,例如包括指令的存储器,上述指令可由服务器中的处理器执行以完成上述实施例中的数据备份方法。例如,所述非临时性计算机可读存储介质可以是ROM、随机存取存储器(RAM)、CD-ROM、磁带、软盘和光数据存储设备等。
应当理解的是,在本文中使用的,除非上下文清楚地支持例外情况,单数形式“一个”(“a”、“an”、“the”)旨在也包括复数形式。还应当理解的是,在本文中使用的“和/或”是指包括一个或者一个以上相关联地列出的项目的任意和所有可能组合。
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。
以上所述仅为本申请的较佳实施例,并不用以限制本申请,凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。

Claims (26)

  1. 一种通信消息同步方法,其特征在于,用于第一社交应用客户端中,所述方法包括:
    获取所述第一社交应用客户端中待同步的n条通信消息以及每条通信消息的消息类型,n为大于等于1的整数;
    对于每条通信消息,生成包括所述通信消息的消息类型以及所述通信消息的消息内容的消息数据;
    以消息块为单位同步生成的n条消息数据至第二社交应用客户端;所述第二社交应用客户端以所述消息块为单位存储所述n条消息数据至数据文件,生成并保存对应关系;每个消息块对应于至少一条消息数据,且在对应于至少两条消息数据时,所述至少两条消息数据所对应的通信消息属于同一会话,所述第二社交应用客户端与所述第一社交应用客户端类型相同且共用同一社交帐号;所述对应关系包括消息块、所述消息块所对应的会话以及所述消息块的存储位置之间的对应关系,所述消息块所对应的会话为所述消息块中的消息数据所对应的通信消息所属的会话。
  2. 根据权利要求1所述的方法,其特征在于,若所述消息类型为图片或者音视频,所述生成包括所述通信消息的消息类型以及所述通信消息的消息内容的消息数据,包括:
    生成包括所述消息类型以及数据标识的消息体,并生成包括所述消息内容的媒体数据,所述数据标识用于指向所述媒体数据,所述消息体和所述媒体数据构成所述消息数据。
  3. 根据权利要求2所述的方法,其特征在于,所述以消息块为单位同步生成的n条消息数据至第二社交应用客户端,包括:
    所述n条通信消息来自m个会话,对于每个会话,生成消息块,m为正整数;
    对于任一会话中的任一通信消息i,如果所述通信消息i的消息数据包括消息体和媒体数据,则将所述通信消息i的消息体按预设顺序存储至所述通信消息i所属会话对应的消息块中,在同步所述通信消息i的消息数据时,同步所述通信消息i所属会话对应的消息块及所述通信消息i的媒体数据至所述第二 社交应用客户端,所述预设顺序为接收到通信消息的先后顺序。
  4. 根据权利要求1所述的方法,其特征在于,所述以消息块为单位同步生成的n条消息数据至第二社交应用客户端,包括:
    所述n条通信消息来自m个会话,对于每个会话,生成消息块,m为正整数;
    对于任一会话中的任一通信消息i,将所述通信消息i的消息数据按预设顺序存储至所述通信消息i所属会话对应的消息块中,在同步所述通信消息i的消息数据时,同步所述通信消息i所属会话对应的消息块至所述第二社交应用客户端,所述预设顺序为接收到通信消息的先后顺序。
  5. 根据权利要求3或4所述的方法,其特征在于,所述对于每个会话,生成消息块,包括:
    根据会话中的各条通信消息所对应的消息数据的总大小,和/或,所述会话中的通信消息的条数,为所述会话生成至少一个消息块。
  6. 根据权利要求1至4任一所述的方法,其特征在于,所述方法还包括:
    获取每个消息块所对应的时间信息,所述时间信息的起始时刻为所述消息块中的首条消息数据所对应的通信消息的接收时间,所述时间信息的结束时刻为所述消息块中的最后一条消息数据所对应的通信消息的接收时间;
    在同步每个消息块至所述第二社交应用客户端时,同步所述消息块所对应的时间信息至所述第二社交应用客户端。
  7. 根据权利要求1至4任一所述的方法,其特征在于,所述获取所述第一社交应用客户端中待同步的n条通信消息以及每条通信消息的消息类型,包括:
    接收所述第二社交应用客户端发送的各个会话的时间戳信息,所述时间戳信息为所述第二社交应用客户端根据保存的对应关系确定的各个会话中最后一条消息数据所对应的通信消息的接收时间;
    对于每个会话,根据所述会话的时间戳信息获取在所述时间戳信息之后接收到的所述会话中的各条通信消息,并获取各条通信消息的消息类型。
  8. 一种通信消息同步方法,其特征在于,用于第二社交应用客户端中,所 述方法包括:
    接收第一社交应用客户端以消息块为单位同步的n条消息数据;所述第一社交应用客户端与所述第二社交应用客户端类型相同且共用同一社交帐号;每条消息数据为所述第一社交应用客户端生成的包括一条通信消息的消息类型以及消息内容的数据;每个消息块对应于至少一条消息数据,且在对应于至少两条消息数据时,所述至少两条消息数据所对应的通信消息属于同一会话;
    以所述消息块为单位存储所述n条消息数据至数据文件;
    生成并保存对应关系;所述对应关系包括消息块、所述消息块所对应的会话以及所述消息块的存储位置之间的对应关系,所述消息块所对应的会话为所述消息块中的消息数据所对应的通信消息所属的会话。
  9. 根据权利要求8所述的方法,其特征在于,所述接收第一社交应用客户端以消息块为单位同步的n条消息数据,包括:
    接收所述第一社交应用客户端同步的每个消息块以及消息块中的数据标识所对应的媒体数据;其中,消息块中包括消息体,所述消息体中包括通信消息的消息类型以及数据标识,所述媒体数据中包括所述通信消息的消息内容,所述数据标识指向所述媒体数据;
    所述以消息块为单位存储所述n条消息数据至数据文件,包括:
    存储每个消息块至消息文件,并存储所述消息块中的数据标识所对应的媒体数据至媒体文件,所述消息文件和所述媒体文件构成所述数据文件;
    所述对应关系还包括数据标识与媒体数据在所述媒体文件中的存储位置之间的对应关系。
  10. 根据权利要求9所述的方法,其特征在于,所述对应关系还包括消息块与消息块中的消息体中的数据标识之间的对应关系。
  11. 根据权利要求8至10任一所述的方法,其特征在于,所述方法还包括:
    接收所述第一社交应用客户端同步的每个消息块所对应的时间信息;所述时间信息的起始时刻为所述消息块中的首条消息数据所对应的通信消息的接收时间,所述时间信息的结束时刻为所述消息块中的最后一条消息数据所对应的通信消息的接收时间;
    所述对应关系还包括消息块与所述消息块所对应的时间信息之间的对应关系。
  12. 根据权利要求8至10任一所述的方法,其特征在于,所述方法还包括:
    根据保存的对应关系确定各个会话的时间戳信息,所述时间戳信息为所述第二社交应用客户端根据所述保存的对应关系确定的各个会话中最后一条消息数据所对应的通信消息的接收时间;
    发送所述时间戳信息至所述第一社交应用客户端。
  13. 一种终端,其特征在于,所述终端包括:处理器和存储器,所述存储器中存储有至少一条指令,所述指令由所述处理器加载并执行以实现如下操作:
    获取第一社交应用客户端中待同步的n条通信消息以及每条通信消息的消息类型,n为大于等于1的整数;
    对于每条通信消息,生成包括所述通信消息的消息类型以及所述通信消息的消息内容的消息数据;
    以消息块为单位同步生成的n条消息数据至第二社交应用客户端;所述第二社交应用客户端以所述消息块为单位存储所述n条消息数据至数据文件,生成并保存对应关系;每个消息块对应于至少一条消息数据,且在对应于至少两条消息数据时,所述至少两条消息数据所对应的通信消息属于同一会话,所述第二社交应用客户端与所述第一社交应用客户端类型相同且共用同一社交帐号;所述对应关系包括消息块、所述消息块所对应的会话以及所述消息块的存储位置之间的对应关系,所述消息块所对应的会话为所述消息块中的消息数据所对应的通信消息所属的会话。
  14. 根据权利要求13所述的终端,其特征在于,所述指令由所述处理器加载并执行以实现如下操作:
    若所述消息类型为图片或者音视频,生成包括所述消息类型以及数据标识的消息体,并生成包括所述消息内容的媒体数据,所述数据标识用于指向所述媒体数据,所述消息体和所述媒体数据构成所述消息数据。
  15. 根据权利要求14所述的终端,其特征在于,所述指令由所述处理器加 载并执行以实现如下操作:
    所述n条通信消息来自m个会话,对于每个会话,生成消息块,m为正整数;
    对于任一会话中的任一通信消息i,如果所述通信消息i的消息数据包括消息体和媒体数据,则将所述通信消息i的消息体按预设顺序存储至所述通信消息i所属会话对应的消息块中,在同步所述通信消息i的消息数据时,同步所述通信消息i所属会话对应的消息块及所述通信消息i的媒体数据至所述第二社交应用客户端,所述预设顺序为接收到通信消息的先后顺序。
  16. 根据权利要求13所述的终端,其特征在于,所述指令由所述处理器加载并执行以实现如下操作:
    所述n条通信消息来自m个会话,对于每个会话,生成消息块,m为正整数;
    对于任一会话中的任一通信消息i,将所述通信消息i的消息数据按预设顺序存储至所述通信消息i所属会话对应的消息块中,在同步所述通信消息i的消息数据时,同步所述通信消息i所属会话对应的消息块至所述第二社交应用客户端,所述预设顺序为接收到通信消息的先后顺序。
  17. 根据权利要求15或16所述的终端,其特征在于,所述指令由所述处理器加载并执行以实现如下操作:
    根据会话中的各条通信消息所对应的消息数据的总大小,和/或,所述会话中的通信消息的条数,为所述会话生成至少一个消息块。
  18. 根据权利要求13-16任一所述的终端,其特征在于,所述指令由所述处理器加载并执行以实现如下操作:
    获取每个消息块所对应的时间信息,所述时间信息的起始时刻为所述消息块中的首条消息数据所对应的通信消息的接收时间,所述时间信息的结束时刻为所述消息块中的最后一条消息数据所对应的通信消息的接收时间;
    在同步每个消息块至所述第二社交应用客户端时,同步所述消息块所对应的时间信息至所述第二社交应用客户端。
  19. 根据权利要求13-16任一所述的终端,其特征在于,所述指令由所述处理器加载并执行以实现如下操作:
    接收所述第二社交应用客户端发送的各个会话的时间戳信息,所述时间戳信息为所述第二社交应用客户端根据保存的对应关系确定的各个会话中最后一条消息数据所对应的通信消息的接收时间;
    对于每个会话,根据所述会话的时间戳信息获取在所述时间戳信息之后接收到的所述会话中的各条通信消息,并获取各条通信消息的消息类型。
  20. 一种终端,其特征在于,所述终端包括:处理器和存储器,所述存储器中存储有至少一条指令,所述指令由所述处理器加载并执行以实现如下操作:
    接收第一社交应用客户端以消息块为单位同步的n条消息数据;所述第一社交应用客户端与第二社交应用客户端类型相同且共用同一社交帐号;每条消息数据为所述第一社交应用客户端生成的包括一条通信消息的消息类型以及消息内容的数据;每个消息块对应于至少一条消息数据,且在对应于至少两条消息数据时,所述至少两条消息数据所对应的通信消息属于同一会话;
    以所述消息块为单位存储所述n条消息数据至数据文件;
    生成并保存对应关系;所述对应关系包括消息块、所述消息块所对应的会话以及所述消息块的存储位置之间的对应关系,所述消息块所对应的会话为所述消息块中的消息数据所对应的通信消息所属的会话。
  21. 根据权利要求20所述的终端,其特征在于,所述指令由所述处理器加载并执行以实现如下操作:
    接收所述第一社交应用客户端同步的每个消息块以及消息块中的数据标识所对应的媒体数据;其中,消息块中包括消息体,所述消息体中包括通信消息的消息类型以及数据标识,所述媒体数据中包括所述通信消息的消息内容,所述数据标识指向所述媒体数据;
    所述指令还由所述处理器加载并执行以实现如下操作:
    存储每个消息块至消息文件,并存储所述消息块中的数据标识所对应的媒体数据至媒体文件,所述消息文件和所述媒体文件构成所述数据文件;
    所述对应关系还包括数据标识与媒体数据在所述媒体文件中的存储位置之间的对应关系。
  22. 根据权利要求20至21任一所述的终端,其特征在于,所述指令由所 述处理器加载并执行以实现如下操作:
    接收所述第一社交应用客户端同步的每个消息块所对应的时间信息;所述时间信息的起始时刻为所述消息块中的首条消息数据所对应的通信消息的接收时间,所述时间信息的结束时刻为所述消息块中的最后一条消息数据所对应的通信消息的接收时间;
    所述对应关系还包括消息块与所述消息块所对应的时间信息之间的对应关系。
  23. 根据权利要求20至21任一所述的终端,其特征在于,所述指令由所述处理器加载并执行以实现如下操作:
    根据保存的对应关系确定各个会话的时间戳信息,所述时间戳信息为所述第二社交应用客户端根据所述保存的对应关系确定的各个会话中最后一条消息数据所对应的通信消息的接收时间;
    发送所述时间戳信息至所述第一社交应用客户端。
  24. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有至少一条指令,所述指令由处理器加载并执行以实现如权利要求1-7任一所述的方法中所执行的操作。
  25. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有至少一条指令,所述指令由处理器加载并执行以实现如权利要求8-12任一所述的方法中所执行的操作。
  26. 一种数据备份方法,其特征在于,所述方法包括:
    向第一设备发送数据备份请求,所述数据备份请求用于指示待备份的目标会话;
    接收所述第一设备返回的所述目标会话的备份截止时间,所述备份截止时间用于指示所述第一设备存储有所述目标会话在所述备份截止时间之前的全部消息记录;
    根据所述备份截止时间确定目标消息记录,所述目标消息记录为所述目标会话在所述备份截止时间之后产生的消息记录;
    向所述第一设备发送所述目标消息记录,所述第一设备用于对会话的消息记录进行备份。
PCT/CN2017/107471 2016-11-25 2017-10-24 通信消息同步方法、数据备份方法、设备及存储介质 WO2018095175A1 (zh)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN201611055670.9A CN106776124B (zh) 2016-11-25 2016-11-25 数据备份方法及装置
CN201611056492.1A CN106506674B (zh) 2016-11-25 2016-11-25 通信消息同步方法及装置
CN201611055670.9 2016-11-25
CN201611056492.1 2016-11-25

Publications (1)

Publication Number Publication Date
WO2018095175A1 true WO2018095175A1 (zh) 2018-05-31

Family

ID=62194745

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/107471 WO2018095175A1 (zh) 2016-11-25 2017-10-24 通信消息同步方法、数据备份方法、设备及存储介质

Country Status (1)

Country Link
WO (1) WO2018095175A1 (zh)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110781408A (zh) * 2019-10-25 2020-02-11 上海连尚网络科技有限公司 信息显示方法和装置
CN114880299A (zh) * 2021-02-05 2022-08-09 北京字跳网络技术有限公司 多媒体草稿文件同步方法、装置、设备和介质
CN115361356A (zh) * 2022-08-25 2022-11-18 中国银行股份有限公司 一种文件控制方法、装置以及电子设备
CN116723203A (zh) * 2022-10-10 2023-09-08 荣耀终端有限公司 数据备份方法、数据恢复方法及电子设备

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140172991A1 (en) * 2012-12-14 2014-06-19 International Business Machines Corporation Low latency messaging chat server
CN104885055A (zh) * 2014-03-19 2015-09-02 华为终端有限公司 一种应用数据同步的方法及装置
CN104883292A (zh) * 2015-04-16 2015-09-02 江苏中威科技软件***有限公司 实现消息在不同终端漫游的方法及***
CN106131137A (zh) * 2016-06-26 2016-11-16 乐视控股(北京)有限公司 数据同步方法、***及用于数据同步的用户终端和服务端
CN106506674A (zh) * 2016-11-25 2017-03-15 腾讯科技(深圳)有限公司 通信消息同步方法及装置
CN106776124A (zh) * 2016-11-25 2017-05-31 腾讯科技(深圳)有限公司 数据备份方法及装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140172991A1 (en) * 2012-12-14 2014-06-19 International Business Machines Corporation Low latency messaging chat server
CN104885055A (zh) * 2014-03-19 2015-09-02 华为终端有限公司 一种应用数据同步的方法及装置
CN104883292A (zh) * 2015-04-16 2015-09-02 江苏中威科技软件***有限公司 实现消息在不同终端漫游的方法及***
CN106131137A (zh) * 2016-06-26 2016-11-16 乐视控股(北京)有限公司 数据同步方法、***及用于数据同步的用户终端和服务端
CN106506674A (zh) * 2016-11-25 2017-03-15 腾讯科技(深圳)有限公司 通信消息同步方法及装置
CN106776124A (zh) * 2016-11-25 2017-05-31 腾讯科技(深圳)有限公司 数据备份方法及装置

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110781408A (zh) * 2019-10-25 2020-02-11 上海连尚网络科技有限公司 信息显示方法和装置
CN110781408B (zh) * 2019-10-25 2023-11-17 上海连尚网络科技有限公司 信息显示方法和装置
CN114880299A (zh) * 2021-02-05 2022-08-09 北京字跳网络技术有限公司 多媒体草稿文件同步方法、装置、设备和介质
CN115361356A (zh) * 2022-08-25 2022-11-18 中国银行股份有限公司 一种文件控制方法、装置以及电子设备
CN115361356B (zh) * 2022-08-25 2024-02-27 中国银行股份有限公司 一种文件控制方法、装置以及电子设备
CN116723203A (zh) * 2022-10-10 2023-09-08 荣耀终端有限公司 数据备份方法、数据恢复方法及电子设备
CN116723203B (zh) * 2022-10-10 2024-04-19 荣耀终端有限公司 数据备份方法、数据恢复方法及电子设备

Similar Documents

Publication Publication Date Title
CN106776124B (zh) 数据备份方法及装置
US11057376B2 (en) Method, apparatus, and system for controlling intelligent device, and storage medium
WO2018086417A1 (zh) 一种轮麦直播的方法、装置和***
EP3525417A1 (en) Data processing method, device, storage medium, electronic device and server
CN106506674B (zh) 通信消息同步方法及装置
WO2018095175A1 (zh) 通信消息同步方法、数据备份方法、设备及存储介质
WO2016150270A1 (zh) 群组会话消息处理方法和装置
WO2020164526A1 (zh) 一种分布式***中的节点控制方法和相关装置
CN104683301B (zh) 一种密码保存的方法及装置
JP2022501920A (ja) サイドリンクのリンク障害検出方法及び端末
WO2015143900A1 (zh) 网络会议中进行数据共享的方法、装置及***
CN109157841B (zh) 一种游戏组队方法、终端、服务器及计算机可读存储介质
CN104580167A (zh) 一种传输数据的方法、装置和***
JP2015525550A (ja) データ接続を確立するための方法、装置、及びシステム
US10454905B2 (en) Method and apparatus for encrypting and decrypting picture, and device
WO2018049971A1 (zh) 热点网络切换方法及终端
US10904198B2 (en) Information sending method, information display method, terminal, server, system, and storage medium
WO2018049970A1 (zh) 热点网络切换方法及终端
CN110572508B (zh) 通讯录同步方法、装置、存储介质及电子设备
WO2016192511A1 (zh) 远程删除信息的方法和装置
WO2018049969A1 (zh) 热点建立方法及相关设备
CN112333337B (zh) 一种消息查看方法、装置、设备及存储介质
WO2015101300A1 (zh) 临时频道创建方法、装置及***
CN107995151B (zh) 登录验证方法、装置及***
CN106453514B (zh) 一种聊天信息区别同步的方法及装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17872932

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17872932

Country of ref document: EP

Kind code of ref document: A1