Real-time session list rendering method and system
By using home page reverse synchronization and asynchronous forward synchronization in the UME2X system, the problems of low session list rendering efficiency and high resource consumption when users log in are solved, and fast rendering of session lists and a better user experience are achieved.
Patent Information
- Application Number
- CN202510053521.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-14
- Publication Date
- 2025-05-16
AI Technical Summary
In the UME2X system, the terminal needs to synchronize the pull of a large number of messages when the user logs in, resulting in a long loading time on the first screen, poor user experience, and the calculation process of the number of unread messages consumes unnecessary CPU resources, increasing the power consumption of the mobile terminal.
The terminal synchronizes the session list through the terminal using the home page reverse synchronization and asynchronous forward synchronization to obtain the session list summary information, including the session ID, the last message ID, the last read message location and the session status. Then, the session information, user information and picture information are obtained through the terminal, the number of unread messages is calculated, and the session list is rendered through the UI.
It reduces the space usage of session list synchronization tasks, reduces the number of network requests, improves the efficiency and accuracy of the calculation of the number of unread messages, reduces resource consumption, and realizes fast rendering of session lists and a better user experience.
Smart Images

Figure CN120017630A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of list rendering, and in particular to a method and system for rendering a real-time conversation list. Background Art
[0002] In the UME2X system, when a user logs in, the UME2X system terminal incrementally pulls the user's historical messages and all unread historical messages in the past 7 days. After the system terminal successfully pulls these messages, it sorts the pulled messages locally on the terminal based on the message time to determine the message order of the first-screen conversation list, and calculates the number of unread messages in each conversation. Finally, it notifies the UI to render and display the first-screen conversation list.
[0003] When a user logs in, the terminal needs to pull a large number of messages simultaneously, causing the first screen to be in a loading state for a long time. Especially in the scenario of mobile soft network, the loading time is long, resulting in a poor user experience, and also causing unnecessary network traffic and power consumption on the mobile terminal. In addition, for the calculation of the number of unread messages, the terminal first pulls all unread messages in the session, and then judges and calculates based on the read status of the messages in the session. This process requires traversing all messages in the session, resulting in unnecessary CPU waste and additional power consumption on the mobile terminal. Summary of the invention
[0004] The present invention provides a method and system for rendering a real-time conversation list, which improves the conversation list rendering efficiency and reduces resource consumption during the conversation list rendering process.
[0005] In order to solve the above technical problems, the present invention provides a method for rendering a real-time conversation list, comprising:
[0006] After the terminal receives the login information of successful login, the terminal uses the homepage reverse synchronization and asynchronous forward synchronization to complete the synchronization of the session list, and obtains the session list summary information; wherein the session list summary information includes the session ID, the last message ID, the last read message position and the session status;
[0007] According to the session ID, obtain session information, user information and picture information from the terminal or the server;
[0008] Increment the number of unread messages in the conversation list and obtain the latest message position through the terminal;
[0009] Subtract the last read message position from the latest message position to get the number of unread messages;
[0010] Load the last message according to the last message ID, obtain preview information, parse the session according to the session status, and obtain the session status identifier;
[0011] The conversation list is rendered through the UI according to the conversation information, user information, picture information, number of unread messages, preview information and conversation status identifier.
[0012] The present invention pulls a complete changed conversation list by means of reverse synchronization of the home page and asynchronous forward synchronization completion, thereby reducing the space occupied by the conversation list synchronization task; obtains conversation information, user information and picture information from a terminal or a server, thereby reducing network requests as much as possible; performs message self-increment and calculation of the number of unread messages through the terminal, thereby ensuring the calculation accuracy of the number of unread messages in the conversation list, improving the calculation efficiency of the number of unread messages, and reducing the terminal CPU calculation amount; uses a UI to render the conversation information, user information, picture information, the number of unread messages, preview information and conversation identifier, thereby completing the rapid rendering of the conversation list, thereby reducing resource consumption during the conversation list rendering process.
[0013] Further, the receiving of login information through the terminal, after the terminal receives the login information of successful login, the synchronization of the session list is performed through the terminal using the homepage reverse synchronization and asynchronous forward synchronization completion method to obtain the session list summary information, including:
[0014] Real-time monitoring and receiving of login information through the terminal, after the terminal receives the login information of successful login, the terminal obtains the latest changed session list from the server;
[0015] According to the latest changed session list, the homepage session list reverse synchronization task is executed through the terminal, and the session messages are pulled starting from the latest session message to obtain the first session message number of the homepage session list reverse synchronization and the first unsynchronized session message in the latest changed session list; wherein the first session number does not exceed a preset positive integer N;
[0016] According to the comparison result of the first unsynchronized session message, the first session message number and the preset positive integer N, and the latest synchronization version number at the historical moment, an asynchronous task of forward synchronization of the latest changed session list is executed through the terminal, and session list summary information is obtained; wherein the session list summary information includes a session ID, a last message ID, a last read message position, and a session status.
[0017] Further, the asynchronous task of forward synchronization of the latest changed session list is executed by the terminal according to the comparison result of the first unsynchronized session message, the first session message number and a preset positive integer N, and the latest synchronization version number at a historical moment, and the session list summary information is obtained, including:
[0018] If the number of the first session messages is less than a preset positive integer N, the session list summary information is stored and outputted through the terminal, and the latest synchronization version number of the historical moment is updated to obtain the latest synchronization version number of the current moment;
[0019] If the first number of session messages is equal to a preset positive integer N, an asynchronous task of forward synchronization of the latest changed session list is executed through the terminal, and session messages are incrementally pulled starting from the session message corresponding to the latest synchronization version number at the historical moment until the first unsynchronized session message is completely pulled, and session list summary information is stored and output through the terminal, and the latest synchronization version number at the historical moment is updated to obtain the latest synchronization version number at the current moment.
[0020] The present invention quickly displays the latest conversation message data by executing the reverse synchronization task of the home page, and completes the latest changed conversation list by executing the asynchronous task of the forward synchronization. This asynchronous processing method can ensure that the main thread of the reverse synchronization is not blocked, improve the user experience, and ensure the integrity and real-time performance of the data in the conversation list; the "main line task of the reverse synchronization + the asynchronous task of the forward synchronization completion" method is used to achieve complete pulling of the changed conversation list, and only a small amount of data needs to be queried to build the complete conversation list, achieving fast rendering within seconds, improving the efficiency of synchronous pulling of the latest changed conversation list, and avoiding unreasonable occupation and blockage of the network.
[0021] Furthermore, obtaining session information, user information and picture information from a terminal or a server according to the session ID includes:
[0022] According to the session ID, obtain the second session information corresponding to the session ID from the terminal; if the second session information does not exist in the terminal, obtain the second session information from the instant messaging service of the server, and store the second session information in the terminal; wherein the second session information includes a plurality of sub-session information;
[0023] According to the session ID, determine the session type of the second session information; if the session type of the second session information is a single chat session, obtain user information of the second session information from the terminal; if the user information of the second session information does not exist in the terminal, obtain the user information of the second session information from the user center service of the server, and store the user information of the second session information in the terminal;
[0024] According to the second session information and the user information of the second session information, the picture information of the second session information is obtained from the terminal; if the picture information of the second session information does not exist in the terminal, the picture information of the second session information is obtained from the network disk of the server, and the picture information of the second session information is stored in the terminal.
[0025] The present invention preferentially obtains session information, user information and picture information associated with a session ID from a terminal based on the session list summary information. If the terminal cannot provide relevant information, relevant information is obtained from a server. This can improve the efficiency of obtaining relevant information from the session list and effectively save network traffic consumption and power consumption on a mobile terminal.
[0026] Furthermore, the step of automatically increasing the number of unread messages in the conversation list and obtaining the latest message position through the terminal includes:
[0027] Sending a first request instruction carrying a session ID to the access gateway through the terminal;
[0028] According to the session ID, a second request instruction for obtaining the latest message location is sent to the IM server through the access gateway, and a plurality of sub-session information corresponding to the session ID is transmitted to the plurality of IM services of the IM server respectively by using a consistent hash algorithm;
[0029] After receiving the second request instruction, the IM server obtains the latest message location from the MySQL database through the IM server, and returns the latest message location to the terminal;
[0030] After the terminal receives the latest message position, the unread messages in the conversation list are automatically incremented by the terminal.
[0031] The present invention uses a consistent hashing algorithm to route multiple sub-session information to multiple IM services based on session IDs through data exchanges between terminals, access gateways and IM servers, so that the same sub-session information can be transmitted to the same IM service, thereby ensuring the accuracy of the acquired information and guaranteeing the continuous increase of the position of unread messages in the session list.
[0032] Further, the loading of the last message according to the last message ID, obtaining preview information, performing state analysis on the session according to the session state, and obtaining the session state identifier includes:
[0033] Load the last message according to the last message ID, obtain and load the last message from the local through the terminal, and obtain preview information; if the last message does not exist locally, obtain the last message from the server in batches through the terminal, load the last message, and obtain preview information;
[0034] The session is parsed according to the session state to obtain a session state identifier; wherein the session state is represented by an Int type field, the Int type field includes a plurality of bits, and each bit represents a different session state identifier.
[0035] The present invention gives priority to obtaining preview information from the terminal, which can improve the efficiency of obtaining preview information and reduce traffic consumption; uses an Int type field to represent the session state, which can quickly parse the session state, thereby achieving fast rendering and display, and improving the efficiency of session list rendering.
[0036] Based on the above method embodiment, the present invention provides a corresponding system embodiment, which provides a real-time conversation list rendering system, including: a list synchronization module, an information acquisition module, a message auto-increment module, an unread message module, a conversation parsing module and a list rendering module;
[0037] The list synchronization module is to synchronize the conversation list by using the homepage reverse synchronization and asynchronous forward synchronization completion method after the terminal receives the login information of successful login, and obtain the conversation list summary information; wherein the conversation list summary information includes the conversation ID, the last message ID, the last read message position and the conversation status;
[0038] The information acquisition module is to acquire session information, user information and picture information from the terminal or the server according to the session ID;
[0039] The message auto-increment module is used to auto-increment the number of unread messages in the conversation list and obtain the latest message position through the terminal;
[0040] The unread message module is to obtain the number of unread messages by subtracting the last read message position from the latest message position;
[0041] The session analysis module is to load the last message according to the last message ID, obtain preview information, perform session status analysis on the session according to the session status, and obtain the session status identifier;
[0042] The list rendering module is to render the conversation list through the UI according to the conversation information, user information, picture information, number of unread messages, preview information and conversation status identifier.
[0043] Further, the list synchronization module includes: a change information unit, a reverse synchronization unit and a forward synchronization unit;
[0044] The change information unit is used to monitor and receive login information in real time through the terminal, and after the terminal receives the login information of successful login, obtain the latest change session list from the server through the terminal;
[0045] The reverse synchronization unit is used to perform a reverse synchronization task of the homepage session list through the terminal according to the latest changed session list, pull session messages starting from the latest session message, and obtain the first number of session messages reversely synchronized with the homepage session list and the first unsynchronized session message in the latest changed session list; wherein the first number of sessions does not exceed a preset positive integer N;
[0046] The forward synchronization unit is used to execute the asynchronous task of forward synchronization of the latest changed session list through the terminal according to the comparison result of the first unsynchronized session message, the first session message number and the preset positive integer N, and the latest synchronization version number at the historical moment, and obtain the session list summary information; wherein the session list summary information includes the session ID, the last message ID, the last read message position and the session status.
[0047] Further, the forward synchronization unit comprises: a first forward synchronization subunit and a second forward synchronization subunit;
[0048] The first forward synchronization subunit is used to store and output the summary information of the session list through the terminal if the number of the first session messages is less than a preset positive integer N, and to update the latest synchronization version number at the historical moment to obtain the latest synchronization version number at the current moment;
[0049] The second forward synchronization subunit is used to execute the asynchronous task of forward synchronization of the latest changed session list through the terminal if the number of the first session messages is equal to a preset positive integer N, incrementally pull the session messages starting from the session message corresponding to the latest synchronization version number at the historical moment until the first unsynchronized session message is completely pulled, store and output the session list summary information through the terminal, and update the latest synchronization version number at the historical moment to obtain the latest synchronization version number at the current moment.
[0050] Further, the information acquisition module includes: a session information unit, a user information unit and a picture information unit;
[0051] The session information unit is used to obtain the second session information corresponding to the session ID from the terminal according to the session ID; if the second session information does not exist in the terminal, obtain the second session information from the instant messaging service of the server, and store the second session information in the terminal; wherein the second session information includes a plurality of sub-session information;
[0052] The user information unit is used to determine the session type of the second session information according to the session ID; if the session type of the second session information is a single chat session, obtain the user information of the second session information from the terminal; if the user information of the second session information does not exist in the terminal, obtain the user information of the second session information from the user center service of the server, and store the user information of the second session information in the terminal;
[0053] The picture information unit is used to obtain the picture information of the second session information from the terminal according to the second session information and the user information of the second session information; if the picture information of the second session information does not exist in the terminal, obtain the picture information of the second session information from the network disk of the server, and store the picture information of the second session information in the terminal.
[0054] Further, the message self-increment module includes: a first request instruction unit, a consistent hash unit, a second request instruction unit and an unread message self-increment unit;
[0055] The first request instruction unit is used to send a first request instruction carrying a session ID to the access gateway through the terminal;
[0056] The consistent hashing unit is used to send a second request instruction for obtaining the latest message location to the IM server through the access gateway according to the session ID, and use a consistent hashing algorithm to transmit multiple sub-session information corresponding to the session ID to multiple IM services of the IM server respectively;
[0057] The second request instruction unit is used to obtain the latest message location from the MySQL database through the IM server after the IM server receives the second request instruction, and return the latest message location to the terminal;
[0058] The unread message self-increment unit is used to self-increment the unread messages in the conversation list through the terminal after the terminal receives the latest message position.
[0059] Further, the session analysis module includes a preview information unit and a status analysis unit;
[0060] The preview information unit is used to load the last message according to the last message ID, obtain and load the last message from the local through the terminal, and obtain preview information; if the last message does not exist locally, the last message is obtained from the server in batches through the terminal, and the last message is loaded to obtain preview information.
[0061] The state analysis unit is used to perform state analysis on the session according to the session state to obtain a session state identifier; wherein the session state is represented by an Int type field, the Int type field includes a plurality of bits, and each bit represents a different session state identifier. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] Figure 1 : A flowchart of an embodiment of a method for rendering a real-time conversation list provided by the present invention;
[0063] Figure 2 : A schematic diagram of an embodiment of the session list synchronization strategy provided by the present invention;
[0064] Figure 3 : A schematic diagram of an embodiment of a strategy for obtaining session information change provided by the present invention;
[0065] Figure 4 : A flowchart of an embodiment of obtaining a conversation message location provided by the present invention;
[0066] Figure 5 : A structural diagram of an embodiment of an Int type session state field provided by the present invention;
[0067] Figure 6 : A structural diagram of an embodiment of a rendering system for a real-time session list provided by the present invention. DETAILED DESCRIPTION
[0068] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0069] In the description of the present application, it should be understood that the terms "first", "second" and "third" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first", "second" and "third" may explicitly or implicitly include one or more of the features. In the description of the present application, unless otherwise specified, "several" means two or more.
[0070] The present invention provides a method and system for rendering a real-time conversation list, which improves the conversation list rendering efficiency and reduces resource consumption during the conversation list rendering process.
[0071] Example 1
[0072] Based on the above requirements, an embodiment of the present invention provides a method for rendering a real-time conversation list. The method flow is as follows: Figure 1 As shown, the method includes steps S1 to S6, and each step is specifically as follows:
[0073] S1. After the terminal receives the login information of successful login, the terminal uses the homepage reverse synchronization and asynchronous forward synchronization to complete the synchronization of the session list, and obtains the session list summary information; wherein the session list summary information includes the session ID, the last message ID, the last read message position and the session status. The schematic diagram of the session list synchronization strategy in this step is as follows Figure 2 As shown, step S1 includes step S1.1 to step S1.3, and each step is specifically as follows:
[0074] S1.1. Real-time monitoring and receiving of login information is performed through the terminal. After the terminal receives the login information of successful login, the terminal obtains the latest changed session list from the server.
[0075] In this embodiment, when the user logs in and enters the home page, the terminal monitors and receives login information in real time. After the terminal receives the login information of successful login, the terminal sends a request to the server to obtain the latest changed session list from the server.
[0076] S1.2. According to the latest changed session list, the terminal executes the reverse synchronization task of the homepage session list, pulls the session messages starting from the latest session message, obtains the first session message number of the homepage session list reversely synchronized and the first unsynchronized session message in the latest changed session list; wherein, the first session number does not exceed a preset positive integer N.
[0077] According to the latest changed session list, the synchronous pulling action of the session list is triggered through the terminal, the reverse synchronization task of the homepage session list is first executed, the session messages are pulled starting from the latest session message, the number of session messages of the reverse synchronization of the homepage session list is obtained, recorded as the first number of session messages, and the session messages in the latest changed session list after the reverse synchronization of the homepage session list that have not been synchronously pulled are obtained, recorded as the first unsynchronized session messages. The first number of sessions does not exceed the preset positive integer N, and the positive integer N in this embodiment is set to 30.
[0078] Through step S1.2, the terminal only synchronizes the latest session message, but does not completely pull all the changed session lists after the last session list synchronization.
[0079] S1.3, according to the comparison result of the first unsynchronized session message, the first session message number and the preset positive integer N, and the latest synchronization version number at the historical moment, the terminal executes the asynchronous task of the latest changed session list forward synchronization, and obtains the session list summary information; wherein the session list summary information includes the session ID, the last message ID, the last read message position and the session status. This step includes steps S1.3.1 to S1.3.2, and each step is as follows:
[0080] S1.3.1. If the number of the first session messages is less than a preset positive integer N, the terminal stores and outputs the session list summary information, and updates the latest synchronization version number at the historical moment to obtain the latest synchronization version number at the current moment.
[0081] If the number of the first conversation messages is less than the preset positive integer N, that is, the number of the first conversation messages in the present embodiment is less than 30, it means that by executing the reverse synchronization task of the homepage conversation list, all the conversation messages in the latest changed conversation list have been completely pulled, the synchronization of the homepage conversation list has been completed, the conversation list summary information is stored and output through the terminal, and the latest synchronization version number at the historical moment is updated to obtain the latest synchronization version number at the current moment.
[0082] S1.3.2. If the number of the first session messages is equal to a preset positive integer N, the terminal executes an asynchronous task of forward synchronization of the latest changed session list, and incrementally pulls session messages starting from the session message corresponding to the latest synchronization version number at the historical moment until the first unsynchronized session message is completely pulled. The terminal stores and outputs the session list summary information, and updates the latest synchronization version number at the historical moment to obtain the latest synchronization version number at the current moment.
[0083] If the first number of session messages is equal to a preset positive integer N, that is, the first number of session messages in this embodiment is equal to 30, it means that after completing the reverse synchronization task of the home page session list, there are still session messages in the latest changed session list that have not been synchronously pulled, and the number of first unsynchronized session messages is greater than zero. At this time, the terminal also needs to execute the asynchronous task of forward synchronization of the latest changed session list.
[0084] First, incrementally pull session messages from the session message corresponding to the latest synchronization version number (min) at the historical moment until the first unsynchronized session message is completely pulled, so that the latest changed session list is completely synchronized, and the completely pulled synchronization session message is stored in the terminal, thereby ensuring the integrity and accuracy of the synchronized session list. Then, the session list summary information is stored and output through the terminal. Finally, the latest synchronization version number at the historical moment is updated to obtain the latest synchronization version number (max) at the current moment.
[0085] S2. According to the session ID, the session information, user information and picture information are obtained from the terminal or the server. The schematic diagram of changing the acquisition strategy of the session information in this step is as follows: Figure 3 As shown, step S2 includes step S2.1 to step S2.3, and each step is specifically as follows:
[0086] S2.1. According to the session ID, obtain the second session information corresponding to the session ID from the terminal; if the second session information does not exist in the terminal, obtain the second session information from the instant messaging service of the server, and store the second session information in the terminal; wherein the second session information includes multiple sub-session information.
[0087] For the change session information, it is preferred to obtain it from the terminal locally. If the corresponding change session information does not exist in the terminal, it is obtained from the server on demand. Since the terminal has the relevant information of the change session information in most scenarios, the terminal does not have the change session information in the scenario of loading the session for the first time. Therefore, according to the change session information acquisition strategy, it is obtained "on demand" to reduce network requests as much as possible and improve the efficiency of information acquisition.
[0088] In this embodiment, based on the session ID carried in the session list summary information, the terminal performs session location on the session ID, and preferentially obtains the relevant changed session information from the terminal locally to obtain the second session information corresponding to the session ID. If the terminal does not have the second session information locally, the second session information is obtained in real time from the instant messaging service of the server as needed, and is stored locally in the terminal. The second session information includes multiple sub-session information.
[0089] S2.2. Determine the session type of the second session information according to the session ID; if the session type of the second session information is a single chat session, obtain user information of the second session information from the terminal; if the user information of the second session information does not exist in the terminal, obtain the user information of the second session information from the user center service of the server, and store the user information of the second session information in the terminal.
[0090] In this embodiment, the terminal first determines the session type of the second session information corresponding to the session ID. If the session type is a single chat session, the user information of the second session information is obtained from the terminal locally. If the user information of the second session information does not exist in the terminal locally, the user information of the second session information is obtained from the user center of the server in real time as needed and stored in the terminal locally.
[0091] S2.3. According to the second session information and the user information of the second session information, obtain the picture information of the second session information from the terminal; if the picture information of the second session information does not exist in the terminal, obtain the picture information of the second session information from the network disk of the server, and store the picture information of the second session information in the terminal.
[0092] After obtaining the second session information and its user information, the terminal also needs to extract the picture information such as the avatar and picture ID corresponding to the second session information. This embodiment preferentially obtains the picture information of the second session information from the terminal locally. If the picture information of the second session information does not exist locally in the terminal, the picture information is loaded from the server's network disk service in real time as needed and stored locally in the terminal.
[0093] S3, the terminal automatically increments the number of unread messages in the conversation list and obtains the latest message position. The process of obtaining the conversation message position in this step is as follows: Figure 4 As shown, step S3 includes step S3.1 to step S3.4, and each step is specifically as follows:
[0094] S3.1. Send a first request instruction carrying a session ID to the access gateway through the terminal.
[0095] S3.2. According to the session ID, a second request instruction for obtaining the latest message location is sent to the IM server through the access gateway, and a consistent hash algorithm is used to transmit multiple sub-session information corresponding to the session ID to multiple IM services of the IM server respectively.
[0096] Based on the session ID carried in the first request instruction, the access gateway sends a second request instruction to the IM server to obtain the latest message location, and uses a consistent hash algorithm to route multiple sub-session information corresponding to the session ID to specific IM services respectively, to ensure that the same sub-session information can be routed to the same IM service for processing, thereby ensuring the accuracy of the obtained information.
[0097] S3.3. After receiving the second request instruction, the IM server obtains the latest message location from the MySQL database through the IM server, and returns the latest message location to the terminal.
[0098] After receiving the second request instruction, the IM server first obtains the latest message position corresponding to the session ID from the memory space of the secondary cache. If it cannot be obtained from the memory space, it obtains the latest message position Position from the MySQL database and returns the latest message position to the terminal.
[0099] S3.4. After the terminal receives the latest message position, the terminal automatically increments the number of unread messages in the conversation list.
[0100] After the terminal receives the latest message location, the terminal continuously increments the number of unread messages in the conversation list. This continuous increment method allows the conversation message location to be quickly obtained in high-concurrency scenarios.
[0101] S4. Subtract the last read message position from the latest message position to obtain the number of unread messages.
[0102] The continuous increment of the conversation message position is achieved through step S3, which can ensure the accuracy of the calculation of the number of unread messages. According to the latest message position (LastMsgPos) and the last read message position (LastReadMsgPos) carried in the conversation list summary information, the number of unread messages is quickly calculated through LastMsgPos-LastReadMsgPos.
[0103] In certain business scenarios, special message types (such as group application messages, group withdrawal messages, etc.) are not counted in the number of unread messages, and the session message position is not increased. Each message type has a unique message type number. The terminal and the server agree on a set of numbering specifications. The server sends a message based on the message, identifies the corresponding message type, and performs specific logical processing.
[0104] Through step S4, for the read conversation messages, the terminal only needs to report the last read conversation message ID and its message location information, without modifying the status of unread messages, thereby realizing fast calculation of the number of read and unread messages of lightweight and fast conversation messages.
[0105] S5. Load the last message according to the last message ID, obtain preview information, perform session status analysis according to the session status, and obtain the session status identifier. This step includes steps S5.1 to S5.2, and each step is as follows:
[0106] S5.1. Load the last message according to the last message ID, obtain and load the last message from the local through the terminal, and obtain preview information; if the last message does not exist locally, obtain the last message from the server in batches through the terminal, load the last message, and obtain preview information.
[0107] S5.2. Perform state analysis on the session according to the session state to obtain a session state identifier; wherein the session state is represented by an Int type field, the Int type field includes a plurality of bits, and each bit represents a different session state identifier.
[0108] This embodiment uses an Int type field to represent the session status carried in the session list summary information. The Int type field used includes multiple bits, each bit identifies a different session status identifier. The Int type session status field is as follows: Figure 5 According to the session status, the terminal parses the session status and obtains the session status identifier
[0109] S6. Rendering a conversation list through a UI according to the conversation information, user information, picture information, number of unread messages, preview information, and conversation status identifier.
[0110] Through steps S1 to S5, this embodiment successfully obtains the rendering conditions of the entire conversation list, and renders the conversation list through the UI according to the conversation information, user information, picture information, number of unread messages, preview information and conversation status identifier.
[0111] The implementation of the above embodiments of the present invention has the following beneficial effects:
[0112] The present invention provides a method for rendering a real-time conversation list, which quickly displays the latest conversation message data by executing a reverse synchronization task on the home page, and completes the latest changed conversation list by executing an asynchronous task of forward synchronization. This asynchronous processing method can ensure that the main thread of the reverse synchronization is not blocked, improve the user experience, and ensure the integrity and real-time nature of the data in the conversation list; the method of "main line task of reverse synchronization + asynchronous task of forward synchronization completion" is used to achieve complete pulling of the changed conversation list, and only a small amount of data needs to be queried to build the complete conversation list, thereby achieving fast rendering within seconds, improving the efficiency of synchronous pulling of the latest changed conversation list, and avoiding unreasonable occupation and congestion of the network.
[0113] Example 2
[0114] Based on the content of the above embodiments, an embodiment of the present invention provides a real-time conversation list rendering system, including: a list synchronization module 101, an information acquisition module 102, a message auto-increment module 103, an unread message module 104, a conversation parsing module 105 and a list rendering module 106. The system structure is as follows Figure 6 shown.
[0115] The list synchronization module 101 is to synchronize the conversation list by using the homepage reverse synchronization and asynchronous forward synchronization completion method after the terminal receives the login information of successful login, and obtain the conversation list summary information; wherein the conversation list summary information includes the conversation ID, the last message ID, the last read message position and the conversation status;
[0116] The information acquisition module 102 is to acquire session information, user information and picture information from the terminal or the server according to the session ID;
[0117] The message auto-increment module 103 is used to auto-increment the unread messages in the conversation list and obtain the latest message position through the terminal;
[0118] The unread message module 104 is to obtain the number of unread messages by subtracting the last read message position from the latest message position;
[0119] The session analysis module 105 is to load the last message according to the last message ID, obtain preview information, perform session status analysis on the session according to the session status, and obtain the session status identifier;
[0120] The list rendering module 106 is used to render the conversation list through the UI according to the conversation information, user information, picture information, number of unread messages, preview information and conversation status identifier.
[0121] Further, the list synchronization module 101 includes: a change information unit 201, a reverse synchronization unit 202 and a forward synchronization unit 203;
[0122] The change information unit 201 is used to monitor and receive login information in real time through the terminal, and after the terminal receives the login information of successful login, obtain the latest changed session list from the server through the terminal;
[0123] The reverse synchronization unit 202 is used to perform the reverse synchronization task of the homepage session list through the terminal according to the latest changed session list, pull the session message starting from the latest session message, and obtain the first session message number of the homepage session list reverse synchronization and the first unsynchronized session message in the latest changed session list; wherein the first session number does not exceed a preset positive integer N;
[0124] The forward synchronization unit 203 is used to perform an asynchronous task of forward synchronization of the latest changed session list through the terminal according to the comparison result of the first unsynchronized session message, the first session message number and a preset positive integer N, and the latest synchronization version number at a historical moment, and obtain session list summary information; wherein the session list summary information includes a session ID, a last message ID, a last read message position, and a session status.
[0125] Further, the forward synchronization unit 203 includes: a first forward synchronization subunit 301 and a second forward synchronization subunit 302;
[0126] The first forward synchronization subunit 301 is used to store and output the summary information of the session list through the terminal if the number of the first session messages is less than a preset positive integer N, and to update the latest synchronization version number at the historical moment to obtain the latest synchronization version number at the current moment;
[0127] The second forward synchronization subunit 302 is used to execute the asynchronous task of forward synchronization of the latest changed session list through the terminal if the number of the first session messages is equal to a preset positive integer N, incrementally pull the session messages starting from the session message corresponding to the latest synchronization version number at the historical moment until the first unsynchronized session message is completely pulled, store and output the session list summary information through the terminal, and update the latest synchronization version number at the historical moment to obtain the latest synchronization version number at the current moment.
[0128] Furthermore, the information acquisition module 102 includes: a session information unit 401, a user information unit 402 and a picture information unit 403;
[0129] The session information unit 401 is used to obtain the second session information corresponding to the session ID from the terminal according to the session ID; if the second session information does not exist in the terminal, obtain the second session information from the instant messaging service of the server, and store the second session information in the terminal; wherein the second session information includes a plurality of sub-session information;
[0130] The user information unit 402 is used to determine the session type of the second session information according to the session ID; if the session type of the second session information is a single chat session, obtain the user information of the second session information from the terminal; if the user information of the second session information does not exist in the terminal, obtain the user information of the second session information from the user center service of the server, and store the user information of the second session information in the terminal;
[0131] The picture information unit 403 is used to obtain the picture information of the second session information from the terminal according to the second session information and the user information of the second session information; if the picture information of the second session information does not exist in the terminal, obtain the picture information of the second session information from the network disk of the server, and store the picture information of the second session information in the terminal.
[0132] Furthermore, the message self-increment module 103 includes: a first request instruction unit 501, a consistent hash unit 502, a second request instruction unit 503 and an unread message self-increment unit 504;
[0133] The first request instruction unit 501 is used to send a first request instruction carrying a session ID to the access gateway through the terminal;
[0134] The consistent hashing unit 502 is used to send a second request instruction for obtaining the latest message location to the IM server through the access gateway according to the session ID, and use a consistent hashing algorithm to transmit multiple sub-session information corresponding to the session ID to multiple IM services of the IM server respectively;
[0135] The second request instruction unit 503 is used to obtain the latest message location from the MySQL database through the IM server after the IM server receives the second request instruction, and return the latest message location to the terminal;
[0136] The unread message self-increment unit 504 is used to self-increment the unread messages in the conversation list through the terminal after the terminal receives the latest message position.
[0137] Further, the session analysis module 105 includes a preview information unit 601 and a state analysis unit 602;
[0138] The preview information unit 601 is used to load the last message according to the last message ID, obtain and load the last message from the local through the terminal, and obtain preview information; if the last message does not exist locally, the last message is obtained from the server in batches through the terminal, and the last message is loaded to obtain preview information.
[0139] The state parsing unit 602 is used to perform state parsing on the session according to the session state to obtain a session state identifier; wherein the session state is represented by an Int type field, the Int type field includes a plurality of bits, and each bit represents a different session state identifier.
[0140] The more detailed working principle and step flow of this embodiment can refer to, but are not limited to, the relevant records of Embodiment 1.
[0141] The implementation of the above embodiments of the present invention has the following beneficial effects:
[0142] A real-time conversation list rendering system provided by the present invention improves the conversation list rendering efficiency and reduces resource consumption during the conversation list rendering process.
[0143] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A method for rendering a real-time conversation list, characterized in that: include: After the terminal receives the login information of successful login, the terminal uses the homepage reverse synchronization and asynchronous forward synchronization to complete the synchronization of the session list, and obtains the session list summary information; wherein the session list summary information includes the session ID, the last message ID, the last read message position and the session status; According to the session ID, obtain session information, user information and picture information from the terminal or the server; Increment the number of unread messages in the conversation list and obtain the latest message position through the terminal; Subtract the last read message position from the latest message position to get the number of unread messages; Load the last message according to the last message ID, obtain preview information, parse the session according to the session status, and obtain the session status identifier; The conversation list is rendered through the UI according to the conversation information, user information, picture information, number of unread messages, preview information and conversation status identifier.
2. A method for rendering a real-time conversation list according to claim 1, characterized in that: The receiving of login information through the terminal, after the terminal receives the login information of successful login, synchronizes the session list through the terminal using the homepage reverse synchronization and asynchronous forward synchronization completion method to obtain the session list summary information, including: Real-time monitoring and receiving of login information through the terminal, after the terminal receives the login information of successful login, the terminal obtains the latest changed session list from the server; According to the latest changed session list, the homepage session list reverse synchronization task is executed through the terminal, and the session messages are pulled starting from the latest session message to obtain the first session message number of the homepage session list reverse synchronization and the first unsynchronized session message in the latest changed session list; wherein the first session number does not exceed a preset positive integer N; According to the comparison result of the first unsynchronized session message, the first session message number and the preset positive integer N, and the latest synchronization version number at the historical moment, an asynchronous task of forward synchronization of the latest changed session list is executed through the terminal, and session list summary information is obtained; wherein the session list summary information includes a session ID, a last message ID, a last read message position, and a session status.
3. A method for rendering a real-time conversation list according to claim 2, characterized in that: The step of performing the asynchronous task of forward synchronization of the latest changed session list through the terminal according to the comparison result of the first unsynchronized session message, the first session message number and the preset positive integer N, and the latest synchronization version number at the historical moment, and obtaining the session list summary information includes: If the number of the first session messages is less than a preset positive integer N, the session list summary information is stored and outputted through the terminal, and the latest synchronization version number of the historical moment is updated to obtain the latest synchronization version number of the current moment; If the first number of session messages is equal to a preset positive integer N, an asynchronous task of forward synchronization of the latest changed session list is executed through the terminal, and session messages are incrementally pulled starting from the session message corresponding to the latest synchronization version number at the historical moment until the first unsynchronized session message is completely pulled, and session list summary information is stored and output through the terminal, and the latest synchronization version number at the historical moment is updated to obtain the latest synchronization version number at the current moment.
4. A method for rendering a real-time conversation list according to claim 1, characterized in that: The acquiring of session information, user information and picture information from a terminal or a server according to the session ID includes: According to the session ID, obtain the second session information corresponding to the session ID from the terminal; if the second session information does not exist in the terminal, obtain the second session information from the instant messaging service of the server, and store the second session information in the terminal; wherein the second session information includes a plurality of sub-session information; According to the session ID, determine the session type of the second session information; if the session type of the second session information is a single chat session, obtain user information of the second session information from the terminal; if the user information of the second session information does not exist in the terminal, obtain the user information of the second session information from the user center service of the server, and store the user information of the second session information in the terminal; According to the second session information and the user information of the second session information, the picture information of the second session information is obtained from the terminal; if the picture information of the second session information does not exist in the terminal, the picture information of the second session information is obtained from the network disk of the server, and the picture information of the second session information is stored in the terminal.
5. A method for rendering a real-time conversation list according to claim 1, characterized in that: The method of automatically increasing the number of unread messages in the conversation list and obtaining the latest message position through the terminal includes: Sending a first request instruction carrying a session ID to the access gateway through the terminal; According to the session ID, a second request instruction for obtaining the latest message location is sent to the IM server through the access gateway, and a plurality of sub-session information corresponding to the session ID is transmitted to the plurality of IM services of the IM server respectively by using a consistent hash algorithm; After receiving the second request instruction, the IM server obtains the latest message location from the MySQL database through the IM server, and returns the latest message location to the terminal; After the terminal receives the latest message position, the unread messages in the conversation list are automatically incremented by the terminal.
6. A real-time conversation list rendering system, characterized in that: include: List synchronization module, information acquisition module, message auto-increment module, unread message module, session parsing module and list rendering module; The list synchronization module is to synchronize the conversation list by using the homepage reverse synchronization and asynchronous forward synchronization completion method after the terminal receives the login information of successful login, and obtain the conversation list summary information; wherein the conversation list summary information includes the conversation ID, the last message ID, the last read message position and the conversation status; The information acquisition module is to acquire session information, user information and picture information from the terminal or the server according to the session ID; The message auto-increment module is used to auto-increment the unread messages in the conversation list and obtain the latest message position through the terminal; The unread message module is to obtain the number of unread messages by subtracting the last read message position from the latest message position; The session analysis module is to load the last message according to the last message ID, obtain preview information, perform session status analysis on the session according to the session status, and obtain the session status identifier; The list rendering module is used to render the conversation list through the UI according to the conversation information, user information, picture information, number of unread messages, preview information and conversation status identifier.
7. A real-time conversation list rendering system as claimed in claim 6, characterized in that: The list synchronization module includes: a change information unit, a reverse synchronization unit and a forward synchronization unit; The change information unit is used to monitor and receive login information in real time through the terminal, and after the terminal receives the login information of successful login, obtain the latest change session list from the server through the terminal; The reverse synchronization unit is used to perform a reverse synchronization task of the homepage session list through the terminal according to the latest changed session list, pull session messages starting from the latest session message, and obtain the first number of session messages reversely synchronized with the homepage session list and the first unsynchronized session message in the latest changed session list; wherein the first number of sessions does not exceed a preset positive integer N; The forward synchronization unit is used to execute the asynchronous task of forward synchronization of the latest changed session list through the terminal according to the comparison result of the first unsynchronized session message, the first session message number and the preset positive integer N, and the latest synchronization version number at the historical moment, and obtain the session list summary information; wherein the session list summary information includes the session ID, the last message ID, the last read message position and the session status.
8. A real-time conversation list rendering system as claimed in claim 7, characterized in that: The forward synchronization unit comprises: a first forward synchronization subunit and a second forward synchronization subunit; The first forward synchronization subunit is used to store and output the summary information of the session list through the terminal if the number of the first session messages is less than a preset positive integer N, and to update the latest synchronization version number at the historical moment to obtain the latest synchronization version number at the current moment; The second forward synchronization subunit is used to execute the asynchronous task of forward synchronization of the latest changed session list through the terminal if the number of the first session messages is equal to a preset positive integer N, incrementally pull the session messages starting from the session message corresponding to the latest synchronization version number at the historical moment until the first unsynchronized session message is completely pulled, store and output the session list summary information through the terminal, and update the latest synchronization version number at the historical moment to obtain the latest synchronization version number at the current moment.
9. A real-time conversation list rendering system as claimed in claim 6, characterized in that: The information acquisition module includes: a session information unit, a user information unit and a picture information unit; The session information unit is used to obtain the second session information corresponding to the session ID from the terminal according to the session ID; if the second session information does not exist in the terminal, obtain the second session information from the instant messaging service of the server, and store the second session information in the terminal; wherein the second session information includes a plurality of sub-session information; The user information unit is used to determine the session type of the second session information according to the session ID; if the session type of the second session information is a single chat session, obtain the user information of the second session information from the terminal; if the user information of the second session information does not exist in the terminal, obtain the user information of the second session information from the user center service of the server, and store the user information of the second session information in the terminal; The picture information unit is used to obtain the picture information of the second session information from the terminal according to the second session information and the user information of the second session information; if the picture information of the second session information does not exist in the terminal, obtain the picture information of the second session information from the network disk of the server, and store the picture information of the second session information in the terminal.
10. A real-time conversation list rendering system as claimed in claim 6, characterized in that: The message self-increment module includes: a first request instruction unit, a consistent hash unit, a second request instruction unit and an unread message self-increment unit; The first request instruction unit is used to send a first request instruction carrying a session ID to the access gateway through the terminal; The consistent hashing unit is used to send a second request instruction for obtaining the latest message location to the IM server through the access gateway according to the session ID, and use a consistent hashing algorithm to transmit multiple sub-session information corresponding to the session ID to multiple IM services of the IM server respectively; The second request instruction unit is used to obtain the latest message location from the MySQL database through the IM server after the IM server receives the second request instruction, and return the latest message location to the terminal; The unread message self-increment unit is used to self-increment the unread messages in the conversation list through the terminal after the terminal receives the latest message position.