Nothing Special   »   [go: up one dir, main page]

CN112492048B - Message synchronization method and device, electronic equipment and readable storage medium - Google Patents

Message synchronization method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN112492048B
CN112492048B CN202011468434.6A CN202011468434A CN112492048B CN 112492048 B CN112492048 B CN 112492048B CN 202011468434 A CN202011468434 A CN 202011468434A CN 112492048 B CN112492048 B CN 112492048B
Authority
CN
China
Prior art keywords
message
session
code
client
user
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011468434.6A
Other languages
Chinese (zh)
Other versions
CN112492048A (en
Inventor
胡晓军
王亚雄
李智广
彭涛
龙喜洋
高宏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Merchants Finance Technology Co Ltd
Original Assignee
China Merchants Finance Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Merchants Finance Technology Co Ltd filed Critical China Merchants Finance Technology Co Ltd
Priority to CN202011468434.6A priority Critical patent/CN112492048B/en
Publication of CN112492048A publication Critical patent/CN112492048A/en
Application granted granted Critical
Publication of CN112492048B publication Critical patent/CN112492048B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/55Push-based network services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/04Real-time or near real-time messaging, e.g. instant messaging [IM]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/04Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
    • H04L63/0428Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
    • H04L63/0442Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload wherein the sending and receiving network entities apply asymmetric encryption, i.e. different keys for encryption and decryption
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/12Applying verification of the received information
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/54Presence management, e.g. monitoring or registration for receipt of user log-on information, or the connection status of the users

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention relates to data processing, and discloses a message synchronization method, which comprises the following steps: storing each conversation message into a message sequence corresponding to each conversation; establishing a corresponding session set for each user, wherein the session set comprises a message queue to be synchronized and a push record table, and the push record table comprises a first code of the last message in the message sequence, a second code of the last message in the message queue to be synchronized and a third code of the pushed last message; storing the newly added messages into each message queue to be synchronized every first time to obtain a new first code and a new second code; and when the pushing is judged to be needed, pushing the messages between the third codes and the new second codes in each message queue to be synchronized corresponding to the appointed client. The invention also provides a message synchronization device, electronic equipment and a readable storage medium. The invention improves the message synchronization efficiency.

Description

Message synchronization method and device, electronic equipment and readable storage medium
Technical Field
The present invention relates to the field of data processing, and in particular, to a message synchronization method and apparatus, an electronic device, and a readable storage medium.
Background
With the development of internet technology, the application of instant messaging is becoming more widespread, for example, people utilize software such as WeChat, QQ or nailing as communication tools in daily work and life, and as the number of users increases, the amount of messages generated becomes more huge, and how to synchronize the messages to the corresponding clients?
Currently, message synchronization is usually performed by means of read or write diffusion. When the read diffusion is synchronous, the storage of the messages in a warehouse only needs to be written once, however, the client needs to pull each session once to obtain all the messages, and the read is greatly amplified; when write-flooding synchronization is performed, the message needs to be synchronized to the subscription list of each client (if there are N participants in a session, the message needs to be written N times). Both of these synchronization approaches result in inefficient message synchronization. Therefore, a message synchronization method is needed to improve the message synchronization efficiency.
Disclosure of Invention
In view of the above, there is a need to provide a message synchronization method, aiming to improve the message synchronization efficiency.
The message synchronization method provided by the invention comprises the following steps:
receiving session messages sent by each client, wherein the session messages comprise message headers and message contents, the message headers comprise session IDs, member IDs participating in the sessions and message sending time, the session messages are stored in message sequences corresponding to the sessions in a first database based on the session IDs and the message sending time, and each message in each message sequence is encoded;
establishing a corresponding session set for each user in a second database based on the member ID, wherein the session set comprises a message queue to be synchronized and a push record table of each session in which the corresponding user participates, and the push record table comprises a first code of the last message in the message sequence of each session in which the corresponding user participates, a second code of the last message in the message queue to be synchronized and a third code of the pushed last message;
storing newly-added messages in the message sequence of each session into a message queue to be synchronized of each session based on the first code and the second code at intervals of first time, and updating the first code and the second code to obtain a new first code and a new second code;
monitoring the online and/or offline state of each client in real time, judging whether a message needs to be pushed to a specified client at intervals of a second time when a specified client is online, pushing the message between a third code and a new second code in a message queue to be synchronized of each session corresponding to the specified client when the specified client needs to be pushed, and updating the third code in a pushing record table corresponding to the specified client to obtain the new third code.
Optionally, the message header further includes a standard information digest value ciphertext of the session message and a sender ID, and before storing each session message in a message sequence corresponding to each session in the first database based on the session ID and the message sending time, the method further includes:
carrying out validity verification on each session message;
the validity verification of each session message includes:
selecting a session message, and calculating the information abstract value of the selected session message;
acquiring a first public key corresponding to the sender based on the ID of the sender of the selected session message, and decrypting a standard information digest value ciphertext of the selected session message by using the first public key to obtain a decrypted standard information digest value;
and when the calculated message digest value is consistent with the decrypted standard message digest value, judging that the selected session message is legal.
Optionally, after obtaining the decrypted standard message digest value, the method further includes:
if the calculated message digest value is not consistent with the decrypted standard message digest value, judging that the selected session message is illegal, and discarding the selected session message.
Optionally, before pushing the message between the third code and the new second code in the message queue to be synchronized of each session corresponding to the specified client, the method further includes:
and acquiring a second public key corresponding to the specified client, and encrypting each message between a third code and a new second code in the message queue to be synchronized of each session corresponding to the specified client by using the second public key.
Optionally, before every second time, the method further includes:
and calculating the average time interval of each newly added message in a third time period of each session participated by the appointed client user, and taking the average time interval as the second time.
Optionally, the method further includes:
responding to a message synchronization request sent by a user based on a target client, displaying a synchronization type selection interface to the target client interface, if the user selects full synchronization based on the selection interface, displaying session IDs of all sessions participated by the user to the target client interface, and synchronizing a corresponding message sequence to the target client based on the session ID selected by the user;
and if the user selects incremental synchronization based on the selection interface, displaying the session IDs of all sessions participated by the user and a synchronization time starting point input box to the target client interface, determining a fourth code of an initial message to be synchronized in the message sequence of the session ID selected by the user based on the synchronization time starting point selected by the user, and synchronizing all messages taking the fourth code as a starting point in the message sequence of the session ID selected by the user to the target client.
In order to solve the above problem, the present invention further provides a message synchronization apparatus, including:
the encoding module is used for receiving session messages sent by all clients, wherein the session messages comprise message headers and message contents, the message headers comprise session IDs, member IDs participating in the sessions and message sending time, and the session messages are stored in message sequences corresponding to all the sessions in the first database based on the session IDs and the message sending time and are encoded for each piece of information in all the message sequences;
the establishing module is used for establishing a corresponding session set for each user in a second database based on the member ID, wherein the session set comprises a message queue to be synchronized and a pushing record table of each session in which the corresponding user participates, and the pushing record table comprises a first code of the last message in the message sequence of each session in which the corresponding user participates, a second code of the last message in the message queue to be synchronized and a third code of the pushed last message;
the updating module is used for storing newly-added messages in the message sequence of each session into a message queue to be synchronized of each session based on the first code and the second code at intervals of first time, and updating the first code and the second code to obtain a new first code and a new second code;
the pushing module is used for monitoring the online and/or offline state of each client in real time, judging whether a message needs to be pushed to a specified client at intervals of a second time when a specified client is online, pushing the message between a third code and a new second code in a message queue to be synchronized of each session corresponding to the specified client when the message needs to be pushed, and updating the third code in a pushing record table corresponding to the specified client to obtain the new third code.
Optionally, the pushing module is further configured to:
and calculating the average time interval of each newly added message in a third time period of each session participated by the appointed client user, and taking the average time interval as the second time.
In order to solve the above problem, the present invention also provides an electronic device, including:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a message synchronization program executable by the at least one processor to enable the at least one processor to perform the message synchronization method described above.
In order to solve the above problem, the present invention also provides a computer-readable storage medium having stored thereon a message synchronization program, which is executable by one or more processors to implement the above message synchronization method.
Compared with the prior art, the method stores each session message into the message sequence corresponding to each session based on the session ID and the message sending time, and the step ensures that the messages in each message sequence are continuous and complete; then, a session set is established for each user based on the member ID, the session set comprises a message queue to be synchronized and a push record table of each session in which the user participates, and the push record table comprises a first code of the last message in the message sequence of each session, a second code of the last message in the message queue to be synchronized and a third code of the last message which is pushed; then, storing newly added messages in the message sequence of each session into a message queue to be synchronized at intervals of first time, and updating the first code and the second code to obtain a new first code and a new second code; and finally, when the message needs to be pushed to the specified client, pushing the message between the third code and the new second code in the message queue to be synchronized of each session corresponding to the specified client. Therefore, the invention improves the message synchronization efficiency.
Drawings
Fig. 1 is a schematic flowchart of a message synchronization method according to an embodiment of the present invention;
fig. 2 is a block diagram of a message synchronization apparatus according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of an electronic device implementing a message synchronization method according to an embodiment of the present invention;
the implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the description relating to "first", "second", etc. in the present invention is for descriptive purposes only and is not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In addition, technical solutions between various embodiments may be combined with each other, but must be realized by a person skilled in the art, and when the technical solutions are contradictory or cannot be realized, such a combination should not be considered to exist, and is not within the protection scope of the present invention.
The invention provides a message synchronization method. Fig. 1 is a schematic flow chart of a message synchronization method according to an embodiment of the present invention. The method may be performed by an electronic device, which may be implemented by software and/or hardware.
In this embodiment, the message synchronization method includes:
s1, receiving session messages sent by each client, wherein the session messages comprise message headers and message contents, the message headers comprise session IDs, member IDs participating in the sessions and message sending time, storing each session message into a message sequence corresponding to each session in a first database based on the session IDs and the message sending time, and encoding each piece of information in each message sequence.
The message synchronization method provided by this embodiment is applied to an electronic device, which may be a background server of instant messaging software, where the first database is used to store all session messages, and when receiving a session message sent by a client based on the instant messaging software, stores each session message into a message sequence corresponding to each session according to a session ID carried by the session message, and encodes each piece of information in the message sequence according to sending time carried by the session message (for example, an encoding of a first message in the message sequence corresponding to session a may be a-1, and an encoding of a second message may be a-2), so that it can be ensured that messages in the message sequence corresponding to each session are continuous and complete.
In this embodiment, the message header further includes a standard information digest value ciphertext of the session message and a sender ID, and before storing each session message in a message sequence corresponding to each session in the first database based on the session ID and the message sending time, the method further includes:
carrying out validity verification on each session message;
the validity verification of each session message includes:
a11, selecting a session message, and calculating the message digest value of the selected session message;
a12, acquiring a first public key corresponding to the sender based on the ID of the sender of the selected session message, and decrypting a standard information digest value ciphertext of the selected session message by using the first public key to obtain a decrypted standard information digest value;
a13, when the calculated message digest value is consistent with the decrypted standard message digest value, judging that the selected session message is legal.
After obtaining the decrypted standard message digest value, the method further comprises:
if the calculated message digest value is not consistent with the decrypted standard message digest value, judging that the selected session message is illegal, and discarding the selected session message.
In this embodiment, the message digest value is an MD5 value, and each client encrypts the standard message digest value with its own private key when sending the session message, so as to ensure the security of the ciphertext of the standard message digest value, and stop the possibility of tampering the session message by comparing whether the computed message digest value is consistent with the decrypted standard message digest value.
S2, establishing a corresponding session set for each user in a second database based on the member ID, wherein the session set comprises a message queue to be synchronized and a push record table of each session in which the corresponding user participates, and the push record table comprises a first code of the last message in the message sequence of each session in which the corresponding user participates, a second code of the last message in the message queue to be synchronized and a third code of the pushed last message.
In this embodiment, because the first database needs to store all received session messages, and as the message volume increases, the pressure for synchronizing the messages to the client increases, which results in low message synchronization efficiency.
In this embodiment, a session set corresponding to each user is established in the second database, where the session set includes a to-be-synchronized message queue and a push record table corresponding to all sessions in which the user participates, and the push record table records a first code of a last message in a message sequence of each session, a second code of the last message in the to-be-synchronized message queue, and a third code of the last message pushed to the client.
In the step, a user-level session set is established, so that the realization logic of the message synchronization based on the user is simpler.
And S3, storing the newly added messages in the message sequence of each session into the message queue to be synchronized of each session based on the first code and the second code at intervals of first time, and updating the first code and the second code to obtain a new first code and a new second code.
The first time may be 1 second, for example, the push record table corresponding to the user 1 records: the first code of the last piece of information in the message sequence corresponding to the session a is a-50, and the second code of the last piece of information in the message queue to be synchronized corresponding to the session a is a-30, which indicates that the 31 st to 50 th messages in the session a have not been updated to the message queue to be synchronized, at this time, the 31 st to 50 th messages can be updated to the message queue to be synchronized, and the first code and the second code of the session a in the push record table are updated.
And S4, monitoring the online and/or offline state of each client in real time, judging whether a message needs to be pushed to a specified client every second time when a certain specified client is online, pushing the message between a third code and a new second code in a message queue to be synchronized of each session corresponding to the specified client when the message needs to be pushed, and updating the third code in a pushing record table corresponding to the specified client to obtain the new third code.
The second time may be 3 seconds, for example, the push record table of user 1 records: and if the third code of the session A is A-0 (initial value) and the new second code is A-50, the message that the 1 st to 50 th messages of the session A need to be pushed to the client of the user 1 is shown, and after the message pushing is finished, the third code of the session A in the pushing record table is updated to be A-50.
In this embodiment, after pushing the message between the third code and the new second code in the message queue to be synchronized of the session a to the specified client, the message in the message queue to be synchronized of the session a may be emptied, and a preset number (e.g., 200) of latest messages may also be reserved.
In this embodiment, before pushing the message between the third code and the new second code in the message queue to be synchronized of each session corresponding to the specified client, the method further includes:
and acquiring a second public key corresponding to the specified client, and encrypting each message between a third code and a new second code in the message queue to be synchronized of each session corresponding to the specified client by using the second public key.
After receiving the message pushed by the client, the appointed client user can decrypt each piece of information by using a private key of the appointed client user, the message header of each piece of information also comprises a standard information abstract value, and the appointed client user can judge the legality of each piece of information by comparing whether the calculated information abstract value is consistent with the standard information abstract value. Meanwhile, whether the message synchronization is missed or repeated can be judged according to whether the codes of the messages corresponding to the sessions are continuous or overlapped.
In another embodiment of the present invention, before every second time, the method further comprises:
and calculating the average time interval of newly added messages in a third time period (for example, the last hour) of each session in which the specified client user participates, and taking the average time interval as the second time.
The step can set different message pushing time intervals for users with different liveness degrees, fully ensures the timeliness of message pushing, and simultaneously avoids resource waste caused by frequently pushing messages for inactive users.
In this embodiment, the method further includes:
b11, responding to a message synchronization request sent by a user based on a target client, displaying a synchronization type selection interface to the target client interface, if the user selects full synchronization based on the selection interface, displaying the session IDs of all sessions participated by the user to the target client interface, and synchronizing the corresponding message sequence to the target client based on the session ID selected by the user;
b12, if the user selects the increment synchronization based on the selection interface, displaying the session ID and the synchronization time starting point input box of all the sessions participated by the user to the target client interface, determining the fourth code of the initial message to be synchronized in the message sequence of the session ID selected by the user based on the synchronization time starting point selected by the user, and synchronizing all the messages taking the fourth code as the starting point in the message sequence of the session ID selected by the user to the target client.
When the client user needs synchronization information, either full or incremental synchronization may be selected. When the increment synchronization is selected, whether the message queue to be synchronized has the message of the fourth code or not can be judged, if yes, all the messages taking the fourth code as the starting point in the message queue to be synchronized are synchronized to the client; and if the message sequence does not exist, synchronizing all messages taking the fourth code as a starting point in the message sequence to the client.
It can be known from the above embodiments that, in the message synchronization method provided by the present invention, first, each session message is stored into the message sequence corresponding to each session based on the session ID and the message sending time, and this step ensures that the messages in each message sequence are continuous and complete; then, establishing a session set for each user based on the member ID, wherein the session set comprises a message queue to be synchronized and a push record table of each session participated by the user, and the push record table comprises a first code of the last message in the message sequence of each session, a second code of the last message in the message queue to be synchronized and a third code of the pushed last message; then, storing newly added messages in the message sequence of each session into a message queue to be synchronized at intervals of first time, and updating the first code and the second code to obtain a new first code and a new second code; and finally, when the message is judged to need to be pushed to the appointed client, pushing the message between the third code and the new second code in the message queue to be synchronized of each session corresponding to the appointed client. Therefore, the invention improves the message synchronization efficiency.
Fig. 2 is a schematic block diagram of a message synchronization apparatus according to an embodiment of the present invention.
The message synchronization apparatus 100 of the present invention can be installed in an electronic device. According to the implemented functions, the message synchronization apparatus 100 may include an encoding module 110, a setup module 120, an update module 130, and a push module 140. The module of the present invention, which may also be referred to as a unit, refers to a series of computer program segments that can be executed by a processor of an electronic device and can perform a fixed function, and are stored in a memory of the electronic device.
In the present embodiment, the functions regarding the respective modules/units are as follows:
the encoding module 110 is configured to receive session messages sent by each client, where the session messages include message headers and message contents, the message headers include session IDs, member IDs participating in the sessions, and message sending times, store each session message in a message sequence corresponding to each session in the first database based on the session IDs and the message sending times, and encode each piece of information in each message sequence.
The first database is used for storing all session messages, when receiving the session messages sent by the client based on the instant messaging software, the first database stores each session message into a message sequence corresponding to each session according to a session ID carried by the session message, and encodes each piece of information in the message sequence according to sending time carried by the session message (for example, the encoding of the first message in the message sequence corresponding to the session A can be A-1, and the encoding of the second message can be A-2), so that the messages in the message sequence corresponding to each session can be ensured to be continuous and complete.
In this embodiment, the message header further includes a standard message digest value ciphertext of the session message and a sender ID, and before storing each session message in a message sequence corresponding to each session in the first database based on the session ID and the message sending time, the encoding module 110 is further configured to:
carrying out validity verification on each session message;
the validity verification of each session message includes:
a21, selecting a session message, and calculating the message digest value of the selected session message;
a22, acquiring a first public key corresponding to the sender based on the ID of the sender of the selected session message, and decrypting a standard information digest value ciphertext of the selected session message by using the first public key to obtain a decrypted standard information digest value;
a23, when the calculated message digest value is consistent with the decrypted standard message digest value, judging that the selected session message is legal.
After obtaining the decrypted standard message digest value, the encoding module 110 is further configured to:
if the calculated message digest value is not consistent with the decrypted standard message digest value, judging that the selected session message is illegal, and discarding the selected session message.
In this embodiment, the message digest value is an MD5 value, and each client encrypts the standard message digest value with its own private key when sending the session message, so as to ensure the security of the ciphertext of the standard message digest value, and stop the possibility of tampering the session message by comparing whether the computed message digest value is consistent with the decrypted standard message digest value.
An establishing module 120, configured to establish, in the second database, a corresponding session set for each user based on the member ID, where the session set includes a to-be-synchronized message queue of each session in which the corresponding user participates and a push record table, and the push record table includes a first code of a last message in a message sequence of each session in which the corresponding user participates, a second code of a last message in the to-be-synchronized message queue, and a third code of a last message that has been pushed.
In this embodiment, because the first database needs to store all received session messages, and as the message volume increases, the pressure for synchronizing the messages to the client increases, which results in low message synchronization efficiency.
In this embodiment, a session set corresponding to each user is established in the second database, where the session set includes a to-be-synchronized message queue and a push record table corresponding to all sessions in which the user participates, and the push record table records a first code of a last message in a message sequence of each session, a second code of the last message in the to-be-synchronized message queue, and a third code of the last message pushed to the client.
The present embodiment establishes the session set at the user level through the establishing module 120, so that the implementation logic of the message synchronization based on the user is simpler.
And an updating module 130, configured to store, at every first time, the newly added message in the message sequence of each session into the message queue to be synchronized of each session based on the first code and the second code, and update the first code and the second code to obtain a new first code and a new second code.
The first time may be 1 second, for example, the push record table corresponding to the user 1 records: the first code of the last message in the message sequence corresponding to the session a is a-50, and the second code of the last message in the message queue to be synchronized corresponding to the session a is a-30, which indicates that the 31 st to 50 th messages in the session a have not been updated to the message queue to be synchronized, at this time, the 31 st to 50 th messages can be updated to the message queue to be synchronized, and the first code and the second code of the session a in the push record table are updated.
The pushing module 140 is configured to monitor online and/or offline states of each client in real time, when a certain specified client is online, determine whether a message needs to be pushed to the specified client at every second time, when it is determined that the message needs to be pushed, push a message between a third code and a new second code in a message queue to be synchronized of each session corresponding to the specified client, and update the third code in a pushing record table corresponding to the specified client to obtain the new third code.
The second time may be 3 seconds, for example, the push record table of user 1 records: and if the third code of the session A is A-0 (initial value) and the new second code is A-50, the message that the 1 st to 50 th messages of the session A need to be pushed to the client of the user 1 is shown, and after the message pushing is finished, the third code of the session A in the pushing record table is updated to be A-50.
In this embodiment, after pushing the message between the third code and the new second code in the message queue to be synchronized of the session a to the specified client, the message in the message queue to be synchronized of the session a may be emptied, and a preset number (e.g., 200) of latest messages may also be reserved.
In this embodiment, before pushing the message between the third code and the new second code in the message queue to be synchronized of each session corresponding to the specified client, the pushing module 140 is further configured to:
and acquiring a second public key corresponding to the specified client, and encrypting each message between a third code and a new second code in a message queue to be synchronized of each session corresponding to the specified client by using the second public key.
After receiving the message pushed by the client, the appointed client user can decrypt each piece of information by using a private key of the appointed client user, the message header of each piece of information also comprises a standard information abstract value, and the appointed client user can judge the legality of each piece of information by comparing whether the calculated information abstract value is consistent with the standard information abstract value. Meanwhile, whether the message synchronization is missed or repeated can be judged according to whether the codes of the messages corresponding to the sessions are continuous or overlapped.
In another embodiment of the present invention, the pushing module 140 is further configured to:
and calculating the average time interval of newly added messages in a third time period (for example, the last hour) of each session in which the specified client user participates, and taking the average time interval as the second time.
The operation can set different message pushing time intervals for users with different liveness degrees, fully ensures the timeliness of message pushing, and simultaneously avoids resource waste caused by frequently pushing messages for inactive users.
In this embodiment, the pushing module 140 is further configured to:
b21, responding to a message synchronization request sent by a user based on a target client, displaying a synchronization type selection interface to the target client interface, if the user selects full synchronization based on the selection interface, displaying the session IDs of all sessions participated by the user to the target client interface, and synchronizing the corresponding message sequence to the target client based on the session ID selected by the user;
b22, if the user selects the increment synchronization based on the selection interface, displaying the session ID and the synchronization time starting point input box of all the sessions participated by the user to the target client interface, determining the fourth code of the initial message to be synchronized in the message sequence of the session ID selected by the user based on the synchronization time starting point selected by the user, and synchronizing all the messages taking the fourth code as the starting point in the message sequence of the session ID selected by the user to the target client.
When the client user needs synchronization information, either full or incremental synchronization may be selected. When the increment synchronization is selected, whether the message queue to be synchronized has the message of the fourth code or not can be judged, if yes, all the messages taking the fourth code as the starting point in the message queue to be synchronized are synchronized to the client; and if the message sequence does not exist, synchronizing all messages taking the fourth code as a starting point in the message sequence to the client.
Fig. 3 is a schematic structural diagram of an electronic device for implementing a message synchronization method according to an embodiment of the present invention.
The electronic device 1 is a device capable of automatically performing numerical calculation and/or information processing in accordance with a command set or stored in advance. The electronic device 1 may be a computer, or may be a single network server, a server group composed of a plurality of network servers, or a cloud composed of a large number of hosts or network servers based on cloud computing, where cloud computing is one of distributed computing and is a super virtual computer composed of a group of loosely coupled computers.
In the present embodiment, the electronic device 1 includes, but is not limited to, a memory 11, a processor 12, and a network interface 13, which are communicatively connected to each other through a system bus, wherein the memory 11 stores a message synchronization program 10, and the message synchronization program 10 is executable by the processor 12. Fig. 3 only shows the electronic device 1 with the components 11-13 and the message synchronization program 10, and it will be understood by those skilled in the art that the structure shown in fig. 3 does not constitute a limitation of the electronic device 1, and may comprise fewer or more components than shown, or a combination of certain components, or a different arrangement of components.
The storage 11 includes a memory and at least one type of readable storage medium. The memory provides cache for the operation of the electronic equipment 1; the readable storage medium may be a non-volatile storage medium such as flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the readable storage medium may be an internal storage unit of the electronic device 1, such as a hard disk of the electronic device 1; in other embodiments, the non-volatile storage medium may also be an external storage device of the electronic device 1, such as a plug-in hard disk provided on the electronic device 1, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like. In this embodiment, the readable storage medium of the memory 11 is generally used for storing an operating system and various application software installed in the electronic device 1, for example, codes of the message synchronization program 10 in an embodiment of the present invention. Further, the memory 11 may also be used to temporarily store various types of data that have been output or are to be output.
Processor 12 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. The processor 12 is generally configured to control the overall operation of the electronic device 1, such as performing control and processing related to data interaction or communication with other devices. In this embodiment, the processor 12 is configured to run the program code stored in the memory 11 or process data, for example, run the message synchronization program 10.
The network interface 13 may comprise a wireless network interface or a wired network interface, and the network interface 13 is used for establishing a communication connection between the electronic device 1 and a client (not shown).
Optionally, the electronic device 1 may further include a user interface, the user interface may include a Display (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface may further include a standard wired interface and a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable for displaying information processed in the electronic device 1 and for displaying a visualized user interface, among other things.
It is to be understood that the described embodiments are for purposes of illustration only and that the scope of the appended claims is not limited to such structures.
The message synchronization program 10 stored in the memory 11 of the electronic device 1 is a combination of instructions that, when executed in the processor 12, enable:
receiving session messages sent by each client, wherein the session messages comprise message headers and message contents, the message headers comprise session IDs, member IDs participating in the sessions and message sending time, the session messages are stored in message sequences corresponding to the sessions in a first database based on the session IDs and the message sending time, and each message in each message sequence is encoded;
establishing a corresponding session set for each user in a second database based on the member ID, wherein the session set comprises a message queue to be synchronized and a push record table of each session in which the corresponding user participates, and the push record table comprises a first code of the last message in the message sequence of each session in which the corresponding user participates, a second code of the last message in the message queue to be synchronized and a third code of the pushed last message;
storing newly-added messages in the message sequence of each session into a message queue to be synchronized of each session based on the first code and the second code at intervals of first time, and updating the first code and the second code to obtain a new first code and a new second code;
monitoring the online and/or offline state of each client in real time, judging whether a message needs to be pushed to a specified client at intervals of a second time when a specified client is online, pushing the message between a third code and a new second code in a message queue to be synchronized of each session corresponding to the specified client when the specified client needs to be pushed, and updating the third code in a pushing record table corresponding to the specified client to obtain the new third code.
Specifically, the processor 12 may refer to the description of the relevant steps in the embodiment corresponding to fig. 1 for a specific implementation method of the message synchronization program 10, which is not described herein again. It is emphasized that, in order to further ensure the privacy and security of the session message, the session message may also be stored in a node of a blockchain.
Further, the integrated modules/units of the electronic device 1, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. The computer readable medium may be non-volatile or non-volatile. The computer-readable medium may include: any entity or device capable of carrying said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM).
The computer-readable storage medium stores a message synchronization program 10, where the message synchronization program 10 may be executed by one or more processors, and a specific implementation of the computer-readable storage medium of the present invention is substantially the same as that of each embodiment of the message synchronization method, and is not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus, device and method can be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (9)

1. A method for message synchronization, the method comprising:
receiving a session message sent by each client, wherein the session message comprises a message header and message content, and the message header comprises a session ID, a member ID participating in the session, message sending time, and a standard information digest value ciphertext and a sender ID of the session message;
and carrying out validity verification on each session message, wherein the validity verification comprises the following steps: selecting a session message, and calculating the information abstract value of the selected session message; acquiring a first public key corresponding to the sender based on the ID of the selected session message, and decrypting a standard information digest value ciphertext of the selected session message by using the first public key to obtain a decrypted standard information digest value; and when the calculated message digest value is consistent with the decrypted standard message digest value, judging that the selected session message is legal;
storing each session message into a message sequence corresponding to each session in a first database based on the session ID and the message sending time, and coding each piece of information in each message sequence;
establishing a corresponding session set for each user in a second database based on the member ID, wherein the session set comprises a message queue to be synchronized and a push record table of each session in which the corresponding user participates, and the push record table comprises a first code of the last message in the message sequence of each session in which the corresponding user participates, a second code of the last message in the message queue to be synchronized and a third code of the pushed last message;
storing newly-added messages in the message sequence of each session into a message queue to be synchronized of each session based on the first code and the second code at intervals of first time, and updating the first code and the second code to obtain a new first code and a new second code;
monitoring the online and/or offline state of each client in real time, judging whether a message needs to be pushed to a specified client at intervals of a second time when a specified client is online, pushing the message between a third code and a new second code in a message queue to be synchronized of each session corresponding to the specified client when the specified client needs to be pushed, and updating the third code in a pushing record table corresponding to the specified client to obtain the new third code.
2. The message synchronization method of claim 1, wherein after obtaining the decrypted standard message digest value, the method further comprises:
if the calculated message digest value is not consistent with the decrypted standard message digest value, judging that the selected session message is illegal, and discarding the selected session message.
3. The message synchronization method according to claim 1, wherein before pushing the message between the third code and the new second code in the message queue to be synchronized of each session corresponding to the specified client, the method further comprises:
and acquiring a second public key corresponding to the specified client, and encrypting each message between a third code and a new second code in the message queue to be synchronized of each session corresponding to the specified client by using the second public key.
4. The message synchronization method of claim 1, wherein prior to every second time, the method further comprises:
and calculating the average time interval of each newly added message in a third time period of each session participated by the appointed client user, and taking the average time interval as the second time.
5. The message synchronization method of claim 1, wherein the method further comprises:
responding to a message synchronization request sent by a user based on a target client, displaying a synchronization type selection interface to the target client interface, if the user selects full synchronization based on the selection interface, displaying session IDs of all sessions participated by the user to the target client interface, and synchronizing a corresponding message sequence to the target client based on the session ID selected by the user;
and if the user selects incremental synchronization based on the selection interface, displaying the session IDs of all sessions participated by the user and a synchronization time starting point input box to the target client interface, determining a fourth code of an initial message to be synchronized in the message sequence of the session ID selected by the user based on the synchronization time starting point selected by the user, and synchronizing all messages taking the fourth code as a starting point in the message sequence of the session ID selected by the user to the target client.
6. A message synchronization apparatus, the apparatus comprising:
the system comprises an encoding module, a sending module and a receiving module, wherein the encoding module is used for receiving session messages sent by each client, each session message comprises a message header and message content, and the message header comprises a session ID, member IDs participating in the session, message sending time, and a standard information digest value ciphertext and a sender ID of the session message;
and carrying out validity verification on each session message, including: selecting a session message, and calculating the information abstract value of the selected session message; acquiring a first public key corresponding to the sender based on the ID of the sender of the selected session message, and decrypting a standard information digest value ciphertext of the selected session message by using the first public key to obtain a decrypted standard information digest value; and when the calculated message digest value is consistent with the decrypted standard message digest value, judging that the selected session message is legal;
storing each session message into a message sequence corresponding to each session in a first database based on the session ID and the message sending time, and coding each piece of information in each message sequence;
the establishing module is used for establishing a corresponding session set for each user in a second database based on the member ID, wherein the session set comprises a message queue to be synchronized and a pushing record table of each session in which the corresponding user participates, and the pushing record table comprises a first code of the last message in the message sequence of each session in which the corresponding user participates, a second code of the last message in the message queue to be synchronized and a third code of the pushed last message;
the updating module is used for storing newly-added messages in the message sequence of each session into a message queue to be synchronized of each session based on the first code and the second code at intervals of first time, and updating the first code and the second code to obtain a new first code and a new second code;
the pushing module is used for monitoring the online and/or offline state of each client in real time, judging whether a message needs to be pushed to a specified client at intervals of a second time when a specified client is online, pushing the message between a third code and a new second code in a message queue to be synchronized of each session corresponding to the specified client when the message needs to be pushed, and updating the third code in a pushing record table corresponding to the specified client to obtain the new third code.
7. The message synchronization apparatus of claim 6, wherein the push module is further to:
and calculating the average time interval of each newly added message in a third time period of each session participated by the appointed client user, and taking the average time interval as the second time.
8. An electronic device, characterized in that the electronic device comprises:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a message synchronization program executable by the at least one processor to enable the at least one processor to perform the message synchronization method of any of claims 1 to 5.
9. A computer-readable storage medium having stored thereon a message synchronization program executable by one or more processors to implement the message synchronization method of any one of claims 1 to 5.
CN202011468434.6A 2020-12-14 2020-12-14 Message synchronization method and device, electronic equipment and readable storage medium Active CN112492048B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011468434.6A CN112492048B (en) 2020-12-14 2020-12-14 Message synchronization method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011468434.6A CN112492048B (en) 2020-12-14 2020-12-14 Message synchronization method and device, electronic equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN112492048A CN112492048A (en) 2021-03-12
CN112492048B true CN112492048B (en) 2022-05-20

Family

ID=74916803

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011468434.6A Active CN112492048B (en) 2020-12-14 2020-12-14 Message synchronization method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN112492048B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113645123A (en) * 2021-08-03 2021-11-12 福建天泉教育科技有限公司 Message storage method and terminal
CN114286293B (en) * 2021-12-22 2023-03-14 广东悦伍纪网络技术有限公司 Message push management method, device, system, computer equipment and storage medium
CN115037758B (en) * 2022-04-27 2024-07-19 浪潮通信技术有限公司 Message synchronization method and server

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016008337A1 (en) * 2014-07-16 2016-01-21 Tencent Technology (Shenzhen) Company Limited Method and system for synchronizing instant messages between multiple clients
CN105471716A (en) * 2015-12-17 2016-04-06 网易(杭州)网络有限公司 Method for achieving message synchronization across clients, user equipment and server
CN110365739A (en) * 2019-06-05 2019-10-22 平安科技(深圳)有限公司 Message synchronization method, apparatus, computer installation and computer readable storage medium
CN111782829A (en) * 2020-05-21 2020-10-16 香港乐蜜有限公司 Instant messaging session message processing method and device and electronic equipment

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030021416A1 (en) * 2001-07-26 2003-01-30 International Business Machines Corporation Encrypting a messaging session with a symmetric key
CN109600302A (en) * 2018-11-27 2019-04-09 金瓜子科技发展(北京)有限公司 A kind of method, apparatus orderly communicated, storage medium and electronic equipment
CN110311895B (en) * 2019-05-28 2022-07-08 深圳壹账通智能科技有限公司 Session permission verification method and system based on identity authentication and electronic equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016008337A1 (en) * 2014-07-16 2016-01-21 Tencent Technology (Shenzhen) Company Limited Method and system for synchronizing instant messages between multiple clients
CN105471716A (en) * 2015-12-17 2016-04-06 网易(杭州)网络有限公司 Method for achieving message synchronization across clients, user equipment and server
CN110365739A (en) * 2019-06-05 2019-10-22 平安科技(深圳)有限公司 Message synchronization method, apparatus, computer installation and computer readable storage medium
CN111782829A (en) * 2020-05-21 2020-10-16 香港乐蜜有限公司 Instant messaging session message processing method and device and electronic equipment

Also Published As

Publication number Publication date
CN112492048A (en) 2021-03-12

Similar Documents

Publication Publication Date Title
CN112492048B (en) Message synchronization method and device, electronic equipment and readable storage medium
CN110400221B (en) Data processing method, system, storage medium and computer equipment
CN111163182B (en) Block chain-based device registration method and apparatus, electronic device, and storage medium
CN111698088B (en) Key alternation method, key alternation device, electronic equipment and medium
CN111556120B (en) Data processing method and device based on block chain, storage medium and equipment
CN111831485B (en) Data recovery method, device, electronic equipment and medium
CN112988674B (en) Big data file processing method and device, computer equipment and storage medium
CN110830242A (en) Key generation and management method and server
CN114389889B (en) File full life cycle management method and device based on block chain technology
CN109213901B (en) Data synchronization method, device, equipment and medium of block chain
CN111597567B (en) Data processing method, data processing device, node equipment and storage medium
CN112948851A (en) User authentication method, device, server and storage medium
CN111488372A (en) Data processing method, device and storage medium
CN114124502B (en) Message transmission method, device, equipment and medium
CN113055380A (en) Message processing method and device, electronic equipment and medium
CN110851466A (en) Visualization method and device for block chain system
CN112182109A (en) Distributed data coding storage method based on block chain and electronic equipment
CN110941672A (en) Household registration management method, device, equipment and storage medium
CN114826736A (en) Information sharing method, device, equipment and storage medium
CN110618989B (en) Information processing method, information processing device and related products
CN113590703A (en) ES data importing method and device, electronic equipment and readable storage medium
CN112286703B (en) User classification method and device, client device and readable storage medium
CN116155491B (en) Symmetric key synchronization method of security chip and security chip device
CN112182598B (en) Public sample ID identification method, public sample ID identification device, server and readable storage medium
CN114726644A (en) Data transmission method, device and equipment based on secret key encryption and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant