Method and apparatus for processing session message
Patent Information
- Application Number
- CN202210797949.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-06
- Publication Date
- 2026-09-08
- Estimated Expiration
- 2042-07-06
AI Technical Summary
但是,当待同步会话消息较多时,需要一次性推送大量的操作记录,既不利于网络传输,用户端还需要花费大量集中的时间下载和同步消息,导致消息同步效率低
[0058]When synchronizing session messages based on multiple operation records corresponding to a session message using the embodiments of this application, if it is determined that the fast-forward synchronization condition is met based on multiple second operation records following the currently synchronized first operation record, a target operation record that is separated from the first operation record by at least one second operation record can be determined from the multiple second operation records. The target operation record and the second operation record arranged after the target operation record are then sent so that the session message is synchronized based on the target operation record and the received second operation record.
Smart Images

Figure CN117411843B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information processing technology, and in particular to a method, apparatus, device, storage medium, and computer program product for processing conversational messages. Background Technology
[0002] With the development of internet technology, more and more users are using instant messaging (IM) applications for information exchange. However, if a user doesn't use an IM application for a long time, a large number of conversation messages accumulate. When the user uses the IM application again, these accumulated conversation messages need to be synchronized. Common technologies for synchronization involve pushing all operation records of the conversation messages to be synchronized to the user at once. However, when there are many conversation messages to be synchronized, pushing a large number of operation records at once is not only inefficient for network transmission, but also requires the user to spend a significant amount of time downloading and synchronizing messages, resulting in low message synchronization efficiency. Summary of the Invention
[0003] This application provides a method, apparatus, device, storage medium, and computer program product for processing session messages, which can improve the synchronization efficiency of session messages.
[0004] The technical solution of this application embodiment is implemented as follows:
[0005] This application provides a method for processing session messages, including:
[0006] Receive a synchronization request for a session message for a target object, which is associated with multiple operation records arranged in the order of their creation;
[0007] The operation record is generated by recording the content of the change operation when a change operation is performed on the session message. The synchronization of the session message is achieved by synchronizing the multiple operation records in the order they are arranged.
[0008] Based on the synchronization request, it is determined that the session message has been synchronized to the first operation record among the multiple operation records, and multiple second operation records arranged after the first operation record are determined;
[0009] When it is determined that the fast-forward synchronization condition is met based on the plurality of second operation records, a target operation record that is separated from the first operation record by at least one second operation record is determined from the plurality of second operation records.
[0010] Send the target operation record and a second operation record arranged after the target operation record to synchronize the session message based on the target operation record and the received second operation record.
[0011] The method in the above scheme further includes:
[0012] Obtain the fast-forward indication information included in the synchronization request. The fast-forward indication information is used to indicate whether the session messages are allowed to be synchronized in a fast-forward synchronization mode.
[0013] When the fast-forward synchronization condition is satisfied based on the plurality of second operation records, determining the target operation record from the plurality of second operation records that is separated from the first operation record by at least one second operation record includes:
[0014] When the fast-forward indication information is used to indicate that the session messages are allowed to be synchronized in a fast-forward synchronization mode, and the fast-forward synchronization condition is determined to be met based on the multiple second operation records, then...
[0015] From the plurality of second operation records, determine the target operation record that is separated from the first operation record by at least one second operation record.
[0016] The method in the above scheme further includes:
[0017] When the fast-forward indication information is used to indicate that the session messages are not allowed to be synchronized in fast-forward synchronization mode, the multiple second operation records are sent to enable...
[0018] Based on the multiple second operation records, the session messages are synchronized.
[0019] This application also provides a method for processing session messages, including:
[0020] Send a synchronization request for a session message for a target object, which is associated with multiple operation records arranged in the order of their creation;
[0021] The operation record is generated by recording the content of the change operation when a change operation is performed on the session message. The synchronization of the session message is achieved by synchronizing the multiple operation records in the order they are arranged. The synchronization request is used to indicate that the session message has been synchronized to the first operation record among the multiple operation records.
[0022] Receive the target operation record returned based on the synchronization request, and the second operation record arranged after the target operation record;
[0023] The target operation record is determined from multiple second operation records when the fast forward synchronization condition is satisfied based on multiple second operation records arranged after the first operation record. The target operation record is separated from the first operation record by at least one second operation record.
[0024] The session messages are synchronized based on the target operation record and the received second operation record.
[0025] In the above scheme, after synchronizing the session message based on the target operation record and the received second operation record, the method further includes:
[0026] Delete the target operation record and the received second operation record.
[0027] This application embodiment also provides a session message processing apparatus, including:
[0028] The first receiving module is used to receive a synchronization request for a session message for a target object, wherein the target object is associated with multiple operation records arranged in the order of their generation.
[0029] The operation record is generated by recording the content of the change operation when a change operation is performed on the session message. The synchronization of the session message is achieved by synchronizing the multiple operation records in the order they are arranged.
[0030] The first determining module is used to determine, based on the synchronization request, that the session message has been synchronized to the first operation record among the multiple operation records, and to determine the multiple second operation records arranged after the first operation record;
[0031] The second determining module is used to determine, when it is determined based on the plurality of second operation records that the fast forward synchronization condition is met, a target operation record that is separated from the first operation record by at least one second operation record from the plurality of second operation records.
[0032] The first sending module is used to send the target operation record and a second operation record arranged after the target operation record, so as to synchronize the session message based on the target operation record and the received second operation record.
[0033] In the above scheme, the operation record has a corresponding sequence number. The first determining module is further used to parse the synchronization request to obtain the first sequence number included in the synchronization request; determine the operation record corresponding to the first sequence number as the first operation record, so as to determine that the session message has been synchronized to the first operation record among the multiple operation records.
[0034] In the above scheme, the sequence numbers of the multiple operation records are monotonically increased according to the order of arrangement, and the increment of the monotonically increasing sequence number is 1; the second determining module is further used to determine the target sequence number corresponding to the operation record that is the last one in the multiple operation records; when the difference between the target sequence number and the first sequence number reaches the difference threshold, it is determined that the fast forward synchronization condition is satisfied.
[0035] In the above scheme, the second determining module is further used to obtain the number of records of the plurality of second operation records; when the number of records reaches the number threshold, it is determined that the fast forward synchronization condition is satisfied.
[0036] In the above scheme, the second determining module is further used to obtain the data size of the multiple second operation records; when the data size reaches the data size threshold, it is determined that the fast forward synchronization condition is satisfied.
[0037] In the above scheme, the second determining module is further configured to obtain fast-forward indication information included in the synchronization request, wherein the fast-forward indication information is used to indicate whether the session message is allowed to be synchronized in a fast-forward synchronization mode; the second determining module is further configured to, when the fast-forward indication information is used to indicate that the session message is allowed to be synchronized in a fast-forward synchronization mode, and the fast-forward synchronization condition is satisfied based on the multiple second operation records, determine a target operation record that is separated from the first operation record by at least one second operation record from the multiple second operation records.
[0038] In the above scheme, the first sending module is further configured to send the multiple second operation records when the fast-forward indication information is used to indicate that the session messages are not allowed to be synchronized in the fast-forward synchronization mode, so that the session messages are synchronized based on the multiple second operation records.
[0039] In the above scheme, the second determining module is further configured to obtain message usage feature information of the target object; based on the message usage feature information, determine the target number of second operation records that are separated from the first operation record by the target operation record; and take the second operation record that is separated from the first operation record by the target number of second operation records as the target operation record.
[0040] In the above scheme, the second determining module is further configured to obtain message usage feature information of the target object; based on the message usage feature information, call a neural network model to predict the target operation record among the multiple second operation records to obtain a prediction result; and take the second operation record indicated by the prediction result as the target operation record that is separated from the first operation record by at least one second operation record.
[0041] In the above scheme, the operation record has a corresponding sequence number. The first sending module is further configured to send a fast-forward notification message to notify the synchronization of the session messages in a fast-forward synchronization mode. The fast-forward notification message is used to construct a gap interval upon receiving the fast-forward notification message, using the first sequence number of the first operation record as the interval start point and the second sequence number of the target operation record as the interval end point. The first receiving module is further configured to receive a message gap synchronization request, which includes the gap interval. The message gap synchronization request is sent when a message gap is detected in the synchronized session messages. The first sending module is further configured to respond to the message gap synchronization request by returning the operation record corresponding to the target sequence number between the first sequence number and the second sequence number, based on the gap interval. The operation record corresponding to the target sequence number is used to synchronize the session messages missing in the message gap.
[0042] This application embodiment also provides a session message processing apparatus, including:
[0043] The second sending module is used to send a synchronization request for a session message to a target object, which is associated with multiple operation records arranged in the order of their generation.
[0044] The operation record is generated by recording the content of the change operation when a change operation is performed on the session message. The synchronization of the session message is achieved by synchronizing the multiple operation records in the order they are arranged. The synchronization request is used to indicate that the session message has been synchronized to the first operation record among the multiple operation records.
[0045] The second receiving module is used to receive the target operation record returned based on the synchronization request, and the second operation record arranged after the target operation record;
[0046] The target operation record is determined from multiple second operation records when the fast forward synchronization condition is satisfied based on multiple second operation records arranged after the first operation record. The target operation record is separated from the first operation record by at least one second operation record.
[0047] The synchronization module is used to synchronize the session messages based on the target operation record and the received second operation record.
[0048] In the above scheme, the synchronization module is further configured to use the target operation record and the received second operation record as message operation records, and determine the target session message corresponding to each message operation record; when there are multiple target session messages, for each target session message, the message operation records corresponding to the target session message are merged, and the merged result is used as the final state of the target session message, so as to synchronize the session messages.
[0049] In the above scheme, the change operation includes: message addition operation; the synchronization module is further used to determine whether the message operation record corresponding to the target session message contains an operation record corresponding to the message addition operation; when it is determined that the operation record contains the message addition operation, the merged result is used as the final state of the target session message; the synchronization module is further used to store the merged result when it is determined that the operation record does not contain the message addition operation.
[0050] In the above scheme, the synchronization module is also used to delete the target operation record and the received second operation record.
[0051] In the above scheme, the synchronization module is further configured to detect message synchronization status during the process of synchronizing the session message based on the target operation record and the received second operation record; when the message synchronization status indicates that the session message has a synchronization abnormality, the synchronized session message is deleted during the process; the second sending module is further configured to resend the synchronization request for the session message for the target object.
[0052] This application also provides an electronic device, including:
[0053] Memory, used to store executable instructions;
[0054] The processor, when executing executable instructions stored in the memory, implements the session message processing method provided in the embodiments of this application.
[0055] This application also provides a computer-readable storage medium storing executable instructions, which, when executed by a processor, implement the session message processing method provided in this application.
[0056] This application also provides a computer program product, including a computer program or instructions, which, when executed by a processor, implement the session message processing method provided in this application.
[0057] The embodiments of this application have the following beneficial effects:
[0058] When synchronizing session messages based on multiple operation records corresponding to a session message using the embodiments of this application, if it is determined that the fast-forward synchronization condition is met based on multiple second operation records following the currently synchronized first operation record, a target operation record that is separated from the first operation record by at least one second operation record can be determined from the multiple second operation records. The target operation record and the second operation record arranged after the target operation record are then sent so that the session message is synchronized based on the target operation record and the received second operation record.
[0059] This allows for the synchronization of session messages to proceed without continuing from the already synchronized first operation record. Instead, it fast-forwards from the first operation record to the target operation record (listed after the first operation record), which is at least one second operation record away from the first operation record. Synchronization then continues based on the target operation record and the second operation records following it. This reduces the amount of data transmitted for operation records, improving network transmission efficiency, and also increases the efficiency of session message synchronization, reducing the time required to synchronize session messages to the latest message, thus enhancing the user experience. Attached Figure Description
[0060] Figure 1 This is a schematic diagram of the architecture of the session message processing system 100 provided in the embodiments of this application;
[0061] Figure 2 This is a schematic diagram of the structure of an electronic device 500 that implements the session message processing method provided in the embodiments of this application;
[0062] Figure 3 This is a flowchart illustrating the session message processing method provided in an embodiment of this application;
[0063] Figure 4 This is a schematic diagram of multiple operation records provided in an embodiment of this application;
[0064] Figure 5 This is a flowchart illustrating the session message processing method provided in an embodiment of this application;
[0065] Figure 6 This is a flowchart illustrating the session message processing method provided in an embodiment of this application;
[0066] Figure 7 This is a schematic diagram of the architecture of the session message processing system provided in the embodiments of this application;
[0067] Figure 8 This is a flowchart illustrating the session message processing method provided in the embodiments of this application. Detailed Implementation
[0068] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0069] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0070] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0071] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0072] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.
[0073] 1) Client: An application that runs on a terminal and provides various services, such as an instant messaging client.
[0074] 2) In response, used to indicate the conditions or states on which the operation performed depends. When the conditions or states on which it depends are met, one or more operations performed may be performed in real time or with a set delay. Unless otherwise specified, there is no restriction on the order in which the multiple operations are performed.
[0075] The following describes the session message processing method, apparatus, device, storage medium, and computer program product provided in the embodiments of this application. The embodiments of this application provide a session message processing method, apparatus, device, storage medium, and computer program product that can improve the synchronization efficiency of session messages.
[0076] The following describes the implementation scenario of the session message processing method provided in the embodiments of this application. See also Figure 1 , Figure 1This is a schematic diagram of the architecture of the session message processing system 100 provided in the embodiments of this application. In order to support an exemplary application, the terminal 400 connects to the server 200 through the network 300. The network 300 can be a wide area network or a local area network, or a combination of the two, and data transmission is achieved using wireless or wired links.
[0077] Terminal 400 (equipped with a client, such as an instant messaging client) is used to send synchronization requests for session messages targeting a specific object to server 200.
[0078] Server 200 is configured to receive a synchronization request for a session message targeting a target object sent by terminal 400; based on the synchronization request, determine that the session message has been synchronized to a first operation record among multiple operation records, and determine multiple second operation records arranged after the first operation record; when it is determined that the fast-forward synchronization condition is met based on the multiple second operation records, determine a target operation record that is separated from the first operation record by at least one second operation record from the multiple second operation records; and send the target operation record and the second operation records arranged after the target operation record to terminal 400.
[0079] Terminal 400 is used to receive the target operation record returned by server 200 based on the synchronization request, and the second operation record arranged after the target operation record; to synchronize the session message based on the target operation record and the received second operation record, and to display the session message indicating that the synchronization is complete.
[0080] The target object is associated with multiple operation records arranged in the order of their generation. These operation records are generated by recording the content of the change operation when a change operation is performed on a session message. The synchronization of session messages is achieved by synchronizing multiple operation records in the order they are arranged.
[0081] In some embodiments, the session message processing method provided in this application can be implemented by various electronic devices. For example, it can be implemented by a terminal alone, by a server alone, or by a terminal and a server working together. This application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, and assisted driving.
[0082] In some embodiments, the electronic device for processing session messages provided in this application can be various types of terminal devices or servers. The server (e.g., server 200) can be a standalone physical server, a server cluster consisting of multiple physical servers, or a distributed system. The terminal (e.g., terminal 400) can be a smartphone, tablet computer, laptop computer, desktop computer, intelligent voice interaction device (e.g., smart speaker), smart home appliance (e.g., smart TV), smartwatch, in-vehicle terminal, etc., but is not limited thereto. The terminal and server can be directly or indirectly connected via wired or wireless communication, and this application does not impose any limitations on this.
[0083] In some embodiments, the session message processing method provided in this application can be implemented using cloud technology. Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and networks within a wide area network or local area network to achieve data computation, storage, processing, and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, and application technology applied based on the cloud computing business model. It can form resource pools, be used on demand, and is flexible and convenient. Cloud computing technology will become an important support. The backend services of the technology network system require a large amount of computing and storage resources. As an example, the server (e.g., server 200) can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0084] In some embodiments, the terminal or server can implement the session message processing method provided in this application by running a computer program. For example, the computer program can be a native program or software module in an operating system; it can be a native application (APP), i.e., a program that needs to be installed in the operating system to run; it can also be a mini-program, i.e., a program that only needs to be downloaded to a browser environment to run; or it can be a mini-program that can be embedded in any APP. In short, the above-mentioned computer program can be any form of application, module, or plugin.
[0085] In some embodiments, multiple servers can form a blockchain, with each server being a node on the blockchain. Information connections can exist between each node in the blockchain, allowing for information transmission between them. Furthermore, data related to the session message processing method provided in this application (e.g., multiple operation records associated with the target object) can be stored on the blockchain.
[0086] The following describes an electronic device that implements a session message processing method according to embodiments of this application. See also: Figure 2 , Figure 2 This is a schematic diagram of the structure of an electronic device 500 that implements the session message processing method provided in this application embodiment. Taking the electronic device 500 as an example... Figure 1 Taking the server shown as an example, the electronic device 500 implementing the session message processing method provided in this application embodiment includes: at least one processor 510, a memory 550, at least one network interface 520, and a user interface 530. The various components in the electronic device 500 are coupled together through a bus system 540. It is understood that the bus system 540 is used to implement communication between these components. In addition to a data bus, the bus system 540 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 2 The general labeled all buses as Bus System 540.
[0087] The processor 510 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.
[0088] Memory 550 may be removable, non-removable, or a combination thereof. Memory 550 may optionally include one or more storage devices physically located remote from processor 510. Memory 550 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), and the volatile memory may be random access memory (RAM). The memory 550 described in this application embodiment is intended to include any suitable type of memory.
[0089] In some embodiments, memory 550 is capable of storing data to support various operations, examples of which include programs, modules, and data structures or subsets or supersets thereof, as illustrated below.
[0090] Operating system 551 includes system programs for handling various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, driver layer, etc., for implementing various basic business functions and handling hardware-based tasks;
[0091] The network communication module 552 is used to reach other computing devices via one or more (wired or wireless) network interfaces 520, exemplary network interfaces 520 including: Bluetooth, WiFi, and Universal Serial Bus (USB), etc.
[0092] In some embodiments, the session message processing apparatus provided in this application can be implemented in software. Figure 2 A processing device 553 for session messages stored in memory 550 is shown. It may be software in the form of programs and plug-ins, including the following software modules: a first receiving module 5531, a first determining module 5532, a second determining module 5533, and a first sending module 5534. These modules are logically related and can therefore be arbitrarily combined or further split according to the functions they implement. The functions of each module will be described below.
[0093] The following describes the session message processing method provided in the embodiments of this application. In some embodiments, the session message processing method provided in the embodiments of this application can be implemented by various electronic devices. For example, it can be implemented by a terminal alone, by a server alone, or by a terminal and a server working together. Taking server implementation as an example, see [link to documentation]. Figure 3 , Figure 3 This is a flowchart illustrating a session message processing method provided in an embodiment of this application. The session message processing method provided in an embodiment of this application includes:
[0094] Step 101: The server receives a synchronization request for the session message of the target object.
[0095] The target object is associated with multiple operation records arranged in the order of their generation; the operation record is generated by recording the content of the change operation when a change operation is performed on a session message; the synchronization of session messages is achieved by synchronizing multiple operation records in the order of their arrangement.
[0096] In practical applications, the terminal can have a client installed that supports sending and receiving session messages, such as an instant messaging client. When the terminal runs this client and is logged into the target object's account, it needs to synchronize the target object's session messages (such as unread session messages sent and received by the target object, read historical session messages, etc.). At this time, the terminal sends a synchronization request for the target object's session messages to the server (such as the client's backend server, or a server that specifically supports session message synchronization) through the client.
[0097] In this embodiment, whenever a change operation is performed on a session message, a corresponding operation record is generated by recording the content of the change operation. This results in multiple operation records associated with the target object, which can be arranged in the order they were generated. In practice, the change operation can be a message addition operation (such as sending a new session message or receiving a new session message), a message modification operation (such as message recall), or a message deletion operation. Examples of multiple operation records for this session message include "New Message 1", "Recall Message 1", and "Delete Message 1".
[0098] In this embodiment, the multiple operation records are synchronized to the client according to their order of arrangement, so that the client can synchronize session messages based on these multiple operation records. It should be noted that the term "session message" (or "message") is used generically and does not specifically refer to any particular session message.
[0099] Step 102: Based on the synchronization request, determine that the session message has been synchronized to the first operation record among multiple operation records, and determine the multiple second operation records arranged after the first operation record.
[0100] In practical applications, after receiving a synchronization request, the server determines, based on the request, which of the multiple operation records the session message has been synchronized to. Here, based on the synchronization request, the server determines that the session message has been synchronized to the first operation record among the multiple operation records. Simultaneously, it can also determine multiple second operation records that are listed after the first operation record. These multiple second operation records are the operation records that have not yet been synchronized on the client side.
[0101] In some embodiments, the operation record has a corresponding sequence number. The server can determine that the session message has been synchronized to the first operation record among multiple operation records by parsing the synchronization request to obtain the first sequence number included in the synchronization request; and determining that the operation record corresponding to the first sequence number is the first operation record, thereby determining that the session message has been synchronized to the first operation record among multiple operation records.
[0102] In practical applications, each operation record has a corresponding sequence number. The sequence numbers of these multiple operation records can be monotonically increased according to the order in which the operation records are arranged, with an increment of 1. See [example example]. Figure 4 , Figure 4This is a schematic diagram of multiple operation records provided in an embodiment of this application. Here, the multiple operation records constitute a message operation queue. The multiple operation records include: operation record 1, operation record 2, ..., operation record (N-1) (N is a positive integer), operation record N (N is a positive integer). Correspondingly, each operation record has a corresponding sequence number. The sequence numbers of the multiple operation records can be monotonically increased according to the order in which the operation records are arranged. The monotonically increasing increment is 1, that is, the sequence number of operation record 1 is 1, the sequence number of operation record 2 is 2, ..., the sequence number of operation record (N-1) (N is a positive integer) is (n-1) (n is a positive integer), and the sequence number of operation record N (N is a positive integer) is n (n is a positive integer).
[0103] In practice, when a terminal sends a synchronization request to the server, it can include the sequence number of the latest synchronized operation record. Based on this, the server can parse the synchronization request to obtain the first sequence number included in the request. The operation record corresponding to this first sequence number is the sequence number of the latest synchronized operation record on the terminal side. In other words, the server determines that the operation record corresponding to the first sequence number is the first operation record, thus confirming that the session message has been synchronized to the first operation record among multiple operation records.
[0104] In some embodiments, the sequence numbers of multiple operation records are monotonically increased in chronological order, with an increment of 1. The server can determine whether the fast-forward synchronization condition is met by: determining the target sequence number corresponding to the last operation record among the multiple operation records; and determining that the fast-forward synchronization condition is met when the difference between the target sequence number and the first sequence number reaches a difference threshold. Here, the fast-forward synchronization condition is that the difference between the target sequence number and the first sequence number reaches a difference threshold. In actual implementation, a difference threshold can be preset. When determining whether the fast-forward synchronization condition is met based on multiple second operation records, the target sequence number corresponding to the last operation record among the multiple operation records can be determined. This target sequence number is the sequence number of the latest operation record in the server-side session message. Then, the target sequence number is compared with the first sequence number of the synchronized first operation record to determine the difference between the target sequence number and the first sequence number. Thus, when the difference between the target sequence number and the first sequence number reaches the difference threshold, the fast-forward synchronization condition is met.
[0105] In some embodiments, the server can determine whether the fast-forward synchronization condition is met by: obtaining the number of records of multiple second operation records; and determining that the fast-forward synchronization condition is met when the number of records reaches a threshold. Here, the fast-forward synchronization condition is that the number of unsynchronized second operation records reaches the threshold. In actual implementation, the threshold can be preset. After the server obtains the number of records of multiple second operation records, it compares the record number with the threshold; thus, when the number of records reaches the threshold, it determines that the fast-forward synchronization condition is met.
[0106] In some embodiments, the server can determine whether the fast-forward synchronization condition is met by: obtaining the data size of multiple second operation records; and determining that the fast-forward synchronization condition is met when the data size reaches a data size threshold. Here, the fast-forward synchronization condition is that the data size of the multiple unsynchronized second operation records reaches the data size threshold. In practice, a data size threshold can be preset. After the server obtains the data size of the multiple second operation records, it compares the data size with the data size threshold; thus, it determines that the fast-forward synchronization condition is met when the data size reaches the data size threshold.
[0107] Step 103: When it is determined that the fast forward synchronization condition is met based on multiple second operation records, determine the target operation record that is separated from the first operation record by at least one second operation record from the multiple second operation records.
[0108] In practical applications, when the fast-forward synchronization condition is met based on multiple second operation records, a fast-forward synchronization method can be used to synchronize session messages. This method prevents the client from continuing session message synchronization from the already synchronized first operation record. Instead, it fast-forwards from the first operation record to a target operation record (selected from multiple second operation records) that is at least one second operation record away from the first operation record. Session message synchronization then continues based on the target operation record and the second operation records following it. Therefore, when the fast-forward synchronization condition is met based on multiple second operation records, the target operation record, which is at least one second operation record away from the first operation record, can be selected from among the multiple second operation records. This reduces the amount of data transmitted for operation records, improving network transmission efficiency, and also increases the synchronization efficiency of session messages, reducing the time spent synchronizing session messages to the latest message, thus improving the user experience.
[0109] In some embodiments, the server may obtain fast-forward indication information included in the synchronization request, which is used to indicate whether session messages are allowed to be synchronized in a fast-forward synchronization manner; accordingly, the server may determine a target operation record that is separated from the first operation record by at least one second operation record from a plurality of second operation records in the following manner: when the fast-forward indication information is used to indicate that session messages are allowed to be synchronized in a fast-forward synchronization manner, and it is determined based on a plurality of second operation records that the fast-forward synchronization condition is met, the target operation record that is separated from the first operation record by at least one second operation record is determined from a plurality of second operation records.
[0110] In practical applications, the terminal can also include fast-forward indication information in the synchronization request to indicate whether session messages are allowed to be synchronized in a fast-forward synchronization mode. Before determining whether the fast-forward synchronization condition is met based on multiple second operation records, the server can parse the synchronization request. Once the fast-forward indication information indicating that session messages are allowed to be synchronized in a fast-forward synchronization mode is obtained from the parsed synchronization request, the server can further determine whether the fast-forward synchronization condition is met based on multiple second operation records. If the fast-forward synchronization condition is determined to be met based on multiple second operation records, the target operation record that is separated from the first operation record by at least one second operation record is identified from the multiple second operation records.
[0111] In some embodiments, when the fast-forward indication information is used to indicate that session messages are not allowed to be synchronized in a fast-forward synchronization manner, the server may send multiple second operation records so that the session messages are synchronized based on the multiple second operation records.
[0112] In practical applications, when parsing a synchronization request yields a fast-forward indication message indicating that session messages are not allowed to be synchronized using the fast-forward synchronization method, it signifies that fast-forward synchronization of session messages is not permitted. In this case, the server sends multiple unsynchronized second operation records to the terminal, enabling the terminal to synchronize session messages based on these records.
[0113] In some embodiments, the server may determine a target operation record that is separated from the first operation record by at least one second operation record from a plurality of second operation records by: obtaining message usage feature information of the target object; determining a target number of second operation records that are separated from the first operation record based on the message usage feature information; and taking the second operation record that is separated from the first operation record by the target number of second operation records from the plurality of second operation records as the target operation record.
[0114] In practical applications, the server can obtain message usage characteristic information of the target object. This message usage characteristic information may include at least one of the following: the number of messages within a target period (e.g., daily, weekly, 12-hour), the usage frequency of the client where the session message is located, the average size of the message body, and the multi-terminal situation of the client where the session message is located. Based on the obtained message usage characteristic information, the target number of second operation records separated from the first operation record is determined. In actual implementation, when there are multiple message usage characteristic information pieces, the target number can also be calculated by combining the weight corresponding to each message usage characteristic information piece. Once the target number is determined, the second operation record that is separated from the first operation record by the target number of times among the multiple second operation records is taken as the target operation record.
[0115] In some embodiments, the server may determine a target operation record that is at least one second operation record away from the first operation record from a plurality of second operation records by: obtaining message usage feature information of the target object; based on the message usage feature information and the plurality of second operation records, calling a neural network model to predict the target operation record among the plurality of second operation records, and obtaining a prediction result; and taking the second operation record indicated by the prediction result as the target operation record that is at least one second operation record away from the first operation record.
[0116] In practical applications, the server can obtain message usage characteristic information of the target object. This message usage characteristic information may include at least one of the following: the message volume within the target period (e.g., daily, weekly, 12-hour), the usage frequency of the client where the session message is located, the average size of the message body, and the multi-terminal situation of the client where the session message is located. Based on the obtained message usage characteristic information and multiple second operation records, a pre-trained neural network model can be invoked to predict the target operation record among the multiple second operation records, obtaining the prediction result. In practical applications, this neural network model can be trained using an operation record sample set (including multiple operation record samples) and message usage characteristic information samples as training samples, with the label indicating whether the operation record sample is the target operation sample. The second operation record indicated by the prediction result is taken as the target operation record that is separated from the first operation record by at least one second operation record.
[0117] Step 104: Send the target operation record and the second operation record arranged after the target operation record, so as to synchronize the session message based on the target operation record and the received second operation record.
[0118] In practical applications, after the server determines the target operation record that is at least one second operation record away from the first operation record, it sends the target operation record and the second operation record following the target operation record to the terminal. After receiving the target operation record and the second operation record following the target operation record, the terminal synchronizes the session messages based on the target operation record and the received second operation record.
[0119] In some embodiments, the operation record has a corresponding sequence number, and the server can send a fast-forward notification message to notify the synchronization of session messages in a fast-forward synchronization manner; wherein, the fast-forward notification message is used to construct a gap interval with the first sequence number of the first operation record as the interval start point and the second sequence number of the target operation record as the interval end point when the fast-forward notification message is received.
[0120] Accordingly, the server can synchronize the operation records corresponding to the missing intervals in the following ways: receive a message hole synchronization request, which includes the missing interval; the message hole synchronization request is sent when a message hole is detected in the synchronized session messages; respond to the message hole synchronization request, and return the operation record corresponding to the target sequence number between the first sequence number and the second sequence number based on the missing interval; wherein, the operation record corresponding to the target sequence number is used to synchronize the session messages missing in the message hole.
[0121] In practical applications, since the server returns the fast-forwarded operation record (i.e., the target operation record and the second operation record following the target operation record), the server can carry a fast-forward notification message during the return of the operation record to notify the synchronization of session messages using the fast-forward synchronization method. When the terminal receives this fast-forward notification message, it determines that the received operation record is the fast-forwarded operation record and is not continuous with the currently synchronized first operation record. In order to avoid the situation where the synchronized session messages are missed due to the lack of operation records, a gap interval is constructed with the first sequence number of the terminal's first operation record as the starting point of the interval and the second sequence number of the target operation record as the ending point of the interval. This gap interval represents the sequence number interval of the operation records that the terminal has not obtained, that is, the sequence number interval of the operation records skipped during fast-forwarding.
[0122] Based on this, the terminal can periodically check for message gaps in the locally synchronized session messages during idle periods. These gaps are caused by the absence of operation records corresponding to the missing intervals. When the terminal detects a message gap, it sends a message gap synchronization request to the server, which includes the missing interval. Upon receiving the message gap synchronization request, the server responds by determining, based on the missing interval, the operation record corresponding to the target sequence number between the first and second sequence numbers from multiple operation records, and returns this target sequence number to the terminal. After receiving the operation record corresponding to the target sequence number, the terminal synchronizes the session messages missing due to the message gap based on this operation record.
[0123] Applying the above embodiments of this application, when synchronizing session messages based on multiple operation records corresponding to a session message, if it is determined that the fast-forward synchronization condition is met based on multiple second operation records following the currently synchronized first operation record, a target operation record separated from the first operation record by at least one second operation record can be determined from the multiple second operation records. The target operation record and the second operation records following the target operation record are then sent to synchronize the session message based on the target operation record and the received second operation record. This allows for synchronization of session messages without continuing from the synchronized first operation record, instead fast-forwarding from the first operation record to the target operation record (sequentially following the first operation record) separated from the first operation record, and continuing synchronization based on the target operation record and the second operation records following it. This reduces the amount of data transmitted for operation records, facilitating network transmission, and also improves the synchronization efficiency of session messages, reducing the time spent synchronizing session messages to the latest message, thus improving the user experience.
[0124] The following continues to describe the session message processing method provided in the embodiments of this application. In some embodiments, the session message processing method provided in the embodiments of this application can be implemented by various electronic devices. For example, it can be implemented by a terminal alone, by a server alone, or by a terminal and a server working together. Taking terminal implementation as an example, see [link to documentation]. Figure 5 , Figure 5 This is a flowchart illustrating a session message processing method provided in an embodiment of this application. The session message processing method provided in an embodiment of this application includes:
[0125] Step 201: The terminal sends a synchronization request for the session message of the target object.
[0126] The target object is associated with multiple operation records arranged in the order of their generation; the operation record is generated by recording the content of the change operation when a change operation is performed on a session message; the synchronization of the session message is achieved by synchronizing multiple operation records in the order of their arrangement; the synchronization request is used to indicate that the session message has been synchronized to the first operation record among the multiple operation records.
[0127] In practical applications, the terminal can have a client installed that supports sending and receiving session messages, such as an instant messaging client. When the terminal runs this client and is logged into the target object's account, it needs to synchronize the target object's session messages (such as unread session messages sent and received by the target object, read historical session messages, etc.). At this time, the terminal sends a synchronization request for the target object's session messages to the server (such as the client's backend server, or a server that specifically supports session message synchronization) through the client.
[0128] In this embodiment, whenever a change operation is performed on a session message, a corresponding operation record is generated by recording the content of the change operation. This results in multiple operation records associated with the target object, which can be arranged in the order they were generated. In practice, the change operation can be a message addition operation (such as sending a new session message or receiving a new session message), a message modification operation (such as message recall), or a message deletion operation. Examples of multiple operation records for this session message include "New Message 1", "Recall Message 1", and "Delete Message 1".
[0129] In this embodiment, the multiple operation records are synchronized to the client according to their order of arrangement, so that the client can synchronize session messages based on these multiple operation records. It should be noted that the term "session message" (or "message") is used generically and does not specifically refer to any particular session message.
[0130] After receiving a synchronization request for a session message targeting a target object, the server determines, based on the synchronization request, that the session message has been synchronized to the first operation record among multiple operation records, and determines multiple second operation records arranged after the first operation record; then, based on the multiple second operation records, it determines whether the fast-forward synchronization condition is met; when it is determined based on the multiple second operation records that the fast-forward synchronization condition is met, it determines, from the multiple second operation records, the target operation record that is separated from the first operation record by at least one second operation record; and sends the target operation record and the second operation records arranged after the target operation record to the terminal, so that the terminal synchronizes the session message based on the target operation record and the received second operation records.
[0131] Step 202: Receive the target operation record returned based on the synchronization request, and the second operation record arranged after the target operation record.
[0132] The target operation record is determined from multiple second operation records when the fast-forward synchronization condition is satisfied based on multiple second operation records arranged after the first operation record. The target operation record is separated from the first operation record by at least one second operation record.
[0133] Step 203: Synchronize session messages based on the target operation record and the received second operation record.
[0134] Here, the terminal receives the target operation record returned based on the synchronization request, as well as the second operation record arranged after the target operation record; then, it synchronizes the session message based on the target operation record and the received second operation record.
[0135] In some embodiments, the terminal can synchronize session messages based on the target operation record and the received second operation record in the following manner: the target operation record and the received second operation record are used as message operation records, and the target session message corresponding to each message operation record is determined; when there are multiple target session messages, the message operation records corresponding to each target session message are merged, and the merged result is used as the final state of the target session message to synchronize the session messages.
[0136] In practical applications, the target operation record and the received second operation record are used as message operation records, and the target session message corresponding to each message operation record is determined. It should be noted that the target session message is used to specifically refer to a certain session message. When there are multiple target session messages, the message operation records corresponding to each target session message are merged, and the merged result is used as the final state of the target session message to achieve session message synchronization.
[0137] In some embodiments, the change operation includes a message addition operation; the terminal may use the merged result as the final state of the target session message in the following manner: determine whether the message operation record of the corresponding target session message contains an operation record corresponding to the message addition operation; when it is determined that the operation record of the message addition operation is included, the merged result is used as the final state of the target session message; correspondingly, when it is determined that the operation record of the message addition operation is not included, the server may also store the merged result.
[0138] In practical applications, change operations for session messages include message addition, message modification, and message deletion. The message addition operation can be understood as the basic change operation for a session message, i.e., the operation that generates the session message. Only after a message addition operation has been performed can message modification and deletion operations be applied to that session message. Therefore, the prerequisite for using the merged result as the final state of the target session message is that the message operation records of the merged target session message must contain the operation records corresponding to the message addition operation. This ensures that the operation records can be applied to the corresponding session messages. Therefore, when it is determined that the operation records containing the message addition operation are included, the merged result is used as the final state of the target session message. When it is determined that the operation records not containing the message addition operation are not included, the server can store the merged result and wait for the operation records corresponding to the empty space to be retrieved later during idle time. Then, the message addition operation of the target session message can be retrieved again, and the subsequently retrieved message addition operation can be merged with the stored merged result to obtain the final state of the target session message, thus achieving synchronization of the target session message.
[0139] In some embodiments, the terminal may detect message synchronization status during the process of synchronizing session messages based on the target operation record and the received second operation record; when the message synchronization status indicates that a synchronization abnormality has occurred in the session messages, the synchronized session messages are deleted during the process; accordingly, the terminal may request the synchronization of session messages again in the following manner: resend the synchronization request for the session messages of the target object, the synchronization request being used to indicate that the session messages have been synchronized to the first operation record among multiple operation records.
[0140] In practical applications, the terminal can detect message synchronization during the synchronization of session messages based on the target operation record and the received second operation record. When the message synchronization status indicates an abnormal synchronization situation, such as synchronization failure, the synchronized session messages are deleted. Therefore, when the terminal resends a synchronization request (e.g., upon receiving a synchronization command, or automatically due to synchronization failure), this request also indicates that the session messages have been synchronized to the first operation record among multiple operation records. This prompts the server to return the target operation record and the second operation record following it, thus preventing missing or incomplete message synchronization.
[0141] In some embodiments, after synchronizing session messages based on the target operation record and the received second operation record, the server may delete the target operation record and the received second operation record. This reduces the amount of local storage space used on the terminal.
[0142] Applying the above embodiments of this application, after sending a synchronization request for a session message targeting a target object, a target operation record returned based on the synchronization request and a second operation record arranged after the target operation record are received. This allows for synchronization of session messages based on the target operation record and the received second operation record. The target operation record is a second operation record determined from among multiple second operation records that is at least one second operation record away from the first operation record, provided that the fast-forward synchronization condition is met based on multiple second operation records following the currently synchronized first operation record. In this way, session message synchronization can proceed without continuing from the already synchronized first operation record. Instead, it can fast-forward from the first operation record to the target operation record (arranged after the first operation record) that is at least one second operation record away from the first operation record, and continue synchronization based on the target operation record and the second operation record arranged after it. This reduces the amount of data transmitted and the download time of operation records, improves the synchronization efficiency of session messages, reduces the time spent synchronizing session messages to the latest message, and improves the user experience.
[0143] The method for processing session messages provided in the embodiments of this application will be further described below. Taking a terminal and server collaborative implementation as an example, see [link to example]. Figure 6 , Figure 6 This is a flowchart illustrating a session message processing method provided in an embodiment of this application. The session message processing method provided in an embodiment of this application includes:
[0144] Step 301: The terminal sends a synchronization request for the session message of the target object.
[0145] The synchronization request includes fast-forward indication information for indicating whether the fast-forward synchronization method is allowed to synchronize session messages, and the synchronization request also includes a first sequence number of the first operation record for indicating that the session message has been synchronized to the first operation record among multiple operation records.
[0146] Step 302: The server receives the synchronization request, parses the synchronization request, obtains the first sequence number and fast-forward indication information, and determines that the session message has been synchronized to the first operation record among multiple operation records.
[0147] Step 303: The server determines the target sequence number corresponding to the last operation record among multiple operation records.
[0148] Step 304: When the fast-forward indication information is used to indicate that the session message can be synchronized using the fast-forward synchronization method, the server determines the difference between the first sequence number and the target sequence number.
[0149] Step 305: Determine whether the difference has reached the difference threshold. If yes, proceed to step 306; otherwise, proceed to step 313.
[0150] Step 306: The server determines the target operation record that is separated from the first operation record by at least one second operation record from the multiple second operation records arranged after the first operation record.
[0151] Step 307: The server sends the target operation record and the second operation record following the target operation record to the terminal, and returns a fast-forward notification message to the terminal.
[0152] Step 308: The terminal receives the target operation record and the second operation record arranged after the target operation record, and receives a fast-forward notification message.
[0153] Step 309: The terminal synchronizes the session message based on the target operation record and the received second operation record, and constructs a gap interval with the first sequence number of the first operation record as the interval start point and the second sequence number of the target operation record as the interval end point.
[0154] Step 310: When the terminal detects a message gap in the synchronized session message during idle time, it sends a message gap synchronization request, including the gap interval, to the server.
[0155] Step 311: The server receives the message hole synchronization request and, based on the hole interval, returns the operation record corresponding to the target sequence number between the first sequence number and the second sequence number to the terminal.
[0156] Step 312: The terminal receives the operation record corresponding to the target sequence number and synchronizes the missing session messages in the message gap based on the operation record corresponding to the target sequence number.
[0157] Step 313: The server sends multiple second operation records, arranged after the first operation record, to the terminal.
[0158] Step 314: The terminal receives multiple second operation records arranged after the first operation record and synchronizes session messages based on the received multiple second operation records.
[0159] Applying the above embodiments of this application, when synchronizing session messages based on multiple operation records corresponding to a session message, if it is determined that the fast-forward synchronization condition is met based on multiple second operation records following the currently synchronized first operation record, a target operation record separated from the first operation record by at least one second operation record can be determined from the multiple second operation records. The target operation record and the second operation records following the target operation record are then sent to synchronize the session message based on the target operation record and the received second operation record. This allows for synchronization of session messages without continuing from the synchronized first operation record, instead fast-forwarding from the first operation record to the target operation record (sequentially following the first operation record) separated from the first operation record, and continuing synchronization based on the target operation record and the second operation records following it. This reduces the amount of data transmitted for operation records, facilitating network transmission, and also improves the synchronization efficiency of session messages, reducing the time spent synchronizing session messages to the latest message, thus improving the user experience.
[0160] The following describes an exemplary application of the embodiments of this application in a real-world scenario. Instant messaging clients (such as enterprise-oriented communication and collaboration applications) have very high requirements for the integrity and reliability of session messages (i.e., messages), and typically also expect messages to support local permanent storage, offline viewing without a network, and other functions. To achieve these characteristics, it is necessary to synchronize session messages in the instant messaging client. In some embodiments, a message synchronization scheme can be designed based on the sequence number of the message operation sequence (including multiple operation records, each operation record having a corresponding sequence number). The sequence number-based message synchronization scheme provided by the embodiments of this application will be described in detail below.
[0161] In practical applications, the server creates a message operation queue for each user. This queue stores all change operations performed on the user's session message data, including appending, deleting, and modifying messages (such as message retraction). This message operation queue can only add operation records, not modify them. Whenever a change operation is performed on a session message, an operation record is added to the end of the message operation queue, recording the content of the change operation. Simultaneously, each operation record in the queue is assigned a unique sequence number (seq). The sequence numbers of multiple operation records in the message operation queue are monotonically increasing (incrementing by 1).
[0162] When a client requests to synchronize messages, it sends its locally stored sequence number `syncseq` (the sequence number of the client's currently synchronized operation records) to the server. The server locates the position of the sequence number `syncseq` in the user's message operation queue and sends subsequent operation records (seq>syncseq) to the client in ascending order. The client replays the received operation records locally, calculates the final state of each message, and presents it to the user. Simultaneously, the final states of these messages and the maximum processed sequence number `max(seq)` are stored in the database within the same database transaction.
[0163] In practice, if the client encounters an abnormal interruption during message synchronization based on operation records, the database transaction is rolled back, and no message changes are stored in the database, nor is the maximum processed sequence number `syncseq` changed. Thus, when message synchronization is restarted, the client still sends the previously processed maximum sequence number `syncseq` to the server, and the server can continue to send operation records with sequence numbers up to `syncseq` (seq>syncseq). This ensures that even if the client encounters an abnormal interruption during the synchronization process, no synchronized messages will be missed.
[0164] The aforementioned sequence number-based message synchronization scheme has the advantages of stability and reliability. However, the client needs to download and replay the entire message operation queue to display the latest message status. This means that clients that haven't logged in for a long time and whose sequence numbers are significantly outdated need to spend a considerable amount of time downloading and synchronizing messages to catch up. This is especially noticeable for users whose message operation queues have accumulated tens of millions of messages. During the message synchronization period, which can last for tens of minutes, the client is almost unusable, negatively impacting the user experience.
[0165] Based on this, this application also provides a message synchronization scheme based on sequence number fast-forwarding to at least solve the problems existing in the above-mentioned schemes. In this application embodiment, when the sequence number of the operation record already synchronized locally on the client (i.e., the synchronized sequence number) lags too far behind the sequence number of the latest operation record added by the server (i.e., the latest sequence number on the server), the server can comprehensively consider various message usage characteristics of the user and calculate a new sequence number (located between the synchronized sequence number and the latest sequence number on the server) according to the fast-forwarding strategy, allowing the client to fast-forward from the synchronized sequence number to the new sequence number to start synchronizing messages. At the same time, the unfetched operation records generated by the sequence number fast-forwarding are marked as empty states, and the sequence number range where the unfetched operation records are located is determined as an empty range, so that the operation records in the empty range can continue to be synchronized and processed during idle time, ensuring the integrity of message synchronization.
[0166] See Figure 7 , Figure 7 This is a schematic diagram of the architecture of the session message processing system provided in this application embodiment. Here, the client communicates with the server through a sequence number-based message synchronization protocol. In addition to maintaining the latest sequence number of the locally synchronized operation records and the message table, the client also maintains an additional information representing the local sequence number gap intervals. The gap maintenance service uses the information of the local sequence number gap intervals to continue synchronizing and filling in the operation records within the gap intervals during idle time, and merges them with the locally acquired operation records to achieve message synchronization. On the server side, a sequence number fast-forward strategy is also set up to comprehensively consider various message usage characteristics of users and calculate a new sequence number (located between the synchronized sequence number and the latest sequence number on the server) according to the fast-forward strategy, allowing the client to fast-forward from the synchronized sequence number to the new sequence number to start synchronizing messages.
[0167] See below. Figure 8 The present application provides a detailed description of the session message processing method provided in the embodiments. Figure 8 This is a flowchart illustrating a session message processing method provided in this application embodiment, including: 1. The client requests message synchronization (allowing sequence number fast-forwarding); 2. The server determines that fast-forwarding is needed and returns the operation record after fast-forwarding; 3. The client receives the notification message that the message has been fast-forwarded and the operation record after fast-forwarding; 4. The client performs message synchronization based on the received operation record, updates the synchronized sequence number, and records any gaps in the record; 5. Message synchronization continues using the updated synchronized sequence number; 6. The operation record for any gaps in the record is filled in during idle time.
[0168] First, the process of fast-forwarding sequence numbers is explained. When a client sends a synchronization request for session messages, in addition to carrying the client's current synchronized sequence number syncseq, the synchronization request also includes a flag (fastsync=true), indicating that this synchronization request allows the use of fast-forwarding sequence numbers for synchronizing session messages.
[0169] When the server determines that the current synchronization request does not allow sequence number fast-forwarding (i.e., the synchronization request does not carry the fastsync=true flag), it can be processed according to the sequence number-based message synchronization scheme described above. When the server determines that the current synchronization request allows sequence number fast-forwarding (i.e., the synchronization request carries the fastsync=true flag), 1) obtain the maximum sequence number maxseq of the user's message operation queue; 2) compare the maximum sequence number maxseq with the synchronized sequence number syncseq transmitted by the client. If the difference between maxseq and syncseq reaches the specified difference threshold, the sequence number fast-forwarding strategy module calculates an appropriate new sequence number fastseq based on the user's message usage characteristics (including daily average message volume, usage frequency, average message body size, multi-terminal situation, etc.); 3) starting from the new sequence number fastseq, the operation records corresponding to the new sequence number fastseq, as well as the operation records seq>fastseq, are fragmented and sent to the client, along with a flag (fastmode=true) to notify the client that sequence number fast-forwarding has occurred in this message synchronization.
[0170] After receiving the response packet from the server based on the synchronization request, the client first checks if the fastmode flag exists in the response packet to determine if sequence number fast-forwarding has occurred. If no sequence number fast-forwarding was sent, message synchronization is performed according to the operation record in the response packet; if sequence number fast-forwarding occurred, the client's current synchronized sequence number syncseq and the minimum sequence number min(seq) of the returned operation record are stored locally as a gap interval (syncseq, min(seq)) along with the message synchronization process. Afterwards, message synchronization continues using the new sequence number syncseq = max(seq).
[0171] Second, the message synchronization process is explained. In practical applications, the message synchronization logic includes: a message's operation record begins with a "message insertion operation," then may involve multiple "message modification operations," and finally ends with a "message deletion operation." Specifically, during message synchronization, all operation records corresponding to a single message can be merged, and the merged result becomes the final representation of the message, thus achieving message synchronization. In actual implementation, the client only needs to store the final state of the message after the operations in its local database. After synchronization is complete, intermediate operation data can be discarded to reduce storage space waste.
[0172] When "sequence number fast-forwarding" occurs during message synchronization, the operation record for the message's "message insertion operation" may not be synchronized locally, yet several operation records for the message's "message modification operation" and "message deletion operation" may be received. This prevents these operation records from being applied to the corresponding message, but they cannot be discarded. In this embodiment, these operation records can be merged and stored in a database. Once the missing operation records are filled, they can be applied to the corresponding messages. In actual implementation, because the client-side message's "message insertion operation" operation record is not synchronized, the message will not be displayed on the user interface, and the user will not be aware of these stored operation records.
[0173] Once message synchronization is complete using the fast-forwarded sequence number, the client's latest synchronized sequence number will catch up with the latest sequence number (or maximum sequence number) in the server's message operation queue. At this point, the user can start using the client normally, sending and receiving new messages. However, some older messages will be missing, which will be retrieved and filled in by the subsequent idle maintenance service.
[0174] Third, the processing flow of the hole maintenance service is described. In this embodiment, each time the client receives a sequence number fast-forward flag, a hole interval is generated in the client database. The range is from the synchronized sequence number syncseq carried by the client when sending the synchronization request to the minimum sequence number min(seq) in the server response packet. This hole interval (syncseq, min(seq)) is recorded and filled by the hole maintenance service during idle time.
[0175] When idle, the client periodically checks its local database for empty intervals. Based on the sequence number (seq), it selects a continuous empty interval from largest to smallest and requests synchronization of the operation records within that interval from the server. Simultaneously, it disables sequence number fast-forwarding (i.e., the synchronization request for this empty interval can carry the flag "fastsync=false"). The server returns the operation records within the empty interval to the client. The client then merges the received operation records with previously saved operation records. Specifically, if a message previously only had "message modification" and "message deletion" operation records, but a "message insertion" operation record is synchronized, the "message insertion" operation record can be merged with the previously obtained "message modification" and "message deletion" operation records, and the final merged result becomes the final representation of the message. Simultaneously, the saved operation record is deleted; otherwise, the operation records are merged and saved. After processing the operation records within the empty interval, the merged result is saved within the same database transaction, and the empty interval is marked as filled.
[0176] After the operation records within the aforementioned empty intervals are processed, the system continues to check for empty intervals during the next idle time, repeating the above process until all empty intervals are filled. If the client experiences an abnormal termination during the retrieval of an empty interval, a database transaction rollback is performed, and no changes are stored in the client database; the message empty intervals remain unchanged. This ensures that the next time message gaps are checked, all missing messages can still be filled, ultimately preventing any message omissions.
[0177] In practical implementation, before applying the message synchronization scheme based on sequence number fast forward provided in this application, the client would wait for the message synchronization process for tens of minutes from login to normal message sending and receiving, during which time it would be unusable. However, after applying the message synchronization scheme based on sequence number fast forward provided in this application, regardless of how long the client has not logged in, under the control of the background policy, it can usually enter a usable state after a synchronization time of no more than 30 seconds, view the latest messages, and send and receive messages normally. In the end, all messages can be synchronized to the client's local machine without any loss or damage.
[0178] By applying the above embodiments of this application, when the locally synchronized sequence number on the client lags far behind the latest sequence number on the server, the server comprehensively considers various user usage characteristics and calculates a new sequence number (located between the synchronized sequence number and the latest sequence number on the server) according to a strategy. The client then fast-forwards to the new sequence number to begin synchronizing messages, enabling clients that have not been used for a long time to quickly obtain the latest messages and enter a usable state. Furthermore, the unfetched operation records generated by the sequence number fast-forwarding are marked as empty states, and the sequence number range where the unfetched operation records are located is determined as an empty range. This allows for continued synchronization and processing of operation records within the empty range during subsequent idle periods, ensuring the integrity and reliability of local message data and improving the user experience.
[0179] It is understood that in the embodiments of this application, data related to user information, session messages, and operation records of session messages are involved. When the embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0180] The following description continues to illustrate the exemplary structure of the session message processing apparatus 553 provided in the embodiments of this application as a software module. In some embodiments, such as Figure 2 As shown, the software modules in the session message processing device 553 stored in the memory 550 may include: a first receiving module 5531, configured to receive a synchronization request for a session message for a target object, the target object being associated with multiple operation records arranged in the order of their generation; wherein, the operation records are generated by recording the content of a change operation when a change operation is performed on the session message, and the synchronization of the session message is achieved by synchronizing the multiple operation records in the order of their arrangement; a first determining module 5532, configured to determine, based on the synchronization request, that the session message has been synchronized to a first operation record among the multiple operation records, and to determine multiple second operation records arranged after the first operation record; a second determining module 5533, configured to, when it is determined based on the multiple second operation records that the fast-forward synchronization condition is met, determine, from the multiple second operation records, a target operation record that is separated from the first operation record by at least one second operation record; and a first sending module 5534, configured to send the target operation record and the second operation records arranged after the target operation record, so as to synchronize the session message based on the target operation record and the received second operation records.
[0181] In some embodiments, the operation record has a corresponding sequence number. The first determining module 5532 is further configured to parse the synchronization request to obtain the first sequence number included in the synchronization request; determine the operation record corresponding to the first sequence number as the first operation record, so as to determine that the session message has been synchronized to the first operation record among the multiple operation records.
[0182] In some embodiments, the sequence numbers of the plurality of operation records are monotonically increased according to the order of arrangement, and the monotonically increasing increment is 1; the second determining module 5533 is further configured to determine the target sequence number corresponding to the operation record that is the last one in the plurality of operation records; when the difference between the target sequence number and the first sequence number reaches the difference threshold, it is determined that the fast forward synchronization condition is satisfied.
[0183] In some embodiments, the second determining module 5533 is further configured to obtain the number of records of the plurality of second operation records; when the number of records reaches a number threshold, it is determined that the fast forward synchronization condition is satisfied.
[0184] In some embodiments, the second determining module 5533 is further configured to obtain the data size of the plurality of second operation records; when the data size reaches the data size threshold, it is determined that the fast forward synchronization condition is satisfied.
[0185] In some embodiments, the second determining module 5533 is further configured to obtain fast-forward indication information included in the synchronization request, the fast-forward indication information being used to indicate whether the session message is allowed to be synchronized in a fast-forward synchronization manner; the second determining module 5533 is further configured to, when the fast-forward indication information is used to indicate that the session message is allowed to be synchronized in a fast-forward synchronization manner, and the fast-forward synchronization condition is determined to be satisfied based on the plurality of second operation records, determine a target operation record that is separated from the first operation record by at least one second operation record from the plurality of second operation records.
[0186] In some embodiments, the first sending module 5534 is further configured to send the plurality of second operation records when the fast-forward indication information is used to indicate that the session messages are not allowed to be synchronized in a fast-forward synchronization mode, so as to synchronize the session messages based on the plurality of second operation records.
[0187] In some embodiments, the second determining module 5533 is further configured to obtain message usage feature information of the target object; determine the target number of second operation records that are separated from the first operation record based on the message usage feature information; and take the second operation record that is separated from the first operation record by the target number of second operation records as the target operation record.
[0188] In some embodiments, the second determining module 5533 is further configured to obtain message usage feature information of the target object; based on the message usage feature information, call a neural network model to predict the target operation record among the plurality of second operation records to obtain a prediction result; and take the second operation record indicated by the prediction result as the target operation record that is separated from the first operation record by at least one second operation record.
[0189] In some embodiments, the operation record has a corresponding sequence number. The first sending module 5534 is further configured to send a fast-forward notification message to notify the synchronization of the session messages in a fast-forward synchronization mode. The fast-forward notification message is used to construct a gap interval upon receiving the fast-forward notification message, using the first sequence number of the first operation record as the interval start point and the second sequence number of the target operation record as the interval end point. The first receiving module 5531 is further configured to receive a message gap synchronization request, which includes the gap interval. The message gap synchronization request is sent when a message gap is detected in the synchronized session messages. The first sending module 5534 is further configured to respond to the message gap synchronization request by returning the operation record corresponding to the target sequence number between the first sequence number and the second sequence number, based on the gap interval. The operation record corresponding to the target sequence number is used to synchronize the session messages missing in the message gap.
[0190] Applying the above embodiments of this application, when synchronizing session messages based on multiple operation records corresponding to a session message, if it is determined that the fast-forward synchronization condition is met based on multiple second operation records following the currently synchronized first operation record, a target operation record separated from the first operation record by at least one second operation record can be determined from the multiple second operation records. The target operation record and the second operation records following the target operation record are then sent to synchronize the session message based on the target operation record and the received second operation record. This allows for synchronization of session messages without continuing from the synchronized first operation record, instead fast-forwarding from the first operation record to the target operation record (sequentially following the first operation record) separated from the first operation record, and continuing synchronization based on the target operation record and the second operation records following it. This reduces the amount of data transmitted for operation records, facilitating network transmission, and also improves the synchronization efficiency of session messages, reducing the time spent synchronizing session messages to the latest message, thus improving the user experience.
[0191] The following continues to describe the session message processing apparatus provided in the embodiments of this application. The session message processing apparatus provided in the embodiments of this application includes: a second sending module, configured to send a synchronization request for a session message targeting a target object, the target object being associated with multiple operation records arranged in the order of their generation; wherein, each operation record is generated by recording the content of a change operation when a change operation is performed on the session message, and the synchronization of the session message is achieved by synchronizing the multiple operation records in the order of their arrangement; the synchronization request is used to indicate that the session message has been synchronized to a first operation record among the multiple operation records; a second receiving module, configured to receive a target operation record returned based on the synchronization request, and a second operation record arranged after the target operation record; wherein, the target operation record is determined from the multiple second operation records when a fast-forward synchronization condition is satisfied based on the multiple second operation records arranged after the first operation record, and the target operation record is separated from the first operation record by at least one second operation record; and a synchronization module, configured to synchronize the session message based on the target operation record and the received second operation record.
[0192] In some embodiments, the synchronization module is further configured to use the target operation record and the received second operation record as message operation records, and determine the target session message corresponding to each message operation record; when there are multiple target session messages, for each target session message, the message operation records corresponding to the target session message are merged, and the merged result is used as the final state of the target session message, so as to synchronize the session messages.
[0193] In some embodiments, the change operation includes: a message addition operation; the synchronization module is further configured to determine whether the message operation record corresponding to the target session message contains an operation record corresponding to the message addition operation; when it is determined that the operation record contains the message addition operation, the merged result is used as the final state of the target session message; the synchronization module is further configured to store the merged result when it is determined that the operation record does not contain the message addition operation.
[0194] In some embodiments, the synchronization module is further configured to delete the target operation record and the received second operation record.
[0195] In some embodiments, the synchronization module is further configured to detect message synchronization status during the process of synchronizing the session messages based on the target operation record and the received second operation record; when the message synchronization status indicates that the session messages have a synchronization abnormality, the synchronized session messages are deleted during the process; the second sending module is further configured to resend the synchronization request for the session messages for the target object.
[0196] Applying the above embodiments of this application, after sending a synchronization request for a session message targeting a target object, a target operation record returned based on the synchronization request and a second operation record arranged after the target operation record are received. This allows for synchronization of session messages based on the target operation record and the received second operation record. The target operation record is a second operation record determined from among multiple second operation records that is at least one second operation record away from the first operation record, provided that the fast-forward synchronization condition is met based on multiple second operation records following the currently synchronized first operation record. In this way, session message synchronization can proceed without continuing from the already synchronized first operation record. Instead, it can fast-forward from the first operation record to the target operation record (arranged after the first operation record) that is at least one second operation record away from the first operation record, and continue synchronization based on the target operation record and the second operation record arranged after it. This reduces the amount of data transmitted and the download time of operation records, improves the synchronization efficiency of session messages, reduces the time spent synchronizing session messages to the latest message, and improves the user experience.
[0197] This application also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the session message processing method provided in this application.
[0198] This application also provides a computer-readable storage medium storing executable instructions, which, when executed by a processor, will cause the processor to execute the session message processing method provided in this application.
[0199] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or it may be a variety of devices including one or any combination of the above-mentioned memories.
[0200] In some embodiments, executable instructions may take the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a standalone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
[0201] As an example, executable instructions may, but do not necessarily, correspond to files in a file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple collaborating files (e.g., a file that stores one or more modules, subroutines, or code sections).
[0202] As an example, executable instructions can be deployed to execute on a single computing device, or on multiple computing devices located in one location, or on multiple computing devices distributed across multiple locations and interconnected via a communication network.
[0203] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, and improvements made within the spirit and scope of this application are included within the scope of protection of this application.
Claims
1. A method for processing session messages, characterized in that, The method includes: Receive a synchronization request for a session message for a target object, which is associated with multiple operation records arranged in the order of their creation; The operation record is generated by recording the content of the change operation when a change operation is performed on the session message. The synchronization of the session message is achieved by synchronizing the multiple operation records in the order they are arranged. Based on the synchronization request, it is determined that the session message has been synchronized to the first operation record among the multiple operation records, and multiple second operation records arranged after the first operation record are determined; When it is determined that the fast-forward synchronization condition is met based on the plurality of second operation records, a target operation record that is separated from the first operation record by at least one second operation record is determined from the plurality of second operation records. Send the target operation record and a second operation record arranged after the target operation record to synchronize the session message based on the target operation record and the received second operation record.
2. The method as described in claim 1, characterized in that, The operation record has a corresponding sequence number. The step of determining, based on the synchronization request, that the session message has been synchronized to the first operation record among the multiple operation records includes: Parse the synchronization request to obtain the first sequence number included in the synchronization request; The operation record corresponding to the first sequence number is determined to be the first operation record, so as to confirm that the session message has been synchronized to the first operation record among the multiple operation records.
3. The method as described in claim 2, characterized in that, The sequence numbers of the multiple operation records are monotonically increased according to their order of arrangement, and the increment of the monotonically increasing sequence is 1; the method further includes: Determine the target sequence number corresponding to the last operation record among the multiple operation records; When the difference between the target sequence number and the first sequence number reaches the difference threshold, it is determined that the fast forward synchronization condition is satisfied.
4. The method as described in claim 1, characterized in that, The method further includes: Obtain the number of records for the plurality of second operation records; When the number of records reaches the number threshold, it is determined that the fast-forward synchronization condition is met.
5. The method as described in claim 1, characterized in that, The method further includes: Obtain the data size of the multiple second operation records; When the data volume reaches the data volume threshold, it is determined that the fast-forward synchronization condition is met.
6. The method as described in claim 1, characterized in that, The method further includes: Obtain the fast-forward indication information included in the synchronization request. The fast-forward indication information is used to indicate whether the session messages are allowed to be synchronized in a fast-forward synchronization mode. When the fast-forward synchronization condition is satisfied based on the plurality of second operation records, determining the target operation record from the plurality of second operation records that is separated from the first operation record by at least one second operation record includes: When the fast-forward indication information is used to indicate that the session messages are allowed to be synchronized in a fast-forward synchronization mode, and the fast-forward synchronization condition is determined to be met based on the multiple second operation records, then... From the plurality of second operation records, determine the target operation record that is separated from the first operation record by at least one second operation record.
7. The method as described in claim 1, characterized in that, The step of determining the target operation record from the plurality of second operation records that is separated from the first operation record by at least one second operation record includes: The message of the target object is obtained using feature information; Based on the message usage feature information, determine the target number of second operation records that are separated from the first operation record; The second operation record that is separated from the first operation record by a target number among the multiple second operation records is taken as the target operation record.
8. The method as described in claim 1, characterized in that, The step of determining the target operation record from the plurality of second operation records that is separated from the first operation record by at least one second operation record includes: The message of the target object is obtained using feature information; Based on the feature information of the message, a neural network model is invoked to predict the target operation record among the multiple second operation records, and the prediction result is obtained; The second operation record indicated by the prediction result shall be used as the target operation record that is separated from the first operation record by at least one second operation record.
9. The method as described in claim 1, characterized in that, The operation record has a corresponding serial number, and the method further includes: Send a fast-forward notification message to notify that the session messages are synchronized in fast-forward synchronization mode; When the fast-forward notification message is received, a gap interval is constructed with the first sequence number of the first operation record as the interval start point and the second sequence number of the target operation record as the interval end point. The method further includes: Receive message hole synchronization request, the message hole synchronization request includes the hole interval, the message hole synchronization request is sent when a message hole is detected in the synchronized session message; In response to the message gap synchronization request, based on the gap interval, return the operation record corresponding to the target sequence number between the first sequence number and the second sequence number; The operation record corresponding to the target sequence number is used to synchronize the missing session messages in the message gap.
10. A method for processing session messages, characterized in that, The method includes: Send a synchronization request for a session message for a target object, which is associated with multiple operation records arranged in the order of their creation; The operation record is generated by recording the content of the change operation when a change operation is performed on the session message. The synchronization of the session message is achieved by synchronizing the multiple operation records in the order they are arranged. The synchronization request is used to indicate that the session message has been synchronized to the first operation record among the multiple operation records. Receive the target operation record returned based on the synchronization request, and the second operation record arranged after the target operation record; The target operation record is determined from multiple second operation records when the fast forward synchronization condition is satisfied based on multiple second operation records arranged after the first operation record. The target operation record is separated from the first operation record by at least one second operation record. The session messages are synchronized based on the target operation record and the received second operation record.
11. The method as described in claim 10, characterized in that, The synchronization of the session messages based on the target operation record and the received second operation record includes: The target operation record and the received second operation record are used as message operation records, and the target session message corresponding to each message operation record is determined. When there are multiple target session messages, for each target session message, the message operation records corresponding to the target session message are merged, and the merged result is used as the final state of the target session message to synchronize the session messages.
12. The method as described in claim 11, characterized in that, The change operation includes: message addition operation; the step of using the merged result as the final state of the target session message includes: Determine whether the message operation record corresponding to the target session message contains an operation record corresponding to the message addition operation; When an operation record containing a message addition operation is identified, the merged result is used as the final state of the target session message; The method further includes: When it is determined that there are no operation records containing message addition operations, the merged result will be stored.
13. The method as described in claim 10, characterized in that, The method further includes: During the process of synchronizing the session messages based on the target operation record and the received second operation record, the message synchronization status is detected; When the message synchronization status indicates that the session message has a synchronization error, delete the session message synchronized during the process; The method further includes: resending the synchronization request for the session message targeting the target object.
14. A device for processing session messages, characterized in that, The device includes: The first receiving module is used to receive a synchronization request for a session message for a target object, wherein the target object is associated with multiple operation records arranged in the order of their generation. The operation record is generated by recording the content of the change operation when a change operation is performed on the session message. The synchronization of the session message is achieved by synchronizing the multiple operation records in the order they are arranged. The first determining module is used to determine, based on the synchronization request, that the session message has been synchronized to the first operation record among the multiple operation records, and to determine the multiple second operation records arranged after the first operation record; The second determining module is used to determine, when it is determined based on the plurality of second operation records that the fast forward synchronization condition is met, a target operation record that is separated from the first operation record by at least one second operation record from the plurality of second operation records. The first sending module is used to send the target operation record and a second operation record arranged after the target operation record, so as to synchronize the session message based on the target operation record and the received second operation record.
15. A device for processing session messages, characterized in that, The device includes: The second sending module is used to send a synchronization request for a session message to a target object, which is associated with multiple operation records arranged in the order of their generation. The operation record is generated by recording the content of the change operation when a change operation is performed on the session message. The synchronization of the session message is achieved by synchronizing the multiple operation records in the order they are arranged. The synchronization request is used to indicate that the session message has been synchronized to the first operation record among the multiple operation records. The second receiving module is used to receive the target operation record returned based on the synchronization request, and the second operation record arranged after the target operation record; The target operation record is determined from multiple second operation records when the fast forward synchronization condition is satisfied based on multiple second operation records arranged after the first operation record. The target operation record is separated from the first operation record by at least one second operation record. The synchronization module is used to synchronize the session messages based on the target operation record and the received second operation record.
Citation Information
Patent Citations
Data processing method and electronic equipment
CN111007995A
Block chain leap-type and skip-type rapid synchronization method and system
CN111416703A