CN113965580A - Method and apparatus for synchronizing messages - Google Patents
Method and apparatus for synchronizing messages Download PDFInfo
- Publication number
- CN113965580A CN113965580A CN202010605744.1A CN202010605744A CN113965580A CN 113965580 A CN113965580 A CN 113965580A CN 202010605744 A CN202010605744 A CN 202010605744A CN 113965580 A CN113965580 A CN 113965580A
- Authority
- CN
- China
- Prior art keywords
- message
- sequence number
- current message
- missing
- server
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 39
- 230000004044 response Effects 0.000 claims description 18
- 238000004590 computer program Methods 0.000 claims description 10
- 230000001360 synchronised effect Effects 0.000 claims description 7
- 230000000977 initiatory effect Effects 0.000 abstract description 2
- 238000010586 diagram Methods 0.000 description 10
- 238000004891 communication Methods 0.000 description 7
- 230000006870 function Effects 0.000 description 5
- 230000003287 optical effect Effects 0.000 description 4
- 230000008569 process Effects 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 238000007405 data analysis Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 239000013589 supplement Substances 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1095—Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
- H04L67/141—Setup of application sessions
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer And Data Communications (AREA)
Abstract
The embodiment of the disclosure provides a method and a device for synchronizing messages. The method for synchronizing the messages comprises the following steps: the method comprises the steps of responding to the fact that a preset trigger event occurs, sending a first request for obtaining a current message to a server, receiving the current message sent by the server and a sequence number of the current message, obtaining a sequence number of a last message from a local message sequence, determining a missing sequence number based on the sequence number of the current message and the sequence number of the last message, sending the first request for obtaining a message corresponding to the missing sequence number to the server, receiving the missing message sent by the server based on the first request, synchronizing the missing message and the current message into the local message sequence, sending the first request for obtaining the current message to the server by determining the occurrence of the preset trigger event, actively initiating the request under the condition that a trigger condition is met, obtaining the current message in time, and improving timeliness and efficiency of message synchronization.
Description
Technical Field
The embodiment of the disclosure relates to the technical field of computers, in particular to a method and a device for synchronizing messages.
Background
In this digital age with rapid development and continuous update, a client sends various requests to a server according to the operation of a user, and then the server pushes corresponding messages to the client according to the requests sent by the client, but the client easily receives messages sent by the server because the client is not online or abnormal in a network.
Disclosure of Invention
The embodiment of the disclosure provides a method and a device for synchronizing messages.
In a first aspect, an embodiment of the present disclosure provides a method for synchronizing messages, where the method includes: responding to the occurrence of a preset trigger event, and sending a first request for acquiring the current message to a server; receiving a current message sent by a server based on a first request and a sequence number of the current message, and acquiring the sequence number of the last message from a local message sequence; determining a missing sequence number based on the sequence number of the current message and the sequence number of the last message, and sending a second request for acquiring the missing message corresponding to the missing sequence number to the server; and the receiving server synchronizes the missing message and the current message into the local message sequence based on the missing message sent by the second request.
In some embodiments, the triggering event comprises at least one of: and starting the application, switching the network from the unconnected state to the connected state and reaching the time of the whole point.
In some embodiments, determining the missing sequence number based on the sequence number of the current message and the sequence number of the last message comprises: judging whether the sequence number of the current message and the sequence number of the last message are continuous or not; in response to determining that the sequence number of the current message is not consecutive with the sequence number of the last message, a missing sequence number is determined based on the sequence number of the current message and the sequence number of the last message.
In some embodiments, the method further comprises: the current message is synchronized into the sequence of local messages in response to determining that the sequence number of the current message is consecutive with the sequence number of the last message.
In some embodiments, receiving the current message and the sequence number of the current message sent by the server based on the first request includes receiving the current message and the sequence number of the current message sent by the server based on the first request over a long connection established with the server.
In a second aspect, an embodiment of the present disclosure provides an apparatus for synchronizing messages, the apparatus including: the triggering unit is configured to respond to the fact that a preset triggering event occurs, and send a first request for obtaining the current message to the server; the acquiring unit is configured to receive a current message sent by the server based on the first request and a sequence number of the current message, and acquire a sequence number of the last message from a local message sequence; the determining unit is configured to determine a missing sequence number based on the sequence number of the current message and the sequence number of the last message, and send a second request for acquiring the missing message corresponding to the missing sequence number to the server; and the synchronization unit is configured to receive the missing message sent by the server based on the second request and synchronize the missing message and the current message into the local message sequence.
In some embodiments, the triggering event comprises at least one of: and starting the application, switching the network from the unconnected state to the connected state and reaching the time of the whole point.
In some embodiments, the determining unit comprises: the judging module is configured to judge whether the sequence number of the current message is continuous with the sequence number of the last message; a determination module configured to determine a missing sequence number based on the sequence number of the current message and the sequence number of the last message in response to determining that the sequence number of the current message is not consecutive with the sequence number of the last message.
In some embodiments, the synchronization unit is further configured to: the current message is synchronized into the sequence of local messages in response to determining that the sequence number of the current message is consecutive with the sequence number of the last message.
In some embodiments, the obtaining unit is further configured to: and receiving the current message sent by the server based on the first request and the sequence number of the current message through the long connection established with the server.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including: one or more processors; a storage device having one or more programs stored thereon; when executed by one or more processors, cause the one or more processors to implement a method of synchronizing messages as described in any one of the embodiments of the first aspect.
In a fourth aspect, embodiments of the present disclosure provide a computer-readable medium on which a computer program is stored, which, when executed by a processor, implements the method of synchronizing messages as described in any of the embodiments of the first aspect.
The method and the device for synchronizing the messages, which are provided by the embodiment of the disclosure, firstly respond to the occurrence of the preset trigger event, send a first request for acquiring the current message to the server, then receive the current message sent by the server based on the first request and the sequence number of the current message, acquire the sequence number of the last message from the local message sequence, determine the missing sequence number based on the sequence number of the current message and the sequence number of the last message, send a second request for acquiring the message corresponding to the missing sequence number to the server, receive the missing message sent by the server based on the second request, synchronize the missing message and the current message into the local message sequence, send the first request for acquiring the current message to the server by determining the occurrence of the preset trigger event, can actively initiate the request and can acquire the current message in time under the condition that the trigger condition is met, the timeliness and the efficiency of message synchronization are improved, all messages sent by the server can be guaranteed to be received by the client, missing conditions cannot occur, meanwhile, missing sequence numbers can be determined according to the comparison sequence numbers, the missing messages are made up through active requests, and the message synchronization of the client and the server is more convenient and accurate.
Drawings
Other features, objects and advantages of the disclosure will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which one embodiment of the present disclosure may be applied;
FIG. 2 is a flow diagram of one embodiment of a method of synchronizing messages, according to an embodiment of the present disclosure;
FIG. 3 is a schematic diagram of one application scenario of a method of synchronizing messages according to an embodiment of the present disclosure;
FIG. 4 is an exemplary flow chart for determining missing sequence numbers according to embodiments of the present disclosure;
FIG. 5 is a block diagram of one embodiment of an apparatus to synchronize messages, according to an embodiment of the present disclosure;
FIG. 6 is a schematic structural diagram of an electronic device suitable for use in implementing embodiments of the present disclosure.
Detailed Description
The present disclosure is described in further detail below with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant disclosure and are not limiting of the disclosure. It should be noted that, for the convenience of description, only the parts relevant to the related disclosure are shown in the drawings.
It should be noted that, in the present disclosure, the embodiments and features of the embodiments may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates an exemplary system architecture 100 of a method of synchronizing messages and an apparatus of synchronizing messages to which embodiments of the present disclosure may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 104, 105, a network 106, and servers 101, 102, 103. The network 106 serves as a medium for providing communication links between the terminal devices 104, 105 and the servers 101, 102, 103. Network 106 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the servers 101, 102, 103 via the network 106 via the terminal devices 104, 105 to receive or transmit information or the like. The end devices 104, 105 may have installed thereon various applications such as data analysis applications, data processing applications, instant messaging tools, social platform software, search-type applications, shopping-type applications, and the like.
The terminal devices 104, 105 may be hardware or software. When the terminal device is hardware, it may be various electronic devices having a display screen and supporting communication with the server, including but not limited to a smart phone, a tablet computer, a laptop portable computer, a desktop computer, and the like. When the terminal device is software, the terminal device can be installed in the electronic devices listed above. It may be implemented as multiple pieces of software or software modules, or as a single piece of software or software module. And is not particularly limited herein.
The servers 101, 102, 103 may be servers that provide various services, such as background servers that receive requests sent by terminal devices with which communication connections are established. The background server can receive and analyze the request sent by the terminal device, and generate a processing result.
The server may be hardware or software. When the server is hardware, it may be various electronic devices that provide various services to the terminal device. When the server is software, it may be implemented as a plurality of software or software modules for providing various services to the terminal device, or may be implemented as a single software or software module for providing various services to the terminal device. And is not particularly limited herein.
It should be noted that the method for synchronizing messages provided by the embodiments of the present disclosure may be performed by the terminal devices 104 and 105. Accordingly, means for synchronizing messages may be provided in the terminal devices 104, 105.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to fig. 2, a flow 200 of one embodiment of a method of synchronizing messages in accordance with the present disclosure is shown. The method for synchronizing messages comprises the following steps:
Wherein the triggering event comprises at least one of: the application is started, the network is switched from the unconnected state to the connected state, the time of the whole point is reached, the trigger time can represent the time for actively initiating a request for acquiring a new message to the server, and the time can be determined according to the actual situation, which is not specifically limited by the application.
In this step, the execution body on which the method for synchronizing messages runs may detect the state of the application by, when it is determined that the state of the application is the start state, determining that a preset trigger event occurs; the method can determine that a preset trigger event occurs when the network state is determined to be switched from the unconnected state to the connected state by detecting the network state; the preset trigger event can be determined to occur when the current time is determined to reach the integral point time through detecting the time. When the occurrence of a preset trigger event is determined, the execution main body actively sends a first request to the server and acquires the current message from the server. After receiving the first request sent by the execution main body, the server acquires a message sequence corresponding to the first request according to the first request, edits a corresponding sequence number for each message according to the arrangement sequence of each message in the message sequence, generates a message sequence with a sequence number, and then sends each message with the sequence number to the execution main body in sequence. The server side searches according to the first request message sequence with the sequence number, determines the last message sent to the execution main body, takes the next message of the last message sent as the current message, and sends the current message and the sequence number of the current message to the execution main body.
In this step, an execution body on which the method for synchronizing messages operates receives a current message sent by a server according to a first request and a sequence number of the current message, and obtains a sequence number of a last message from a local message sequence, where the local message sequence includes messages sent by the server and ordered before the current message and a sequence number corresponding to each message, and the execution body stores the received messages and the sequence numbers of the messages locally, and generates the received messages into the local message sequence.
As an example, a server receives a request sent by a terminal and acquires a plurality of messages corresponding to the request, the plurality of messages are arranged in sequence into a message sequence, that is, a message a, a message B, a message C, and a message D, and the server edits sequence numbers for the message a, the message B, the message C, and the message D in sequence, that is, a sequence number corresponding to the message a is 1, a sequence number corresponding to the message B is 2, a sequence number corresponding to the message C is 3, and a sequence number corresponding to the message D is 4. And the server side sequentially sends the message A and the sequence number 1 corresponding to the message A to the terminal, and then continuously sends the message B and the sequence number 2 corresponding to the message B until the plurality of messages are sent.
In some optional implementation manners of this embodiment, the execution body may establish a long connection with the server, for example, ajax polling, long poll from long poll, iframe long connection, and WebSocket. The execution main body can send a request through a long connection established with the server side, and receive a current message sent by the server side and a sequence number of the current message.
In the implementation mode, the long chain is established between the client and the server, and when the client is online, the client can receive the message sent by the server without establishing connection between the client and the server every time.
In this step, after obtaining the sequence number of the current message and the sequence number of the last message in the local message sequence, the execution main body compares the sequence number of the current message with the sequence number of the last message to determine the missing sequence number, and if the message corresponding to the missing sequence number is the missing message, for example, if the sequence number of the current message is 4 and the sequence number of the last message in the local message sequence is 2, it may be determined that the missing sequence number is 3 and the message corresponding to the sequence number 3 is the missing message. After determining the missing sequence number, the execution main body sends a second request to the server, where the second request is used to obtain a missing message corresponding to the missing sequence number from the server, for example, if the execution main body determines that the missing sequence number is 3, the execution main body sends a request to the server to obtain a message corresponding to the sequence number 3.
And step 240, the receiving server synchronizes the missing message and the current message into the local message sequence based on the missing message sent by the second request.
In this step, the execution main body sends a second request for obtaining the missing message corresponding to the missing sequence number to the server, and after receiving the second request sent by the execution main body, the server searches for the missing message according to the missing sequence number in the second request, and sends the searched missing message to the execution main body. And the execution main body receives the missing message sent by the server, supplements the missing message to the corresponding position in the local message sequence, and synchronizes the current message to the local message sequence. The sequence numbers of all the messages in the local message sequence are consecutive, and the sequence number of the last message is updated to the current message, and the sequence number of the last message is updated to the sequence number of the current message.
With continuing reference to fig. 3, fig. 3 is a schematic diagram of an application scenario of the method of synchronizing messages according to the present embodiment. In the application scenario of fig. 3, the terminal 301 detects the time and determines that the time reaches the hour, and sends a first request for acquiring the current message to the server 302. The message sequence with sequence number in the server 302 includes a message a with sequence number 1, a message B with sequence number 2, a message C with sequence number 3, and a message D with sequence number 4, and the server 302 determines that the current message is the message D with sequence number 4 in the message sequence with sequence number according to the first request, and sends the message D with sequence number 4 to the terminal 301. The terminal 301 has received that the server 302 sent message a with sequence number 1 and message B with sequence number 2 and stored message a with sequence number 1 and message B with sequence number 2 in the local message sequence. Then, the terminal 301 receives the message D with the sequence number of 4, searches the sequence number of the last message from the local message sequence, and determines that the last message is the message B and the sequence number of the message B is 2. Then, the terminal 301 determines that the missing sequence number is 3 by comparing the sequence number 4 with the sequence number 2, and sends a request for acquiring a message corresponding to the sequence number 3 to the server 302. After receiving the request for acquiring the message with the sequence number 3 sent by the terminal 301, the server 302 searches the message with the sequence number 3 in the message sequence with the sequence number, determines the message C with the sequence number 3, and sends the message C with the sequence number 3 to the terminal 301. The terminal 301 synchronizes message C with sequence number 3 and message D with sequence number 4 into the local message sequence.
The method for synchronizing the messages, provided by the embodiment of the disclosure, first sends a first request for acquiring the current message to the server in response to the occurrence of a predetermined trigger event, then receives the current message sent by the server and the sequence number of the current message, acquires the sequence number of the last message from a local message sequence, determines a missing sequence number based on the sequence number of the current message and the sequence number of the last message, sends a second request for acquiring the message corresponding to the missing sequence number to the server, receives the missing message sent by the server based on the second request, synchronizes the missing message and the current message to the local message sequence, sends the first request for acquiring the current message to the server by determining the occurrence of the predetermined trigger event, can initiatively initiate the request under the condition that the trigger condition is satisfied, can acquire the current message in time, and improves the timeliness and efficiency of message synchronization, and all messages sent by the server can be guaranteed to be received by the client, missing conditions can not occur, meanwhile, missing sequence numbers can be determined according to the comparison sequence numbers, the missing messages are made up through active requests, and the messages of the client and the server are enabled to be synchronized more conveniently and more accurately.
In some optional implementations of this embodiment, the step 230 of determining the missing sequence number based on the sequence number of the current message and the sequence number of the last message may be performed according to the following flow 400:
In this step, after acquiring the sequence number of the last message in the local message sequence, the execution main body compares the sequence number of the current message with the sequence number of the last message, and determines whether the sequence number of the current message is continuous with the sequence number of the last message.
When it is determined that the sequence number of the current message is not consecutive with the sequence number of the last message, step 420 is performed, and in response to determining that the sequence number of the current message is not consecutive with the sequence number of the last message, a missing sequence number is determined based on the sequence number of the current message and the sequence number of the last message.
In this step, the execution main body determines that the sequence number of the current message is not consecutive to the sequence number of the last message by comparing the sequence number of the current message with the sequence number of the last message, and then determines a missing sequence number between the sequence number of the current message and the sequence number of the last message according to the sequence number of the current message and the sequence number of the last message.
As an example, the sequence number of the current message received by the terminal is 4, the sequence number of the last message obtained is 2, and by comparing 4 with 2, it is determined that 4 is not consecutive to 2, thereby determining that the missing sequence number is 3.
Upon determining that the sequence number of the current message is consecutive with the sequence number of the last message, step 430 is performed to synchronize the current message into the sequence of local messages in response to determining that the sequence number of the current message is consecutive with the sequence number of the last message.
In this step, the execution main body compares the sequence number of the current message with the sequence number of the last message, and determines that the sequence number of the current message is continuous with the sequence number of the last message, and then determines that the messages received by the execution main body are not missing, synchronizes the current message into the local message sequence, updates the last message of the local message sequence to the current message, and updates the sequence number of the last message to the sequence number of the current message.
In the implementation mode, the sequence number of the current message is compared with the sequence number of the last message in the local message sequence, and whether the sequence number of the current message and the sequence number of the last message in the local message sequence are continuous or not is determined, so that whether the received message is missed or not is determined, and the continuity of the received message is ensured.
With further reference to fig. 5, as an implementation of the methods illustrated in the above figures, the present disclosure provides one embodiment of an apparatus for synchronizing messages. This device embodiment corresponds to the method embodiment shown in fig. 2.
As shown in fig. 5, the apparatus 500 for synchronizing messages of the present embodiment may include: a triggering unit 510 configured to send, in response to determining that a preset triggering event occurs, a first request for acquiring a current message to a server; an obtaining unit 520, configured to receive a current message sent by the server based on the first request and a sequence number of the current message, and obtain a sequence number of a last message from the local message sequence; a determining unit 530 configured to determine a missing sequence number based on the sequence number of the current message and the sequence number of the last message, and send a second request for obtaining the missing message corresponding to the missing sequence number to the server; and a synchronizing unit 540 configured to receive the missing message sent by the server based on the second request, and synchronize the missing message and the current message into the local message sequence.
In some optional implementations of this implementation, the triggering event includes at least one of: and starting the application, switching the network from the unconnected state to the connected state and reaching the time of the whole point.
In some optional implementations of this implementation, the determining unit 530 includes: the judging module is configured to judge whether the sequence number of the current message is continuous with the sequence number of the last message; a determination module configured to determine a missing sequence number based on the sequence number of the current message and the sequence number of the last message in response to determining that the sequence number of the current message is not consecutive with the sequence number of the last message.
In some optional implementations of this implementation, the synchronization unit 540 is further configured to: the current message is synchronized into the sequence of local messages in response to determining that the sequence number of the current message is consecutive with the sequence number of the last message.
In some optional implementations of this implementation, the obtaining unit 520 is further configured to: and receiving the current message sent by the server based on the first request and the sequence number of the current message through the long connection established with the server.
The device provided by the above embodiment of the present disclosure, first, in response to determining that a preset trigger event occurs, sends a first request for obtaining a current message to a server, then receives the current message sent by the server based on the first request and a sequence number of the current message, and obtains a sequence number of a last message from a local message sequence, determines a missing sequence number based on the sequence number of the current message and the sequence number of the last message, and sends a second request for obtaining a message corresponding to the missing sequence number to the server, receives the missing message sent by the server based on the second request, synchronizes the missing message and the current message into the local message sequence, sends the first request for obtaining the current message to the server by determining that the preset trigger event occurs, can actively initiate a request under the condition that a trigger condition is satisfied, can obtain the current message in time, and improve timeliness and efficiency of message synchronization, and all messages sent by the server can be guaranteed to be received by the client, missing conditions can not occur, meanwhile, missing sequence numbers can be determined according to the comparison sequence numbers, the missing messages are made up through active requests, and the messages of the client and the server are enabled to be synchronized more conveniently and more accurately.
As shown in fig. 6, electronic device 600 may include a processing means (e.g., central processing unit, graphics processor, etc.) 601 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM603, various programs and data necessary for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Generally, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 6 illustrates an electronic device 600 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided. Each block shown in fig. 6 may represent one device or may represent multiple devices as desired.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 609, or may be installed from the storage means 608, or may be installed from the ROM 602. The computer program, when executed by the processing device 601, performs the above-described functions defined in the methods of embodiments of the present disclosure.
It should be noted that the computer readable medium of the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In embodiments of the present disclosure, however, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: responding to the occurrence of a preset trigger event, and sending a first request for acquiring the current message to a server; receiving a current message sent by a server based on a first request and a sequence number of the current message, and acquiring the sequence number of the last message from a local message sequence; determining a missing sequence number based on the sequence number of the current message and the sequence number of the last message, and sending a second request for acquiring the missing message corresponding to the missing sequence number to the server; and the receiving server synchronizes the missing message and the current message into the local message sequence based on the missing message sent by the second request.
Computer program code for carrying out operations for embodiments of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and including conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a triggering unit, an obtaining unit, a determining unit, and a synchronizing unit. The names of these units do not form a limitation to the unit itself in some cases, for example, the obtaining unit may also be described as "a unit that receives the current message sent by the server and the sequence number of the current message, and obtains the sequence number of the last message from the local message sequence".
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the embodiments of the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is made without departing from the inventive concept as defined above. For example, the above features and (but not limited to) technical features with similar functions disclosed in the embodiments of the present disclosure are mutually replaced to form the technical solution.
Claims (12)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010605744.1A CN113965580A (en) | 2020-06-29 | 2020-06-29 | Method and apparatus for synchronizing messages |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010605744.1A CN113965580A (en) | 2020-06-29 | 2020-06-29 | Method and apparatus for synchronizing messages |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN113965580A true CN113965580A (en) | 2022-01-21 |
Family
ID=79459099
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202010605744.1A Pending CN113965580A (en) | 2020-06-29 | 2020-06-29 | Method and apparatus for synchronizing messages |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN113965580A (en) |
Citations (14)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CA2452916A1 (en) * | 2003-01-03 | 2004-07-03 | Microsoft Corporation | System and method for improved synchronization between a server and a client |
| CN101511042A (en) * | 2009-03-23 | 2009-08-19 | 中兴通讯股份有限公司 | Data synchronization method and device |
| US20110099436A1 (en) * | 2009-10-22 | 2011-04-28 | International Business Machines Corporation | Expedited transaction failure handling by leveraging a reliable message transport protocol to assist detection of discarded processing |
| CN103873527A (en) * | 2012-12-17 | 2014-06-18 | 联想(北京)有限公司 | Data processing method, electronic equipment and server |
| CN104683243A (en) * | 2013-11-26 | 2015-06-03 | 华为技术有限公司 | A data processing method, device and system |
| CN106161190A (en) * | 2015-04-02 | 2016-11-23 | 北大方正集团有限公司 | Point-to-point instant communicating method |
| CN107491356A (en) * | 2017-08-28 | 2017-12-19 | 广州市百果园信息技术有限公司 | Message treatment method, terminal device and server based on sequence number |
| CN108810116A (en) * | 2018-05-29 | 2018-11-13 | Oppo广东移动通信有限公司 | Message treatment method and Related product |
| CN108848024A (en) * | 2018-07-25 | 2018-11-20 | 深圳市比特熊科技有限公司 | message synchronization method, system and device |
| CN110008037A (en) * | 2019-02-28 | 2019-07-12 | 北京达佳互联信息技术有限公司 | Message treatment method, device and storage medium |
| US20190238605A1 (en) * | 2018-01-31 | 2019-08-01 | Salesforce.Com, Inc. | Verification of streaming message sequence |
| CN110311969A (en) * | 2019-06-27 | 2019-10-08 | 深圳市丰巢科技有限公司 | Express delivery information push method, device, server and storage medium |
| CN111162880A (en) * | 2019-12-26 | 2020-05-15 | 上海米哈游天命科技有限公司 | Data transmission method, device, equipment and storage medium |
| CN111193792A (en) * | 2019-12-27 | 2020-05-22 | 北京指掌易科技有限公司 | Message transmission method and device, electronic equipment and storage medium |
-
2020
- 2020-06-29 CN CN202010605744.1A patent/CN113965580A/en active Pending
Patent Citations (14)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CA2452916A1 (en) * | 2003-01-03 | 2004-07-03 | Microsoft Corporation | System and method for improved synchronization between a server and a client |
| CN101511042A (en) * | 2009-03-23 | 2009-08-19 | 中兴通讯股份有限公司 | Data synchronization method and device |
| US20110099436A1 (en) * | 2009-10-22 | 2011-04-28 | International Business Machines Corporation | Expedited transaction failure handling by leveraging a reliable message transport protocol to assist detection of discarded processing |
| CN103873527A (en) * | 2012-12-17 | 2014-06-18 | 联想(北京)有限公司 | Data processing method, electronic equipment and server |
| CN104683243A (en) * | 2013-11-26 | 2015-06-03 | 华为技术有限公司 | A data processing method, device and system |
| CN106161190A (en) * | 2015-04-02 | 2016-11-23 | 北大方正集团有限公司 | Point-to-point instant communicating method |
| CN107491356A (en) * | 2017-08-28 | 2017-12-19 | 广州市百果园信息技术有限公司 | Message treatment method, terminal device and server based on sequence number |
| US20190238605A1 (en) * | 2018-01-31 | 2019-08-01 | Salesforce.Com, Inc. | Verification of streaming message sequence |
| CN108810116A (en) * | 2018-05-29 | 2018-11-13 | Oppo广东移动通信有限公司 | Message treatment method and Related product |
| CN108848024A (en) * | 2018-07-25 | 2018-11-20 | 深圳市比特熊科技有限公司 | message synchronization method, system and device |
| CN110008037A (en) * | 2019-02-28 | 2019-07-12 | 北京达佳互联信息技术有限公司 | Message treatment method, device and storage medium |
| CN110311969A (en) * | 2019-06-27 | 2019-10-08 | 深圳市丰巢科技有限公司 | Express delivery information push method, device, server and storage medium |
| CN111162880A (en) * | 2019-12-26 | 2020-05-15 | 上海米哈游天命科技有限公司 | Data transmission method, device, equipment and storage medium |
| CN111193792A (en) * | 2019-12-27 | 2020-05-22 | 北京指掌易科技有限公司 | Message transmission method and device, electronic equipment and storage medium |
Non-Patent Citations (2)
| Title |
|---|
| 仲玮;吴晋;孙鹏;: "基于XMPP协议的校园实时消息推送系统的研究", 武汉大学学报(理学版), no. 1 * |
| 武荷岚;胡炳元;陈必多;: "弹性堆叠系统中控制数据同步的方法", 华东师范大学学报(自然科学版), no. 02 * |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN110609872B (en) | Method and apparatus for synchronizing node data | |
| CN109995877B (en) | Information pushing method and device | |
| CN111901341B (en) | State synchronization method and device | |
| CN111309747A (en) | Data synchronization method, system and device | |
| CN110069919B (en) | Information acquisition method and device | |
| CN111813685B (en) | Automatic test method and device | |
| CN111694757A (en) | Application program testing method and device, electronic equipment and computer readable storage medium | |
| CN113326013A (en) | Information interaction method and device and electronic equipment | |
| CN112732302B (en) | Application configuration update method, device and electronic device | |
| CN110704760B (en) | Data processing method and apparatus | |
| CN111309366B (en) | Method, device, medium and electronic equipment for managing registration core | |
| CN111324470B (en) | Methods and devices for generating information | |
| US20140370814A1 (en) | Connecting wireless devices | |
| CN114253520B (en) | Interface code generation method and device | |
| CN111291011B (en) | File synchronization method and device, electronic equipment and readable storage medium | |
| CN112732728A (en) | Data synchronization method and system | |
| CN113965580A (en) | Method and apparatus for synchronizing messages | |
| CN112068853A (en) | Cross-project synchronous updating method and device | |
| CN110750424A (en) | Resource inspection method and device | |
| CN113407229B (en) | Method and device for generating offline scripts | |
| CN111290873B (en) | Fault processing method and device | |
| CN116975012A (en) | File synchronization method, file updating method, device, electronic equipment and medium | |
| CN108811036B (en) | Method and apparatus for displaying wireless access point information | |
| CN114417905B (en) | Information transmission method, apparatus, device and computer readable medium | |
| CN115914396B (en) | Call link generation method, device, electronic equipment and computer readable 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 | ||
| RJ01 | Rejection of invention patent application after publication | ||
| RJ01 | Rejection of invention patent application after publication |
Application publication date: 20220121 |