Message synchronization system and method for multiple devices
By querying and pushing messages to various online devices from the target server in the distributed server cluster, the problem of untimely message synchronization between different devices is solved, thereby improving the user experience and high availability in the instant messaging system.
Patent Information
- Application Number
- CN202511194078.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-25
- Publication Date
- 2025-10-28
AI Technical Summary
Untimely message synchronization between different devices means that after a user sends or receives a message on one end, other devices cannot quickly display the same message status, affecting the user experience.
The system receives messages from target servers in a distributed server cluster, queries the login servers of the sending and receiving users, and pushes the messages to various online devices to achieve message synchronization among multiple devices.
It ensures that messages can be synchronized in a timely and accurate manner when users switch between different devices, improving the user's instant messaging experience, and provides highly available, scalable, and flexible instant messaging cloud services through a distributed server cluster.
Smart Images

Figure CN120856773A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of instant messaging technology, and in particular to a multi-device message synchronization system and method. Background Technology
[0002] With the rapid development of computer and internet technologies, instant messaging has been widely used in social networking, enterprise collaboration and other fields. In the digital age, users usually use a variety of devices (such as mobile phones, tablets, computers, etc.) for instant messaging.
[0003] In existing technologies, message synchronization between different devices is not timely, resulting in other devices not quickly displaying the same message status after a user sends or receives a message on one end, thus affecting user experience. Therefore, there is an urgent need for a timely and accurate multi-device message synchronization solution. Summary of the Invention
[0004] In view of this, embodiments of this specification provide a multi-device message synchronization system. One or more embodiments of this specification also relate to a multi-device message synchronization method, a computing device, a computer-readable storage medium, and a computer program product, to address the technical deficiencies existing in the prior art.
[0005] According to a first aspect of the embodiments of this specification, a multi-device message synchronization system is provided, including multiple devices and a distributed server cluster; The target server is configured to receive a first message. If the first message is a chat message, the receiving user corresponding to the first message is determined, and the login server corresponding to the sending user and receiving user of the first message is queried. The first message is then pushed to the login server. The target server and the login server are any servers in the distributed server cluster. The login server is configured to query the online devices currently online of the sending user and / or the receiving user, and push the first message to each of the online devices.
[0006] According to a second aspect of the embodiments of this specification, a multi-device message synchronization method is provided, applied to any server in a distributed server cluster, the method comprising: Receive the first message; If the first message is parsed as a chat message, the receiving user corresponding to the first message is determined, and the login server corresponding to the sending user and receiving user of the first message is queried. The first message is then pushed to the login server, wherein the login server is used to push the first message to each online device currently online of the sending user and / or the receiving user.
[0007] According to a third aspect of the embodiments of this specification, a computing device is provided, comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, they implement the steps of the above-described multi-device message synchronization method.
[0008] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided that stores computer-executable instructions, which, when executed by a processor, implement the steps of the above-described multi-device message synchronization method.
[0009] According to a fifth aspect of the embodiments of this specification, a computer program product is provided, including a computer program / instructions that, when executed by a processor, implement the steps of the above-described multi-device message synchronization method.
[0010] This specification provides an embodiment of a multi-device message synchronization system, including multiple devices and a distributed server cluster; a target server is configured to receive a first message, and if the first message is a chat message, determine the receiving user corresponding to the first message, query the login server corresponding to the sending user and the receiving user of the first message, and push the first message to the login server; wherein, the target server and the login server are any servers in the distributed server cluster; the login server is configured to query each online device currently online of the sending user and / or the receiving user, and push the first message to each online device.
[0011] One embodiment of this specification implements a scenario where a sending user sends a first message. When a target server in a distributed server cluster receives the first message, it can query the login server corresponding to the sending and receiving users. Through the login server, the first message can be pushed to all currently online devices of the sending and / or receiving users, achieving message synchronization between multiple devices. After a user sends or receives a message on one end, other devices can quickly display the same message status. This ensures that messages can be synchronized in a timely and accurate manner when a user switches between different devices in an instant messaging system, guaranteeing the user's instant messaging experience. Furthermore, by providing instant messaging cloud services to multiple devices through a distributed server cluster, message storage, processing, and transmission services are provided, achieving high availability, scalability, and flexibility, and providing a solid foundation for multi-device message synchronization. Attached Figure Description
[0012] Figure 1 This is a structural block diagram of a multi-device message synchronization system provided in one embodiment of this specification; Figure 2 This is a schematic diagram illustrating a process for real-time synchronization of messages between multiple devices, provided in one embodiment of this specification. Figure 3 This is a schematic diagram illustrating the process of processing offline synchronization messages between multiple devices according to one embodiment of this specification; Figure 4 This is a schematic diagram illustrating another process for processing offline synchronization messages between multiple devices, provided in one embodiment of this specification. Figure 5 This is a flowchart illustrating a multi-device message synchronization method provided in one embodiment of this specification; Figure 6 This is a schematic diagram of the structure of a multi-device message synchronization device provided in one embodiment of this specification; Figure 7 This is a structural block diagram of a computing device provided in one embodiment of this specification. Detailed Implementation
[0013] Many specific details are set forth in the following description to provide a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.
[0014] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of this specification. The singular forms “a” and “the” as used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0015] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this specification, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0016] Furthermore, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties. Moreover, the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0017] First, the terms and concepts used in one or more embodiments of this specification will be explained.
[0018] Instant Messaging (IM) is a communication technology that enables real-time transmission of text, voice, video, or other multimedia content via the internet or mobile networks. It allows users to communicate instantly online and is widely used in personal social interactions, business collaboration, and customer service. IM messages are sent and received with virtually no delay and support online status display (e.g., online, offline, busy). In addition to text, it supports multimedia formats such as images, voice, video, and files. It supports login on multiple devices including mobile phones, computers, and tablets, with messages synchronized to the cloud. It also supports multi-person chat and group management.
[0019] Distributed server clusters are the core architecture of modern instant messaging (IM) systems. They achieve high availability, high concurrency, and low latency communication services through the collaborative work of multiple servers.
[0020] It's important to note that in today's digital age, users typically use multiple devices (such as mobile phones, tablets, and computers) for instant messaging. However, in multi-device message synchronization solutions, untimely message synchronization between different devices can cause other devices to fail to quickly display the same message status after a user sends or receives a message on one device, impacting user experience. For example, after a user sends a message on their mobile phone, the computer may need to wait a considerable amount of time for the message to be displayed as sent. Furthermore, when the network is unstable or a device switches networks, message synchronization can easily become disordered, resulting in issues such as lost messages or duplicate receptions.
[0021] Therefore, this specification provides a multi-device message synchronization system and method. When a sending user sends a first message and a target server in a distributed server cluster receives the first message, it can query the login server corresponding to the sending and receiving users of the first message. Through the login server, the first message can be pushed to the various online devices currently online by the sending and / or receiving users, realizing message synchronization between multiple devices. After a user sends or receives a message on one end, other devices can quickly present the same message status. In the instant messaging system, this ensures that messages can be synchronized in a timely and accurate manner when the user switches between different devices, guaranteeing the user's instant messaging experience. Furthermore, by providing instant messaging cloud services to multiple devices through a distributed server cluster, message storage, processing, and transmission services are provided, achieving high availability, scalability, and flexibility, providing a solid foundation for multi-device message synchronization.
[0022] This specification provides a multi-device message synchronization system, and also relates to a multi-device message synchronization method, a multi-device message synchronization apparatus, a computing device, a computer-readable storage medium, and a computer program product, which will be described in detail in the following embodiments.
[0023] See Figure 1 , Figure 1 A structural block diagram of a multi-device message synchronization system according to an embodiment of this specification is shown, such as... Figure 1 As shown, the multi-device message synchronization system includes multiple devices 102 and a distributed server cluster 104; The target server 1042 is configured to receive the first message. If the first message is a chat message, the receiving user corresponding to the first message is determined, and the login server 1044 corresponding to the sending user and receiving user of the first message is queried. The first message is then pushed to the login server 1044. The target server 1042 and the login server 1044 are servers in the distributed server cluster 104. Login server 1044 is configured to query the sending user and / or receive the user's currently online devices 1022, and push the first message to each online device 1022.
[0024] Specifically, "multiple devices" can refer to terminal devices held by the sending user and / or receiving user that enable information interaction. These devices include, but are not limited to, mobile phones, computers, tablets, smartwatches, and other similar devices. They can be used to send and receive information and play a role in communication, data transmission, and other scenarios. The sending user is the person who sends the information, and the receiving user is the person who receives the information.
[0025] In practical implementation, the target server refers to the server in the distributed server cluster that receives the first message. After receiving the first message, the target server can parse it to determine its message type. If the first message is a chat message, it means that the first message needs to be synchronized to the various devices of the sending and receiving users. Therefore, the target server can query the login server corresponding to the sending and receiving users of the first message. This login server is a server that the sending and receiving users have pre-registered with. Through the login server, the first message can be pushed to the various online devices currently connected to the sending and / or receiving users, achieving real-time synchronization of the first message. The sending and receiving users can correspond to the same login server or different login servers. Alternatively, the target server can also be the login server for both the sending and / or receiving users. If the target server is the login server for both the sending and / or receiving users, then upon receiving the first message, the target server can directly push the first message to the various online devices currently connected to the sending and / or receiving users, achieving real-time synchronization of the first message.
[0026] It's important to note that each user needs to authenticate within the distributed server cluster (i.e., cloud service) to ensure that only authorized users can access message data within the cluster. Device registration binds each user's devices to their account for subsequent message synchronization. Common authentication methods include username / password, OAuth, and two-factor authentication. Successful authentication yields a unique user ID. By generating a unique device identifier (such as a UUID) and associating it with the user account, device and platform information can be recorded within the distributed server cluster for use during subsequent message synchronization.
[0027] In practice, a message sending and receiving channel is established between the device and the login server. Messages are forwarded to the login server, which then queries the user's registered devices and pushes messages to the corresponding devices through the established sending and receiving channel. When a user sends the first message through any client, the target server in the distributed server cluster can receive the first message. The target server can store the user's account, server address, login device platform, and other information in a Redis cache. The target server can then query all the server information logged into by the user based on the user's account, i.e., the login servers that the user has pre-registered with.
[0028] It's important to note that each user login may lead to a different login server. Assuming user A creates a message channel on login server A, login server A stores the association information between user A and login server A when user A logs in. After receiving the first message pushed by the sending user, the target server parses it to determine the receiving user to whom it needs to be forwarded. The target server can then query the login servers where the sending and receiving users logged in. The target server forwards the first message to the corresponding login server, pushing it to the online devices of both the sending and receiving users through the established message channel between them.
[0029] Example, Figure 2 This is a schematic diagram illustrating a real-time synchronization message processing procedure for multiple devices, provided in one embodiment of this specification. Figure 2 As shown, user A sends the first message to user B to determine if user A is logged in. If not, user A is prompted to log in to confirm whether the login was successful. If not (login failed), the connection is closed, and user A is prompted to resend after 3 seconds. If the login was successful, user A's login binding relationship is sent to the target server. If user A is already logged in, the first message is sent to the target server.
[0030] The target server receives the first message, parses the message type of the first message, and if the first message is a chat message, the target server determines the receiving user of the first message, queries the login servers of the sending user and the receiving user of the first message, and pushes the first message to each login server. The first message is then pushed to each online device of the sending user and / or the receiving user through each login server.
[0031] In the embodiments described in this specification, when a sending user sends a first message and the target server in the distributed server cluster receives the first message, it can query the login server corresponding to the sending user and the receiving user of the first message. Through the login server, the first message can be pushed to the various online devices currently online by the sending user and / or the receiving user, realizing message synchronization between multiple devices. After a user sends or receives a message on one end, other devices can quickly present the same message status. In the instant messaging system, this ensures that messages can be synchronized in a timely and accurate manner when the user switches between different devices, guaranteeing the user's instant messaging experience. Furthermore, by providing instant messaging cloud services to multiple devices through the distributed server cluster, message storage, processing, and transmission services are provided, achieving high availability, scalability, and flexibility, providing a solid foundation for multi-device message synchronization.
[0032] In one optional implementation of this embodiment, the login server 1044 includes a first login server that sends users and a second login server that receives users; The first login server is configured to query each of the user's currently online devices and push the first message to each of the first online devices; The second login server is configured to query and receive information about the user's currently online devices and push the first message to each of the online devices.
[0033] Specifically, the sending user can correspond to a first login server, and the receiving user can correspond to a second login server; that is, the sending user and the receiving user correspond to different login servers. The sending user can have one or more first login servers, and the receiving user can have one or more second login servers.
[0034] In actual implementation, the target server can push the first message to each first login server and each second login server. The first login servers are those where the sending user has logged in or registered. These servers can query the various first online devices currently connected to the sending user and push the first message to each of those devices. This ensures that after the sending user sends the first message on any device, other online devices logged in by the sending user can synchronize the first message in real time. The second login servers are those where the receiving user has logged in or registered. These servers can query the various second online devices currently connected to the receiving user and push the first message to each of those devices. This ensures that all online devices receiving the user can synchronously receive the first message sent by the sending user.
[0035] For example, suppose user A logs in on login server A, establishing a message channel between user A and login server A. User B logs in on login server B, establishing a message channel between user B and login server B. While users A and B are logging into their respective login servers, the login servers store user and server information. Upon receiving the first message, the target server can push it to login server A and login server B. Login server A then pushes the first message to user A's online devices, and login server B pushes the first message to user B's online devices.
[0036] It should be noted that the first login server is the server that sends the user to log in or register. This first login server can query all the first online devices that the sending user is currently online on. For example, the sending user may have logged into their account on a mobile phone, computer, or tablet. These devices are the first online devices. The first login server will push the first message received from the target server to these first online devices. In this way, when the sending user sends the first message on one of the devices, other online devices that have logged into the same account can synchronize this message in real time, making it convenient for the sending user to see the status of their message on different devices.
[0037] The second login server is the server that receives user login and registration operations. This second login server can query the various online devices currently connected to the receiving user. Similarly, the receiving user may also have logged into their account on multiple devices, which are the second online devices. The second login server will push the first message to these second online devices, so that all the receiving user's online devices can synchronously receive the first message sent by the sending user, ensuring that the receiving user will not miss important information no matter which device they use.
[0038] In the embodiments described in this specification, the first message is pushed to each of the user's currently online first online devices through the first login server, and the first message is pushed to each of the user's currently online second online devices through the second login server, which ensures timely synchronization of information and improves the reliability and efficiency of communication between multiple devices.
[0039] In one optional implementation of this embodiment, The first login server is further configured to determine the first session to which the first message belongs, update the server message sequence number of the first session, query each first online device currently online of the sending user, and push the first message to each first online device; The first online device is configured to receive and store the first message and update the local message sequence number of the first session to which the first message belongs.
[0040] It should be noted that in a distributed server cluster, user messages need to be stored and indexed efficiently for fast retrieval and synchronization. Each message can be bound to a session, and a message sequence number (seq) is generated. Message sequence numbers within the same session are unique and consecutive.
[0041] In practice, after the first login server receives the first message, it needs to determine which session the first message belongs to, that is, the first session. In a message communication system, a session can be understood as a series of message interactions between two or more users. For example, two people's chat windows correspond to a session.
[0042] It should be noted that, in order to manage and track messages in a session in an orderly manner, each message in the session can be assigned a corresponding message sequence number. This message sequence number is unique within a session and can be used to identify the order of messages in the session, facilitating subsequent message sorting, querying, and synchronization operations. After the first login server determines the first session to which the first message belongs, it can update the server-side message sequence number of the first session recorded in the first login server. Then, the first login server can query the various online devices currently connected to the sending user and push the received first message to each of the sending user's online devices.
[0043] In practical implementation, the core of multi-device message synchronization lies in data consistency and real-time performance. Synchronization mechanisms can include push-pull modes, which can include a push mode where the server actively pushes messages to each device, and a pull mode where devices periodically request the latest messages from the server. The push mode is when the first login server pushes the first message to each of the sending user's first online devices; real-time message synchronization can also use the push mode. Of course, in practice, real-time message synchronization can also use the pull mode, where the first online device can send a message retrieval request to the first login server to retrieve messages that are not currently synchronized. This specification does not limit this implementation.
[0044] Specifically, real-time synchronization ensures instant message updates. For real-time synchronization, persistent connections can be used to push the first message in real time. Each time the first message is pushed, the system queries all online devices logged in by the user and pushes the message accordingly. Upon receiving the first message from the login server, each online device stores it locally and updates its local message sequence number for the first session to ensure the order of local messages matches the server's, facilitating subsequent message management and display. Persistent connections maintain a continuous communication channel, making them suitable for scenarios with high real-time requirements.
[0045] In actual implementation, when performing message synchronization, a data synchronization protocol can also be designed. Common synchronization protocols include WebSocket, MQTT, XMPP, TCP, UDP, etc. Lightweight data formats such as JSON, XML, and protobuf can be used for message transmission. An efficient message synchronization protocol is the key to achieving multi-device synchronization.
[0046] In the embodiments of this specification, the first message is accurately and orderly transmitted and stored by using the first session to which the first message belongs, the server message sequence number of the first session, and the local message sequence number of the first session, thereby ensuring the synchronization and accuracy of messages across multiple devices.
[0047] It should be noted that the process by which the second login server pushes the first message to each of the receiving user's second online devices is similar to the process by which the first login server pushes the first message to each of the sending user's first online devices, and will not be described again in this embodiment of the specification.
[0048] In an optional implementation of this embodiment, the target server is further configured as follows: If the first message is a login message, the login binding relationship between the target server and the sending user is stored, and a message channel is established between the target server and the sending user's login device. The message channel is used to synchronize messages between the target server and the sending user's login device.
[0049] In practice, the target server parses the first received message to determine its type. If the first message is a login message, it means the user sending the message wishes to log in to the target server. In this case, the target server processes the login information contained in the first message, such as the user account and the associated device. The target server then prompts the sending user to log in and records the login binding relationship between the target server and the sending user. This binding relationship can be used to identify the user's login association with the server later. Furthermore, the target server establishes message channels with each of the sending user's login devices to transmit messages between the target server and the user's devices. After completing these operations, the target server becomes the sending user's login device. Subsequent messages that need to be pushed to the sending user must first be forwarded to this target server before being pushed to the user's login device.
[0050] Continuing with the previous example, such as Figure 2 As shown, after parsing the message type of the first message, if the first message is a login message, then the first message is processed, and the login binding relationship between the target server and the sending user is established.
[0051] In the embodiments described in this specification, the target server parses the received first message and determines its message type. When the type of the first message is a login message, the target server processes the login information contained in the first message, completes the login, ensures the user's normal login on the target server, stores the login binding relationship between the target server and the sending user, and establishes an orderly delivery mechanism for subsequent message pushes.
[0052] In one optional implementation of this embodiment, The login server is further configured to respond to the login request from the offline device of the first user, query each session corresponding to the first user and the maximum message sequence number of the server corresponding to each session, wherein the first user is any user registered on the login server; and return each session corresponding to the first user and the maximum message sequence number of the server corresponding to each session to the offline device of the first user. The offline device of the first user is configured to determine the maximum local message sequence number currently synchronized in each session; based on the maximum message sequence number of the server in the second session and the maximum local message sequence number, the messages in the second session are synchronized, where the second session is any one of the sessions corresponding to the target user.
[0053] Offline devices refer to devices that are registered with the first user but are not connected to the internet or not in real-time connected to the server, such as mobile phones and computers. The first user can be any user registered on the login server.
[0054] It should be noted that offline synchronization can record message changes when the network is unavailable and synchronize them after the network is restored. That is, when any offline device of any user registered on the login server logs in, message synchronization is performed to avoid message synchronization errors when the network is unstable or the device switches networks.
[0055] In practice, any offline device of the first user registered on the login server can send a login request to the login server. Upon receiving the request, the login server queries each session corresponding to the first user, as well as the server's maximum message sequence number for each session. A session is an interaction between the first user and other users or systems, such as a chat conversation. The server's maximum message sequence number is the number of the latest message in each session, numbered sequentially by the login server. The login server returns this information to the offline device of the first user who initiated the login request. Upon receiving this information, the offline device determines the maximum message sequence number currently synchronized locally for each session—that is, the number of the latest synchronized message in that session on the device. Based on any corresponding server's maximum message sequence number and the local maximum message sequence number, the offline device synchronizes the messages in that session. If the server's maximum message sequence number is greater than the local maximum message sequence number, it indicates that there are new messages on the login server that the offline device has not synchronized. The offline device can download these new messages from the login server for synchronization to ensure that the session messages on the device are consistent with those on the server.
[0056] In the embodiments of this specification, for any offline device, after the network is restored, the server-side maximum message sequence number of the first user's session list on the login server can be obtained and compared with the local maximum message sequence number of the session data stored locally to achieve the synchronization of the actual messages. This message synchronization mechanism ensures that even when the device is offline or the network is unstable, the user can seamlessly receive the missing messages, avoiding message synchronization errors, partial message loss, duplicate reception, and other situations.
[0057] In one optional implementation of this embodiment, The first user's offline device is further configured to determine the missing message sequence number of the second session based on the server's maximum message sequence number and the local maximum message sequence number of the second session; and send the session identifier of the second session and the corresponding missing message sequence number to the login server. Log in to the server, and it is further configured to query the missing message corresponding to the missing message sequence number under the second session based on the session identifier of the second session, and push the missing message to the offline device of the first user; The first user's offline device is further configured to receive and store the missing message corresponding to the missing message sequence number, and update the local maximum message sequence number of the second session.
[0058] The local maximum message sequence number refers to the maximum message sequence number of each session stored in the first user's offline device at the time of the last synchronization, representing the latest message position of each session recorded locally by that device. The server-side maximum message sequence number refers to the maximum message sequence number of each session stored in the login server, reflecting the latest message status of each session on the server. The session identifier is information used to uniquely identify each session, mapping local and server message sequence numbers to specific sessions for comparison; it is an example of a session ID. The message sequence number is a unique number assigned to each message within a session, used to identify the message order for easy message location and synchronization.
[0059] Specifically, messages from each session are stored in a distributed database, which supports high-concurrency read and write operations and global vector clock retrieval. By establishing an indexing mechanism, the corresponding messages can be efficiently retrieved from the distributed database, improving data query efficiency.
[0060] In practice, offline synchronization can adopt a pull model. The first user's offline device pulls the server's maximum message sequence number for each session from the login server. Then, it compares the local maximum message sequence number and the server's maximum message sequence number for each session using the session identifier. If the server's maximum message sequence number is greater than the local maximum message sequence number, it means that new messages were generated during the user's offline period, and the messages corresponding to the missing sequence numbers are the messages that need to be synchronized. After determining the missing message sequence numbers for a certain session (such as the second session), the first user's offline device sends these missing message sequence numbers to the login server. The login server, based on the second session's session identifier, queries the database for the missing messages corresponding to the missing message sequence numbers in that session, and then pushes these missing messages to the first user's offline device. After receiving the missing messages, the first user's offline device stores them locally and updates the local maximum message sequence number of the second session to the sequence number of the latest received message for use in the next synchronization.
[0061] Example, Figure 3 This is a schematic diagram illustrating the processing procedure for offline synchronization messages between multiple devices, provided in one embodiment of this specification. Figure 3 As shown, the first user's offline device successfully logs in and obtains the server's maximum message sequence number for each session of the first user through the login server. For each session, the first user's offline device compares the server's maximum message sequence number with the local maximum message sequence number based on the session ID. If there is no difference, it means that the messages stored on the first user's offline device and the login server are identical, and no synchronization is performed. If there is a difference, the missing message sequence number for that session is determined, and the message corresponding to the missing message sequence number is synchronized from the login server based on the missing message sequence number. The synchronized missing message is received and stored, and the corresponding local maximum message sequence number is updated.
[0062] In the embodiments described in this specification, when the first user's offline device reconnects, it can quickly and accurately synchronize the messages missing from each session. This ensures that messages missed by the user during offline periods can be promptly synchronized locally after the device reconnects to the network, improving the efficiency and accuracy of message synchronization. Furthermore, by employing a comparison mechanism between the server's maximum message sequence number and the local maximum message sequence number, the problem of duplicate message synchronization is effectively avoided, enhancing the user experience.
[0063] In one optional implementation of this embodiment, the multiple devices include the offline devices of the second user; The offline device of the second user is configured to respond to the request to obtain the third session by querying whether the message sequence numbers of the third session are consecutive in the local database, where the second user is any user registered on the login server; if they are not consecutive, the local maximum message sequence number and local minimum message sequence number of the third session are determined, and a message synchronization request for the third session is sent to the login server based on the local maximum message sequence number and local minimum message sequence number of the third session. Log in to the server and be further configured to make a message synchronization request based on a third session, query the corresponding message to be synchronized, and push the message to be synchronized to the offline device of the second user; The second user's offline device is further configured to store messages to be synchronized to a local database and update the message sequence number in the second session.
[0064] Specifically, the second user is any user registered on the login server, whose offline device can synchronize messages from a certain session.
[0065] It should be noted that offline synchronization can not only synchronize missing messages after logging in, but also specify the chat messages of a particular session to achieve the synchronization of messages in a specific session.
[0066] In actual implementation, the second user's offline device responds to the third session retrieval request triggered by the second user. The offline device can query its local database to check if the message sequence numbers for the third session are consecutive. Message sequence numbers are typically used to identify the order of messages; consecutive sequence numbers mean no messages are missing. If the message sequence numbers are not consecutive, it indicates that there may be missing messages in the third session. In this case, the offline device can determine the maximum and minimum message sequence numbers in its local database. These two sequence numbers define the range of existing messages locally. Based on the determined maximum and minimum message sequence numbers, the offline device sends a message synchronization request for the third session to the login server to retrieve the missing messages. After receiving the message synchronization request, the login server can search for the corresponding messages to be synchronized in the distributed database based on the information in the request—that is, the messages missing from the offline device. The login server pushes the retrieved messages to be synchronized to the second user's offline device. Upon receiving the messages to be synchronized from the login server, the offline device can store these messages in its local database and update the message sequence numbers under the third session to reflect the newly stored messages, ensuring the continuity and accuracy of the message sequence numbers.
[0067] In the embodiments of this specification, any offline device can determine whether the message sequence numbers of the third session in the local database are continuous. If they are not continuous, the missing messages are retrieved from the corresponding login server based on the local maximum message sequence number and local minimum message sequence number of the third session. This ensures that any offline device can obtain complete session messages through the message synchronization mechanism, thereby guaranteeing the accuracy and integrity of the session messages.
[0068] In one optional implementation of this embodiment, the second user's offline device is further configured as follows: Determine the initial set of message sequence numbers between the local maximum message sequence number and the local minimum message sequence number of the third session; Filter out message sequence numbers stored in the local database from the initial message sequence number set to obtain the message sequence number set to be synchronized; The message synchronization request for the third session is generated based on the set of message sequence numbers to be synchronized.
[0069] In practice, after determining the local maximum and minimum message sequence numbers, the second user's offline device creates an initial set containing these sequence numbers. Next, the offline device checks the message sequence numbers already stored in its local database and removes these stored sequence numbers from the initial set, resulting in a set containing only the sequence numbers of the messages to be synchronized. Finally, based on this set of sequence numbers, the offline device generates a message synchronization request for the third session and sends it to the login server to retrieve the missing messages. Upon receiving the message synchronization request, the login server parses the set of sequence numbers to be synchronized in the request and precisely searches for the corresponding message content in the distributed database based on these sequence numbers. After receiving these synchronization messages, the offline device can store them sequentially in its local database according to their sequence numbers and update the message sequence number record for the session, ensuring the continuity of message sequence numbers and the integrity of the session.
[0070] It should be noted that messages in a session usually have a unique sequence number to identify their order and uniqueness. The second user's offline device can determine all message sequence numbers between the local maximum message sequence number and the local minimum message sequence number in the third session. These sequence numbers constitute the initial message sequence number set. For example, if the local maximum message sequence number is 100 and the local minimum message sequence number is 50, then the initial message sequence number set is all integer sequence numbers between 50 and 100.
[0071] The offline device's local database may already contain some messages, and the sequence numbers corresponding to these messages already exist in the local database. To avoid repeatedly synchronizing these existing messages, the offline device can filter out the message sequence numbers already stored in the local database from the initial message sequence number set. After filtering, the remaining message sequence numbers form the set of message sequence numbers to be synchronized, which represents the sequence numbers of the messages that the offline device is missing and needs to be synchronized from the login server. Based on the obtained set of message sequence numbers to be synchronized, the offline device can generate a message synchronization request and send it to the login server. The login server can query the messages corresponding to these message sequence numbers and return them to the offline device, thus achieving the synchronization of missing messages. This allows the offline device to obtain complete message data from the third session and maintain consistency with other devices.
[0072] Example, Figure 4 This is a schematic diagram illustrating another process for processing offline synchronization messages between multiple devices, provided in one embodiment of this specification. Figure 4 As shown, the second user's offline device receives a request to retrieve the third session, queries its local database to determine if the message sequence numbers of the third session are consecutive. If they are consecutive, synchronization ends. If they are not consecutive, based on the initial set of message sequence numbers between the local maximum and minimum message sequence numbers of the third session, message sequence numbers stored in the local database are filtered out from the initial set of message sequence numbers to obtain a set of message sequence numbers to be synchronized. Based on the set of message sequence numbers to be synchronized, the missing messages of the third session in the offline device are synchronized from the corresponding login server.
[0073] In the embodiments of this specification, any offline device can determine whether the message sequence numbers of the third session in the local database are continuous. If they are not continuous, it first determines the initial message sequence number set between the local maximum message sequence number and the local minimum message sequence number of the third session, then filters out the message sequence numbers of messages already stored in the set to obtain the message sequence number set to be synchronized, and then pulls the messages corresponding to these sequence numbers from the corresponding login server to realize the synchronization of missing session messages, thus ensuring the accuracy and integrity of session messages.
[0074] See Figure 5 , Figure 5 A flowchart of a multi-device message synchronization method according to an embodiment of this specification is shown, which is applied to any server in a distributed server cluster and specifically includes the following steps.
[0075] Step 502: Receive the first message.
[0076] Step 504: If the first message is parsed as a chat message, determine the receiving user corresponding to the first message, query the login server corresponding to the sending user and receiving user of the first message, and push the first message to the login server. The login server is used to push the first message to each online device currently online of the sending user and / or the receiving user.
[0077] In one optional implementation of this embodiment, after receiving the first message, the method further includes: If the first message is a login message, the login binding relationship between the target server and the sending user is stored, and a message channel is established between the target server and the sending user's login device. The message channel is used to synchronize messages between the target server and the sending user's login device.
[0078] This specification provides an embodiment of a multi-device message synchronization method. When a sending user sends a first message, and a target server in a distributed server cluster receives the first message, it can query the login server corresponding to the sending and receiving users. Through these login servers, the first message can be pushed to all currently online devices of the sending and / or receiving users, achieving message synchronization between multiple devices. After a user sends or receives a message on one end, other devices can quickly display the same message status. In an instant messaging system, this ensures timely and accurate message synchronization when a user switches between different devices, guaranteeing the user's instant messaging experience. Furthermore, by providing instant messaging cloud services to multiple devices through a distributed server cluster, providing message storage, processing, and transmission services, it achieves high availability, scalability, and flexibility, providing a solid foundation for multi-device message synchronization.
[0079] The above is an illustrative scheme of a multi-device message synchronization method according to this embodiment. It should be noted that the technical solution of this multi-device message synchronization method belongs to the same concept as the technical solution of the multi-device message synchronization system described above. For details not described in detail in the technical solution of the multi-device message synchronization method, please refer to the description of the technical solution of the multi-device message synchronization system described above.
[0080] Corresponding to the above method embodiments, this specification also provides embodiments of a multi-device message synchronization device. Figure 6 This specification shows a schematic diagram of a multi-device message synchronization device according to an embodiment, which is applied to any server in a distributed server cluster, such as... Figure 6 As shown, the device includes: The receiving module 602 is configured to receive the first message; The push module 604 is configured to, when parsing the first message as a chat message, determine the receiving user corresponding to the first message, query the login server corresponding to the sending user and receiving user of the first message, and push the first message to the login server. The login server is used to push the first message to each online device currently online of the sending user and / or the receiving user.
[0081] This specification provides an embodiment of a multi-device message synchronization device. When a sending user sends a first message and a target server in a distributed server cluster receives the first message, it can query the login server corresponding to the sending and receiving users of the first message. Through the login server, the first message can be pushed to the various online devices currently connected to the sending and / or receiving users, thereby achieving message synchronization between multiple devices. After a user sends or receives a message on one end, other devices can quickly display the same message status. In an instant messaging system, this ensures that messages can be synchronized in a timely and accurate manner when a user switches between different devices, guaranteeing the user's instant messaging experience. Furthermore, by providing instant messaging cloud services to multiple devices through a distributed server cluster, message storage, processing, and transmission services are provided, achieving high availability, scalability, and flexibility, and providing a solid foundation for multi-device message synchronization.
[0082] The above is an illustrative scheme of a multi-device message synchronization device according to this embodiment. It should be noted that the technical solution of this multi-device message synchronization device and the technical solution of the multi-device message synchronization system described above belong to the same concept. For details not described in detail in the technical solution of the multi-device message synchronization device, please refer to the description of the technical solution of the multi-device message synchronization system described above.
[0083] Figure 7 A structural block diagram of a computing device according to one embodiment of this specification is shown. The components of the computing device 700 include, but are not limited to, a memory 710 and a processor 720. The processor 720 is connected to the memory 710 via a bus 730, and a database 750 is used to store data.
[0084] The computing device 700 also includes an access device 740, which enables the computing device 700 to communicate via one or more networks 760. Examples of these networks include Public Switched Telephone Network (PSTN), Local Area Network (LAN), Wide Area Network (WAN), Personal Area Network (PAN), or combinations of communication networks such as the Internet. The access device 740 may include one or more of any type of wired or wireless network interface (e.g., a network interface card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) wireless interface, a Wi-MAX (Worldwide Interoperability for Microwave Access) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, or a Near Field Communication (NFC) interface.
[0085] In one embodiment of this specification, the above-described components of the computing device 700 and Figure 7 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 7 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0086] The computing device 700 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or personal computers (PCs). The computing device 700 can also be a mobile or stationary server.
[0087] The processor 720 is configured to execute the following computer-executable instructions, which, when executed by the processor, implement the steps of the above-described multi-device message synchronization method.
[0088] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device belongs to the same concept as the technical solutions of the multi-device message synchronization method and the multi-device message synchronization system described above. For details not described in detail in the technical solution of the computing device, please refer to the descriptions of the technical solutions of the multi-device message synchronization method and the multi-device message synchronization system described above.
[0089] An embodiment of this specification also provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the above-described multi-device message synchronization method.
[0090] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium belongs to the same concept as the technical solutions of the multi-device message synchronization method and the multi-device message synchronization system described above. For details not described in detail in the technical solution of the storage medium, please refer to the descriptions of the technical solutions of the multi-device message synchronization method and the multi-device message synchronization system described above.
[0091] An embodiment of this specification also provides a computer program, wherein when the computer program is executed in a computer, it causes the computer to perform the steps of the above-described multi-device message synchronization method.
[0092] The above is an illustrative scheme of a computer program according to this embodiment. It should be noted that the technical solution of this computer program belongs to the same concept as the technical solutions of the multi-device message synchronization method and the multi-device message synchronization system described above. For details not described in detail in the technical solution of the computer program, please refer to the descriptions of the technical solutions of the multi-device message synchronization method and the multi-device message synchronization system described above.
[0093] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0094] Computer instructions include computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. Computer-readable media can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in computer-readable media can be appropriately added or removed according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.
[0095] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments in this specification are not limited to the described order of actions, because according to the embodiments in this specification, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments in this specification.
[0096] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0097] The preferred embodiments disclosed above are merely illustrative of this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the embodiments described herein. These embodiments are selected and specifically described in this specification to better explain the principles and practical applications of the embodiments, thereby enabling those skilled in the art to better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.
Claims
1. A multi-device message synchronization system, characterized in that, Includes multiple devices and a distributed server cluster; The target server is configured to receive a first message. If the first message is a chat message, the receiving user corresponding to the first message is determined, and the login server corresponding to the sending user and receiving user of the first message is queried. The first message is then pushed to the login server. The target server and the login server are servers in the distributed server cluster. The login server is configured to query the online devices currently online of the sending user and / or the receiving user, and push the first message to each of the online devices.
2. The multi-device message synchronization system according to claim 1, characterized in that, The login server includes the first login server that sends the user and the second login server that receives the user; The first login server is configured to query each of the first online devices currently online by the sending user, and push the first message to each of the first online devices; The second login server is configured to query each of the second online devices currently online by the receiving user, and push the first message to each of the second online devices.
3. The multi-device message synchronization system according to claim 2, characterized in that, The first login server is further configured to determine the first session to which the first message belongs, update the server message sequence number of the first session, query each first online device currently online by the sending user, and push the first message to each first online device; The first online device is configured to receive and store the first message, and update the local message sequence number of the first session to which the first message belongs.
4. The multi-device message synchronization system according to claim 1, characterized in that, The target server is further configured as follows: If the first message is a login message, then the login binding relationship between the target server and the sending user is stored, and a message channel is established between the target server and the sending user's login device, wherein the message channel is used to synchronize messages between the target server and the sending user's login device.
5. The multi-device message synchronization system according to claim 1, characterized in that, The login server is further configured to respond to a login request from the offline device of the first user by querying each session corresponding to the first user and the maximum message sequence number of the server corresponding to each session, wherein the first user is any user registered on the login server; and return each session corresponding to the first user and the maximum message sequence number of the server corresponding to each session to the offline device of the first user. The first user's offline device is configured to determine the maximum local message sequence number currently synchronized in each session; based on the server maximum message sequence number and the local maximum message sequence number of the second session, the messages in the second session are synchronized, wherein the second session is any one of the sessions corresponding to the target user.
6. The multi-device message synchronization system according to claim 5, characterized in that, The offline device of the first user is further configured to determine the missing message sequence number of the second session based on the server's maximum message sequence number and the local maximum message sequence number of the second session; and send the session identifier of the second session and the corresponding missing message sequence number to the login server. The login server is further configured to query the missing message corresponding to the missing message sequence number under the second session based on the session identifier of the second session, and push the missing message to the offline device of the first user; The first user's offline device is further configured to receive and store the missing message corresponding to the missing message sequence number, and update the local maximum message sequence number of the second session.
7. The multi-device message synchronization system according to claim 1, characterized in that, The multiple devices include the offline devices of the second user; The offline device of the second user is configured to, in response to the request to obtain the third session, query the local database to see if the message sequence numbers of the third session are consecutive, wherein the second user is any user registered on the login server; if they are not consecutive, determine the local maximum message sequence number and the local minimum message sequence number of the third session, and send a message synchronization request for the third session to the login server based on the local maximum message sequence number and the local minimum message sequence number of the third session. The login server is further configured to query the corresponding message to be synchronized based on the message synchronization request of the third session, and push the message to be synchronized to the offline device of the second user; The second user's offline device is further configured to store the messages to be synchronized to a local database and update the message sequence number under the second session.
8. The multi-device message synchronization system according to claim 7, characterized in that, The second user's offline device is further configured as follows: Determine the initial sequence number set between the local maximum message sequence number and the local minimum message sequence number of the third session; Filter out the message sequence numbers stored in the local database from the initial message sequence number set to obtain the message sequence number set to be synchronized; The message synchronization request for the third session is generated based on the set of message sequence numbers to be synchronized.
9. A method for synchronizing messages across multiple devices, characterized in that, Applied to any server in a distributed server cluster, the method includes: Receive the first message; If the first message is parsed as a chat message, the receiving user corresponding to the first message is determined, and the login server corresponding to the sending user and receiving user of the first message is queried. The first message is then pushed to the login server, wherein the login server is used to push the first message to each online device currently online of the sending user and / or the receiving user.
10. A computing device, characterized in that, include: memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the message synchronization method for multiple devices as described in claim 9.