CN116743693A - Message synchronization method, electronic equipment and storage medium - Google Patents

Message synchronization method, electronic equipment and storage medium Download PDF

Info

Publication number
CN116743693A
CN116743693A CN202211305813.2A CN202211305813A CN116743693A CN 116743693 A CN116743693 A CN 116743693A CN 202211305813 A CN202211305813 A CN 202211305813A CN 116743693 A CN116743693 A CN 116743693A
Authority
CN
China
Prior art keywords
message
synchronization
node
synchronous
event
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.)
Granted
Application number
CN202211305813.2A
Other languages
Chinese (zh)
Other versions
CN116743693B (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.)
Honor Device Co Ltd
Original Assignee
Honor Device 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 Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202211305813.2A priority Critical patent/CN116743693B/en
Publication of CN116743693A publication Critical patent/CN116743693A/en
Application granted granted Critical
Publication of CN116743693B publication Critical patent/CN116743693B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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]
    • H04L51/043Real-time or near real-time messaging, e.g. instant messaging [IM] using or handling presence information
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/542Event management; Broadcasting; Multicasting; Notifications
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/80Services using short range communication, e.g. near-field communication [NFC], radio-frequency identification [RFID] or low energy communication
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W84/00Network topologies
    • H04W84/02Hierarchically pre-organised networks, e.g. paging networks, cellular networks, WLAN [Wireless Local Area Network] or WLL [Wireless Local Loop]
    • H04W84/10Small scale networks; Flat hierarchical networks
    • H04W84/12WLAN [Wireless Local Area Networks]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/547Messaging middleware
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Mobile Radio Communication Systems (AREA)
  • Telephonic Communication Services (AREA)

Abstract

The application relates to a message synchronization method, an electronic device and a storage medium. A preset buffer queue can be newly added in the electronic equipment. And caching the message node of the synchronous message to be sent to the wearable device in the cache queue, wherein the message node records the retry times of the synchronous message. When the electronic device processes the first synchronization message recorded by the first message node in the cache queue, it may be determined whether the retry number recorded by the first message node is less than a preset retry number threshold. If the number of retries recorded by the first message node is smaller than a preset threshold number of retries, a synchronization request of the first synchronization message can be added to the sending queue. Through the newly added cache queue, a cache retry mechanism of the synchronous message can be realized, and the probability of accurately transmitting the synchronous message between the electronic equipment and the wearable equipment can be effectively improved.

Description

Message synchronization method, electronic equipment and storage medium
Technical Field
The present application relates to the field of communications technologies, and in particular, to a message synchronization method, an electronic device, and a storage medium.
Background
Wearable devices (such as electronic watches, electronic bracelets, etc.) are popular in the smart product market in recent years, and can be directly worn on the body, so that brand new experience can be brought to users. The wearable device may interact with the terminal, and synchronization of messages may be involved in the interaction process, for example, the user terminal and the wearable device synchronize and prompt for messages such as application notifications, system notifications, incoming call information, short messages, alarm notifications, calendar reminders, contextual intelligent messages, and the like.
In general, interaction between a terminal and a wearable device may enable information synchronization through a specific service program. The service program in the terminal can be responsible for managing the information transmission channel, sending the encapsulated information and distributing the received information, and can monitor various information needing to be synchronized and send the encapsulated and packaged information to the wearable device one by one through threads. The wearable device may also transmit data back to the terminal.
However, in some cases, there may be a phenomenon that the message is lost, and the terminal and the wearable device cannot achieve synchronization of the message.
Disclosure of Invention
In view of the above, the application provides a message synchronization method, an electronic device and a storage medium, which can send synchronization requests to a wearable device for a plurality of times through an increased buffer queue, reduce the loss of synchronization messages, and realize the synchronization of messages between a terminal and the wearable device.
In a first aspect, the present application provides a message synchronization method, where in the message synchronization method provided by the embodiment of the present application, a preset buffer queue may be newly added in an electronic device. The electronic device may cache, in the cache queue, a message node of a synchronization message to be sent to the wearable device, where the message node records a number of retries of the synchronization message. The retry number is used to record the number of times the electronic device repeatedly sends a synchronization request for a synchronization message to the wearable device. Thus, the electronic device may process the synchronization message corresponding to each message node in the cache queue one by one, for example, when processing the first synchronization message recorded by the first message node in the cache queue, it may determine whether the retry number of the first synchronization message is less than a preset retry number threshold. If the number of retries of the first synchronization message is less than a preset threshold number of retries, the synchronization request of the first synchronization message may be added to a transmit queue. Because the electronic device will add the synchronization request of the first synchronization message to the transmission queue according to each synchronization request in the transmission queue one by one, it means that the electronic device can at least send the synchronization request of the first synchronization message to the wearable device again.
In the embodiment of the application, the electronic equipment is newly added with a preset cache queue, and a cache retry mechanism of the synchronous message is realized through the cache queue. The buffer retry mechanism of the synchronous message can effectively improve the probability of accurately transmitting the synchronous message between the electronic equipment and the wearable equipment.
In a possible implementation manner of the first aspect, the synchronization information further includes a message state, where the message state includes a pending state and an in-process state. Message nodes whose pending state is a synchronization message have been added to the cache queue waiting for a state to be processed but not yet processed. The in-process state is a state in which a synchronization request of a synchronization message has been issued from the transmission queue n times, but a synchronization response has not been received. N is smaller than N, N is a retry number threshold, and N and N are natural numbers.
In the embodiment of the application, the synchronous information recorded in the message node of the synchronous message can also comprise the message state, so that the processing condition of the synchronous message can be recorded through the message node.
In another possible implementation manner of the first aspect, after the electronic device adds the synchronization request of the first synchronization message in the transmission queue, the synchronization information recorded by the first message node in the cache queue may be updated. The first message node corresponds to a first synchronization message. Under the condition that the electronic equipment updates the synchronous information recorded by the first message node in the cache queue, if the message state recorded by the first message node is a to-be-processed state and the retry number recorded by the first message node is 0, the electronic equipment updates the message state recorded by the first message node into a processing state, and the retry number recorded by the first message node is still 0. If the message state recorded by the first message node is the in-process state, the electronic device adds 1 to the retry number recorded by the first message node, and the message state recorded by the first message node is still the in-process state.
In this way, the electronic device can timely determine the message state of each message node after adding the synchronization request of the synchronization message, and ensure the accuracy of the synchronization information recorded by each message node.
In another possible implementation of the first aspect, the message state further includes a processed state. The processed state is a state that a synchronization request of a synchronization message has been issued from a transmission queue and a synchronization response has been received; alternatively, the processed state is a state in which the synchronization request of the synchronization message has been repeatedly issued from the transmission queue N times, but the synchronization response has not been received. After the electronic device obtains the synchronization information of the first synchronization message recorded by the first message node in the cache queue, if the retry number of the first synchronization message is equal to the retry number threshold, the electronic device updates the message state recorded by the first message node to a processed state.
In the embodiment of the application, the electronic equipment repeatedly sends the synchronization request of the synchronization message to the wearable equipment for a plurality of times, but does not receive the synchronization response of the wearable equipment, and the synchronization message can be considered to be processed. The electronic device may not attempt to send the synchronization request of the synchronization message to the wearable device any more by setting the message state recorded by the message node corresponding to the synchronization message to a processed state.
In another possible implementation manner of the first aspect, the electronic device may periodically delete, from the cache queue, a message node corresponding to the synchronization message whose message state is the processed state. Or, the electronic device may delete, from the cache queue, a message node corresponding to the synchronization message whose message state is the processed state when the remaining cache space of the cache queue is smaller than the preset cache threshold.
By the method, the message nodes which finish message synchronization in the cache queue can be cleaned in time, and the cache space is saved.
In another possible implementation manner of the first aspect, the electronic device counts the number of nodes that can buffer the message states in the queue into the pending state and the in-process state. If the number of the nodes reaches a preset threshold value of the number of the nodes, the electronic equipment sets the threshold value of the retry times as the first retry times. And when the number of the nodes does not reach the threshold value of the number of the nodes, the threshold value of the retry number is the second retry number, and the first retry number is smaller than the second retry number.
In the embodiment of the application, under the condition that the node number of the message nodes which are not processed in the cache queue reaches the node number threshold, the synchronous message backlog of the current incomplete processing can be considered to be excessive, and the electronic equipment can reduce the retry frequency threshold so as to shorten the delay time of message synchronization between the electronic equipment and the wearable equipment.
In another possible implementation manner of the first aspect, if the number of nodes reaches the threshold of the number of nodes, the electronic device sets a cycle processing time interval of the cache queue to a first duration. The electronic device periodically processes the message nodes in the primary cache queue, and the cyclic processing time interval is used for indicating the time interval of the electronic device periodically processing the message nodes in the primary cache queue. And under the condition that the number of the nodes does not reach a preset threshold value of the number of the nodes, the cyclic processing time interval is a second time length, and the second time length is smaller than the first time length.
By the method, the electronic equipment can reduce the processing period of the cache queue under the condition that the number of message nodes in the cache queue is large, so that the processing speed of the synchronous message is increased, and the condition that the delay of the synchronous message is too long is reduced.
In another possible implementation manner of the first aspect, the synchronization information further includes a message identification. And the electronic equipment responds to the synchronous event, and if the synchronous event is the first event, the electronic equipment searches a second message node in the message nodes of the cache queue. The synchronization event is used for triggering the electronic device to send a second synchronization message to the wearable device, the first event is used for indicating the wearable device to delete the synchronization message related to the first event, the synchronization information of the synchronization message related to the first event is recorded in the second message node, and the message identification recorded in the second message node is identical to the message identification of the second synchronization message. And under the condition that the second message node is found, the electronic equipment deletes the second message node from the cache queue.
In this way, in the case that the synchronization event is an event of deleting the synchronization message, the electronic device may delete the message node in the cache queue that is the same as the message identifier of the second synchronization message, so as to delete the message node in the cache queue that does not need the synchronization message. The electronic equipment does not need to process the message nodes to be deleted, so that processing resources are saved.
In another possible implementation manner of the first aspect, if the synchronization event is not the first event, the electronic device may determine whether the third message node exists in the cache queue. Wherein the message identifier recorded by the third message node is the same as the second synchronization message. If the third message node does not exist in the cache queue, the electronic equipment adds the message node corresponding to the second synchronous message at the tail of the cache queue.
In this way, the electronic device may add the message node of the newly added synchronization message in the cache queue.
In another possible implementation manner of the first aspect, the synchronization information further includes a message status. If the third message node exists in the cache queue, the electronic device further judges whether the message state recorded by the third message node is a processed state. If the message state recorded by the third message node is the processed state, the electronic device may delete the third message node from the cache queue, and add a message node corresponding to the second synchronization message at the end of the cache queue.
In this way, the electronic device may delete the message node associated with the second synchronization message and having the message state being the processed state from the cache queue, and add the message node of the second synchronization message to the tail of the cache queue. Therefore, the cache queue can be updated in time, and message synchronization between the electronic equipment and the wearable equipment is realized.
In another possible implementation manner of the first aspect, if the message status recorded by the third message node is not a processed status, the electronic device determines whether the second synchronization message is a second event-triggered synchronization message. The second event is used for indicating the electronic device to send a new synchronization message to the wearable device. If the second synchronous message is a synchronous message triggered by a second event, the electronic equipment updates the synchronous information recorded by the third message node according to the second synchronous message.
In this way, in the case where there is a message node of the synchronization message that has not completed processing and is related to the second synchronization message in the cache queue, the electronic device may update the existing related message node instead of adding the node of the second synchronization message in the cache queue. I.e. the electronic device merges the relevant message nodes in the cache queue. Therefore, the synchronous messages of the same type are only provided with one message node, so that the interaction times of the synchronous messages between the electronic equipment and the wearable equipment can be reduced, and the occupation and the power consumption of a transmission channel can be reduced to a certain extent.
In another possible implementation manner of the first aspect, the synchronization information further includes an event identifier of the synchronization message. The event identifier is used for indicating a to-be-processed event of the synchronous message, wherein the to-be-processed event comprises an added synchronous message, an updated synchronous message and a deleted synchronous message. If the synchronous event is the first event, the event to be processed indicated by the event identification of the second synchronous message is the deletion synchronous message. If the synchronous event is a second event, the event to be processed indicated by the event identification of the second synchronous message is a newly added synchronous message. In this way, the electronic device can identify the synchronization event triggering the synchronization message through the event identification, so that different processing can be performed for different synchronization events.
In another possible implementation manner of the first aspect, the message identifier includes a key identifier and a category identifier. Wherein the key identification is used to identify the listener that generated the synchronization message. The category identification is used for identifying the scene category corresponding to the synchronous message. Through the key identification and the category identification, the electronic device can identify the source and the scene of the synchronous message, so that synchronous messages with the same source and scene can be identified.
In another possible implementation manner of the first aspect, the electronic device receives a synchronization response returned by the wearable device. The electronic equipment searches a fourth message node corresponding to the synchronous response in the cache queue. If the fourth message node is found, the electronic device sets the message state in the synchronization information recorded by the fourth message node to the processed state.
In another possible implementation manner of the first aspect, the synchronization response carries a communication identifier, and the electronic device searches for a fourth message node corresponding to the synchronization response in the cache queue; according to a pre-established mapping table, the electronic equipment searches a fourth message node corresponding to the communication identifier in the cache queue, wherein the mapping table stores the corresponding relation between the message node in the cache queue and the communication identifier.
In this way, the electronic device can update the message node corresponding to the synchronization message which has received the synchronization response in time, so as to request retry for the synchronization message which has not completed synchronization.
In a second aspect, the present application provides an electronic device comprising: a memory, a communication module, and one or more processors; the memory, the communication module, and the processor are coupled; the communication module is used for transmitting data or signaling with the wearable equipment; the memory is used for storing a preset cache queue, the cache queue comprises at least one message node corresponding to the synchronous message, the message node records the synchronous information of the synchronous message, and the synchronous information comprises retry times; the retry number is used for recording the number of times that the electronic device repeatedly sends the synchronization request of the synchronization message to the wearable device;
Wherein the memory has stored therein also computer program code comprising computer instructions which, when executed by the processor, cause the electronic device to perform the method according to the first aspect.
In a third aspect, the application provides a computer readable storage medium comprising computer instructions which, when run on an electronic device, cause the electronic device to perform the method according to the first aspect.
Drawings
Fig. 1 is a schematic diagram of synchronous display of a mobile phone and a smart watch according to an embodiment of the present application;
fig. 2 is a schematic diagram of message synchronization between an electronic device and a wearable device provided by a conventional technology;
FIG. 3 is a flow chart of message synchronization between an electronic device and a wearable device provided by a conventional technology;
FIG. 4 is a functional block diagram of electronic device and wearable device line message synchronization provided by the conventional technology;
fig. 5 is a block diagram of an electronic device according to an embodiment of the present application;
fig. 6 is a block diagram of a smart watch 200 according to an embodiment of the present application;
fig. 7 is a flowchart of a message synchronization method according to an embodiment of the present application;
FIG. 8 is a diagram illustrating an example of a message node according to an embodiment of the present application;
FIG. 9 is a flowchart of an example of a message synchronization method according to an embodiment of the present application;
fig. 10 is a flowchart of a mobile phone 100 according to an embodiment of the present application processing a message node in a cache queue;
fig. 11 is a flowchart of a process of responding to synchronization by the mobile phone 100 according to an embodiment of the present application;
fig. 12 is a flowchart of adding a message node to a buffer queue by the mobile phone 100 according to an embodiment of the present application;
fig. 13 is a schematic block diagram of message synchronization between a mobile phone 100 and a smart watch 200 according to an embodiment of the present application;
fig. 14 is a block diagram of a message synchronization buffer management module according to an embodiment of the present application.
Detailed Description
Various exemplary embodiments, features and aspects of the disclosure will be described in detail below with reference to the drawings. In the drawings, like reference numbers indicate identical or functionally similar elements. Although various aspects of the embodiments are illustrated in the accompanying drawings, the drawings are not necessarily drawn to scale unless specifically indicated.
The word "exemplary" is used herein to mean "serving as an example, embodiment, or illustration. Any embodiment described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments.
The term "and/or" is herein merely an association relationship describing an associated object, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, C, and may mean including any one or more elements selected from the group consisting of A, B and C.
Furthermore, numerous specific details are set forth in the following detailed description in order to provide a better understanding of the present disclosure. It will be understood by those skilled in the art that the present disclosure may be practiced without some of these specific details. In some instances, methods, means, elements, and circuits well known to those skilled in the art have not been described in detail in order not to obscure the present disclosure.
The embodiment of the application provides a message synchronization method which can be applied to a message synchronization system. The message synchronization system may include: an electronic device and a wearable device. The electronic device may synchronize messages in the electronic device (referred to as synchronization messages) to the wearable device. For example, taking the electronic device as the cell phone 100 shown in fig. 1, the wearable device is the smart watch 200 as an example. As shown in fig. 1, the message synchronization system may include: smart watch 200 and handset 100. The handset 100 may synchronize the synchronization messages in the handset 100 to the smart watch 200. The synchronization message may be triggered by a user operation or by an application in the electronic device itself, for example, the user may operate on the user device to trigger the synchronization message, or an alarm, a schedule, etc. of the user may automatically trigger the synchronization message after the timing time is reached.
By way of example, the synchronization message described in the embodiments of the present application may include any of the following: application notification, system notification, memo message, alarm message, call reminder, short message, user preference recommendation. The embodiment of the application does not limit the synchronous message, and the synchronous message can be any message which needs to be synchronized between the electronic equipment and the wearable equipment.
In fig. 1, taking a schedule reminding message as an example, a reminding interface schematic diagram of three schedule reminding messages displayed by the mobile phone 100 and the smart watch 200 is shown. As shown in fig. 1, the mobile phone 100 may send out a reminder message 101 (i.e. a synchronization message) of the schedule of new product research and development meeting, and synchronize the schedule with the smart watch 200; the smart watch 200 may display a reminder interface 201 for the calendar. As another example, as shown in fig. 1, after the schedule "new product research and development meeting" has a time change, the mobile phone 100 may send a reminder message 102 (synchronization message) for the time change of the schedule, and synchronize the time change of the schedule with the smart watch 200; the smart watch 200 may display a reminder interface 202 for the calendar time change. As another example, as shown in fig. 1, after the schedule "new product research and development meeting" changes in time, the mobile phone 100 may send out a reminder message 103 (synchronization message) for the schedule location change, and synchronize the location change of the schedule with the smart watch 200; the smart watch 200 may display a reminder interface 203 for the change of the calendar place.
For ease of understanding, embodiments of the present application describe a specific process in the conventional art in which an electronic device sends a synchronization message to a wearable device.
The synchronization of an electronic device (e.g., handset 100) with a wearable device (e.g., smart watch 200) requires two interactions. Before the electronic device sends the synchronization message to the wearable device, a synchronization request of the synchronization message may be sent to the wearable device, where the synchronization request may not carry the message content of the synchronization message. Thereafter, if the electronic device receives a synchronization request for the synchronization message, the synchronization message may be sent to the wearable device. As shown in fig. 2, the electronic device may buffer the synchronization request of the synchronization message in a transmission queue (such as transmission queue 1), and send the synchronization request of the synchronization message from the transmission queue 1 to the wearable device. After receiving the synchronization request, the wearable device may transmit a synchronization response of the synchronization request back to the electronic device. After receiving the response message of the synchronization request, the electronic device may send the message content including the full data of the synchronization message (i.e., the synchronization message itself) from another sending queue (e.g., sending queue 2) to the wearable device.
As shown in fig. 3, after the electronic device obtains one synchronization request in the transmission queue 1, the synchronization request may be encrypted, and the encrypted synchronization request may be sent to the wearable device through a bottom layer transmission channel (such as a bluetooth channel). Each time the electronic device sends a synchronization request, it may wait 300ms in a blocking manner, reading the synchronization response of the synchronization request from the receive queue. If the synchronization response of the synchronization request is not read from the receiving queue, the synchronization request can be directly deleted from the sending queue 1, and the next synchronization request can be processed.
In the process of synchronizing the messages, the problem of synchronization message loss easily occurs. The reasons for the loss of synchronization messages may be the following:
(1) The transmission link between the electronic device and the wearable device is abnormal, so that the synchronization request sent by the electronic device is not successfully sent to the wearable device, or the response message of the synchronization request sent by the wearable device is not successfully sent to the electronic device.
(2) The performance difference between the electronic device and the wearable device causes mismatching of the speed of processing the messages, and the wearable device does not process the messages timely, so that the synchronous response of the synchronous request cannot be replied to the electronic device within 300 ms.
Based on this, the embodiment of the application provides a message synchronization method, which can solve the problem of synchronization message loss. In order to better explain the technical solution provided by the embodiments of the present application, the message synchronization process mentioned in the above background art is further described herein.
Fig. 4 is a schematic block diagram of synchronous messaging by an electronic device according to a conventional technology. As shown in fig. 4, various types of listeners may be provided in the electronic device, such as an application notification listener, a memo information listener, an alarm listener, a call listener, and the like. The listener can listen for various instructions, messages (e.g., synchronization messages). The monitoring management module may be a service module for managing synchronization messages of various types of monitors. The listening management module may specifically be a Synergy service provided by the electronic device. The key class of Message processing in the Synergy service is a Message Manager class, and is responsible for management of a bottom layer transmission (Transport) channel, sending processing of an upper layer encapsulation Message and receiving and distributing processing of the bottom layer Message.
After receiving a synchronization message sent by various listeners, the interception management module (such as a Synergy service) can call the synchronization message sending and receiving management module to send a synchronization request of the synchronization message to the wearable device, and after the interception management module calls a packaging program to package the synchronization request of the synchronization message, the packaged synchronization request is added into the sending queue 1 through a message manager. And then the synchronous requests in the transmission queue 1 are transmitted to the wearable side equipment one by one through the established transmission channel through independent threads.
The electronic device may further include a synchronous messaging module, where the synchronous messaging management module may include a synchronous message processing executor, a transmission channel manager, an information security manager, and the like. The synchronous message processing executor may manage the transmission queue 1, the reception queue, and the transmission queue 2. The synchronous message receiving and transmitting management module sends the synchronous requests in the sending queue 1 to the wearable side equipment one by one through the transmission channel established by the transmission channel manager and the independent threads. The synchronous messaging management module can also add a synchronous response returned by the wearable device for the synchronous request in the receiving queue, send the message content of a synchronous message corresponding to the synchronous response to the wearable device in the sending queue 2, and meanwhile, distribute the synchronous response to the monitoring management module.
Specifically, according to the message synchronization scheme provided by the embodiment of the application, a buffer queue can be added in a message receiving and sending process, for example, a message synchronization buffer management module (shown in fig. 13) is added in a framework of synchronous message receiving and sending in fig. 4, and the buffer queue is managed through the message synchronization buffer management module. The message nodes corresponding to the synchronous messages are recorded in the cache queue, and the synchronous request of the same synchronous message can be repeatedly sent to the wearable device by the electronic device under the condition that the retry times recorded in the message nodes of the cache queue do not reach the set retry times threshold value by introducing a retry mechanism of synchronous message sending. By the method, the synchronization of the information between the electronic equipment and the wearable equipment is realized under the condition that the loss of the synchronization information between the electronic equipment and the wearable equipment can be reduced.
Here, the message node may record the number of retries, and may represent the number of synchronization requests for which the electronic device repeatedly sends a synchronization message to the wearable device.
By way of example, the electronic device described in embodiments of the present application may be a cell phone, tablet, desktop, laptop, handheld computer, notebook, ultra-mobile personal computer (ultra-mobile personal computer, UMPC), netbook, cell phone, personal digital assistant (personal digital assistant, PDA), augmented reality (augmented reality, AR) \virtual reality (VR) device, media player, television, etc. The wearable device can be intelligent devices such as intelligent watches, intelligent bracelets, intelligent helmets, intelligent glasses and the like which can be worn on the body, and the specific forms of the electronic device and the wearable device are not particularly limited in the embodiment of the application.
In the embodiment of the present application, the electronic device is a mobile phone (such as mobile phone 100), and the hardware structure of the electronic device is described. Fig. 5 is a block diagram of an electronic device according to an embodiment of the present application. As shown in fig. 5, the electronic device 500 may include a processor 510, an internal memory 520, a universal serial bus (universal serial bus, USB) interface 530, a charge management module 540, a battery 541, an antenna 1, an antenna 2, a mobile communication module 550, a wireless communication module 560, an audio module 570, a sensor module 580, a display screen 590, a subscriber identity module (subscriber identification module, SIM) card interface 591, and the like.
It should be understood that the illustrated structure of the embodiment of the present application does not constitute a specific limitation on the electronic device 500. In other embodiments of the application, electronic device 500 may include more or fewer components than shown, or may combine certain components, or split certain components, or a different arrangement of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
Processor 510 may include one or more processing units, such as: processor 510 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and/or a neural network processor (neural-network processing unit, NPU), etc. Wherein the different processing units may be separate devices or may be integrated in one or more processors. For example, in an embodiment of the present application, processor 510 may be an application processor AP.
The controller may be a neural hub and a command center of the electronic device 500, among others. The controller can generate operation control signals according to the instruction operation codes and the time sequence signals to finish the control of instruction fetching and instruction execution.
A memory may also be provided in the processor 510 for storing instructions and data. In some embodiments, the memory in processor 510 is a cache memory. The memory may hold instructions or data that has just been used or recycled by the processor 510. If the processor 510 needs to reuse the instruction or data, it may be called directly from memory. Repeated accesses are avoided and the latency of the processor 510 is reduced, thereby improving the efficiency of the system.
In some embodiments, processor 510 may include one or more interfaces. The interfaces may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous receiver transmitter (universal asynchronous receiver/transmitter, UART) interface, a mobile industry processor interface (mobile industry processor interface, MIPI), a general-purpose input/output (GPIO) interface, a subscriber identity module (subscriber identity module, SIM) interface, and/or a USB interface, among others.
The USB interface 530 is an interface conforming to the USB standard specification, and may specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, or the like. The USB interface 530 may be used to connect a charger to charge the electronic device 500, or may be used to transfer data between the electronic device 500 and a peripheral device. And can also be used for connecting with a headset, and playing audio through the headset. The interface may also be used to connect other electronic devices or mobile terminals, such as AR devices, etc.
It should be understood that the connection between the modules illustrated in the embodiments of the present application is only illustrative, and does not limit the structure of the electronic device 500. In other embodiments of the present application, the electronic device 500 may also employ different interfacing manners in the above embodiments, or a combination of multiple interfacing manners.
The charge management module 540 is configured to receive a charge input from a charger. The charger can be a wireless charger or a wired charger. In some embodiments, the electronic device 500 may support wired charging. Specifically, the charge management module 540 may receive a charge input of the wired charger through the USB interface 530. In other embodiments, electronic device 500 may support wireless charging.
The charging management module 540 may also supply power to the electronic device 500 while charging the battery 541. The charge management module 540 receives input from the battery 541 and provides power to the processor 510, the internal memory 520, the external memory, the display 590, the wireless communication module 560, and the like. The charge management module 540 may also be configured to monitor battery 541 battery capacity, battery cycle number, battery state of health (leakage, impedance), and other parameters. In other embodiments, the charge management module 540 may also be disposed in the processor 510.
The wireless communication function of the electronic device 500 may be implemented by the antenna 1, the antenna 2, the mobile communication module 550, the wireless communication module 560, the modem processor, the baseband processor, and the like.
The antennas 1 and 2 are used for transmitting and receiving electromagnetic wave signals. Each antenna in electronic device 500 may be used to cover a single or multiple communication bands. Different antennas may also be multiplexed to improve the utilization of the antennas. For example: the antenna 1 may be multiplexed into a diversity antenna of a wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.
The mobile communication module 550 may provide a solution for wireless communication including 2G/3G/4G/5G, etc., applied on the electronic device 500. The wireless communication module 560 may provide solutions for wireless communication including wireless local area network (wireless local area networks, WLAN) (e.g., wireless fidelity (wireless fidelity, wi-Fi) network), bluetooth (BT), global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), NFC, infrared (IR), etc. as applied on the electronic device 500. In some embodiments, antenna 1 and mobile communication module 550 of electronic device 500 are coupled, and antenna 2 and wireless communication module 560 are coupled, such that electronic device 500 may communicate with a network and other devices through wireless communication techniques. In an embodiment of the present application, the electronic device 500 may communicate with the smart watch 200 via the wireless communication module 560, for example, may send a synchronization message to the smart watch 200 via a bluetooth link.
Electronic device 500 implements display functionality via a GPU, display screen 590, and an application processor, among others. The GPU is a microprocessor for image processing, and is connected to the display screen 590 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 510 may include one or more GPUs that execute program instructions to generate or change display information.
The display screen 590 is for displaying images, videos, and the like. The display screen 590 includes a display panel. In some embodiments, electronic device 500 may include 1 or M display screens 590, M being a positive integer greater than 1.
Internal memory 520 may be used to store computer-executable program code that includes instructions. The processor 510 executes various functional applications of the electronic device 500 and data processing by executing instructions stored in the internal memory 520. In addition, the internal memory 520 may include high-speed random access memory, and may also include nonvolatile memory, such as at least one magnetic disk storage device, flash memory device, universal flash memory (universal flash storage, UFS), and the like.
The electronic device 500 may implement audio functions through an audio module 570, speakers, a receiver, a microphone, an earphone interface, an application processor, and so forth. Such as music playing, recording, etc.
The audio module 570 is configured to convert digital audio information to an analog audio signal output and also to convert an analog audio input to a digital audio signal. In some embodiments, the audio module 570 may be provided in the processor 510 or some functional modules of the audio module 570 may be provided in the processor 510.
The SIM card interface 591 may support Nano SIM cards, micro SIM cards, and the like. In some embodiments, the electronic device 500 employs esims, namely: an embedded SIM card. The eSIM card can be embedded in the electronic device 500 and cannot be separated from the electronic device 500.
Fig. 6 is a block diagram of a smart watch 200 according to an embodiment of the present application. As shown in fig. 6, the smart watch 200 includes: the watch body and wristband are connected to each other, wherein the watch body may include a front case (not shown in fig. 6), a touch screen 601 (also called a touch panel), a display screen 602, a bottom case (not shown in fig. 6), and a processor 603, a micro control unit (Micro Control Unit, MCU) 604, a memory 605, a bluetooth module 608, a sensor 610, a power supply 612, a power management system 613, and the like. Although not shown, the smart watch 200 may also include an antenna, a WiFi module, a GPS module, a speaker, a gyroscope, and the like. The following describes each functional component of the smart watch 200:
The touch screen 601, also referred to as a touch pad, may collect touch operations thereon by a user of the wristwatch (e.g., the user's operation on or near the touch panel using any suitable object or accessory such as a finger, stylus, etc.), and actuate the responsive connection device according to a predetermined program. Alternatively, the touch screen 601 may include two parts, a touch detection device and a touch controller. The touch detection device detects the touch azimuth of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends the touch point coordinates to the processor 603, and can receive and execute commands sent by the processor 603. In addition, the touch panel may be implemented in various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch screen 601, the smart watch may include other input devices that may include, but are not limited to, function keys (e.g., volume control keys, switch keys, etc.).
The display 602 may be used to display information entered by or provided to the user as well as various menus of the watch. In the embodiment of the application, the synchronization message sent by the electronic device 500 can be displayed for the user. Alternatively, the display 602 may be configured in the form of a liquid crystal display (Liquid Crystal Display, LCD), an Organic Light-Emitting Diode (OLED), or the like. Further, the touch screen 601 may overlay the display screen 602, and when the touch screen 601 detects a touch operation thereon or thereabout, the touch screen is transferred to the processor 603 to determine a type of touch event, and then the processor 603 provides a corresponding visual output on the display screen 602 according to the type of touch event. Although in fig. 6 the touch screen 601 and the display screen 602 implement the input and output functions of the wristwatch as two separate components, in some embodiments the touch screen 601 may be integrated with the display screen 602 to implement the input and output functions of the wristwatch.
The processor 603 is used for performing system scheduling, controlling a display screen, a touch screen, supporting processing of the bluetooth module 608, etc.
The bluetooth module 608 may enable the smart watch 200 to interact with other electronic devices (e.g., the electronic device 500 shown in fig. 5) through the bluetooth module 608, for example, the smart watch 200 may receive a synchronization message sent by the electronic device through the bluetooth module 608, and connect to a server through the electronic device connection network, and perform functions such as voice recognition.
The micro control unit 604 is used for controlling the sensor, calculating sensor data, communicating with the processor 603, and the like.
The sensor 610 may be a barometric pressure sensor, heart rate detection sensor, gravitational acceleration sensor, light sensor, motion sensor, or other sensor. In particular, the light sensor may include an ambient light sensor and a proximity sensor. Other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc. that may also be configured in the wristwatch are not described in detail herein.
The memory 605 is used to store software programs and data, and the processor 603 executes various functional applications and data processing of the wristwatch by executing the software programs and data stored in the memory. The memory 605 mainly includes a storage program area and a storage data area, wherein the storage program area can store an operating system, an application program (such as a sound playing function, an image playing function, etc.) required for at least one function; the storage data area may store data (such as audio data, phonebooks, etc.) created from the usage table. In addition, the memory may include high-speed random access memory, and may also include nonvolatile memory, such as magnetic disk storage devices, flash memory devices, or other volatile solid-state storage devices.
The smart watch 200 also includes a power supply 612 (e.g., a battery) for powering the various components, and optionally, the power supply 612 may be logically connected to the processor 603 by a power management system 613 such that charge, discharge, and power consumption management functions are performed by the power management system 613.
The message synchronization methods in the following embodiments may be implemented in electronic devices and smart watches having the above hardware structures. In the following embodiments, taking an example that the electronic device is the mobile phone 100 shown in fig. 5 and the wearable device is the smart watch 200 shown in fig. 6, the method according to the embodiments of the present application is described.
Fig. 7 is a flowchart of a message synchronization method according to an embodiment of the present application, as shown in fig. 7, where the message synchronization method includes:
s71, the mobile phone 100 acquires the synchronization information of the first synchronization message recorded by the first message node in the cache queue.
In the embodiment of the present application, the mobile phone 100 may include a preset cache queue, where the cache queue may include at least one message node corresponding to the synchronization message. And the corresponding message node of each synchronous message records the synchronous information of the synchronous message. The synchronization information may include a retry number, where the retry number is used to record the number of times that the mobile phone 100 repeatedly sends the synchronization request of the synchronization message to the smart watch 200. Of course, the synchronization information may also include other contents corresponding to the synchronization message, which is not described herein in detail in the embodiments of the present application.
The mobile phone 100 may add a message node corresponding to the synchronization message in the buffer queue. One or more message nodes corresponding to one or more synchronous messages respectively can be included in the cache queue, and one message node corresponds to one synchronous message. In some cases, there may be no message node in the cache queue, i.e., the cache queue may be empty. For example, after one synchronization message is sent, the message node corresponding to the synchronization message in the buffer queue may be deleted.
It will be appreciated that the cache queues referred to herein are storage structures in a broad sense, as opposed to queues that only allow delete operations at the head of the queue and insert operations at the tail of the queue. The buffer queue may be a linked list structure, for example, a single linked list or a double linked list, and the adding and deleting operations may be performed on any message node in the buffer queue.
In the embodiment of the present application, in the case that the preset cache queue includes at least one message node, the mobile phone 100 may sequentially process the message nodes in the cache queue in the order from the head of the queue to the tail of the queue. The message node currently processed by the mobile phone 100 may be the first message node. The first message node records the synchronization information of the first synchronization message, that is, the first message node is the message node corresponding to the first synchronization message, and the first message node corresponds to the first synchronization message. In the case where the mobile phone 100 processes the first message node, the mobile phone 100 may acquire synchronization information of the first synchronization message recorded by the first message node.
S72, if the retry number in the synchronization information of the first synchronization message is smaller than the preset retry number threshold, the mobile phone 100 adds the synchronization request of the first synchronization message in the transmission queue.
It will be appreciated that to increase the likelihood that the smart watch 200 receives a synchronization message, the handset 100 may send multiple synchronization requests to the smart watch 200 for the same synchronization message. The retry number may be used to record the number of times that the synchronization request is repeatedly sent for one synchronization message, and the number of retries recorded by the message node corresponding to the synchronization message is increased by 1 time every time the synchronization request is repeatedly sent. The default value of the number of retries is 0.
In the embodiment of the present application, after obtaining the retry number of the first message node, the mobile phone 100 may compare the retry number of the first message node with a preset retry number threshold, and determine whether the retry number of the first message node reaches the retry number threshold. In the case that it is confirmed that the number of retries of the first message node does not reach the threshold number of retries, that is, the number of retries of the synchronization request for sending the first synchronization message to the smart watch 200 has not reached the set maximum value, the synchronization request for the first synchronization message may be further added at the end of the sending queue of the synchronization request, for example, the synchronization request (such as the a004 signaling) may be added at the end of the sending queue.
S73, the mobile phone 100 sends a synchronization request of the first synchronization message to the smart watch 200 from the transmission queue.
In the disclosed embodiment, the handset 100 may invoke a synchronization request that the transmission channel sends a first synchronization message from the head of the transmit queue to the smart watch 200. The communication channel between the mobile phone 100 and the smart watch 200 can be set according to the actual application situation and the application scenario. For example, the transmission channel between the mobile phone 100 and the smart watch 200 may be a wireless transmission channel, such as a bluetooth channel, a hot spot channel, and the like. When a plurality of synchronization requests are present in the transmission queue, the mobile phone 100 sequentially transmits the plurality of synchronization requests in the transmission queue order according to the plurality of synchronization messages, for example, the mobile phone 100 sequentially transmits the plurality of synchronization requests from the transmission queue. The plurality of synchronous messages are sequentially arranged from the head of the queue to the tail of the queue according to time sequence.
In this way, the synchronization request can be repeatedly sent to the wearable device for the same synchronization message, so that the possibility of losing the synchronization message is reduced, and the message synchronization between the mobile phone 100 and the hand smart watch 200 is realized.
In some embodiments, the synchronization information may include not only the number of retries, but also one or more of a message identification, an event identification, a message status, a waiting duration, a timestamp of completion of message transmission, and a message node identification. Each of the synchronization information is described below:
message identification: the message identification can be used for identifying one message, and the message identifications of different synchronous messages can be different or the same. The synchronization messages identified by the same message may be considered as homogeneous synchronization messages.
Event identification: the event identification may be used to describe a synchronization event that triggers a synchronization message. For example, the synchronization event may be an event of adding a synchronization message, deleting a synchronization message, updating a synchronization message. The mobile phone 100 may perform a corresponding operation on a synchronization message according to an event identifier of the synchronization message. For example, in the case where the synchronization event indicated by the event identification is an addition message, the handset 100 may add a message node of the synchronization message in the cache queue. In the case where the synchronization event indicated by the event identification is a delete message, the handset 100 may delete the message node of the synchronization message in the cache queue. In the case where the synchronization event indicated by the event identification is an update message, the handset 100 may update the message node of the synchronization message in the cache queue.
Message status: the message state may be used to represent the processing state of the synchronization message. The message state of one synchronization message may be any one of a pending state, an in-process state, and a processed state.
The state to be processed may be a state that a message node of the synchronous message has been added to the buffer queue and is waiting to be processed but not yet processed, i.e. the synchronous request of the synchronous message has not yet been added to the sending queue. The in-process state is a state in which a synchronization request of a synchronization message has been issued from the transmission queue n times, but a synchronization response has not been received.
The processed state is a state in which a synchronization request for a synchronization message has been issued from the transmit queue and a synchronization response has been received. Alternatively, the synchronization request whose processed state is the synchronization message is repeated N times from the transmission queue, but no synchronization response is received (the number of retries is N).
Wherein N is less than N, N is a retry number threshold, and N are natural numbers, i.e., N and N are greater than or equal to 0. In the case of processing a message node in the cache queue, the mobile phone 100 does not process a message node whose processing state is a processed state.
Waiting time period: the waiting duration may be used to represent the duration that the handset 100 waits for the wearable device to return a synchronization response for one synchronization message. The handset 100 may begin timing after the first synchronization request to send the synchronization message. The waiting time length can be used as a basis for whether to change the message state recorded by the message node. For example, in the case where the waiting time period reaches a preset waiting time period threshold value, the synchronization response of the synchronization message may be considered to be timed out, and the message state of the synchronization message may be set to the processed state.
Timestamp of completion of synchronization: the time stamp for completing synchronization can be used to represent the time for completing synchronization of a synchronization message, and can be used as a basis for whether to remove the synchronization message. For example, in the case where the handset 100 deletes a message node of a synchronization message in which synchronization has been completed in the cache queue, the synchronization node with the earliest timestamp in the cache queue may be deleted according to the timestamp recorded by the message node.
Message node identification: the message node identification may be used to indicate the message node in the cache queue.
In some examples, message nodes in the cache queue may be implemented by dataclasses. For example, a message node may be defined by a Requestltem class. The dataclass may include multiple fields, and different fields may describe different information. The synchronization information of the synchronization message may be carried in a field of the dataclass.
In some examples, the message nodes in the cache queue may be implemented by a dataclass, e.g., the message nodes may be defined by a Requestltem class. The dataclass may include multiple fields, and different fields may describe different information. The synchronization information of the synchronization message may be carried in a field of the dataclass. Fig. 8 is a block diagram illustrating an example of a message node provided by an embodiment of the present application. The Requestltem class may include a key field key, a category field categorid, an event identification field eventId, a message status field state, a retry number field tryCount, a wait timeout period field timeout, a timestamp field processedTimestamp, and a message node identification field RequestItem next & previous. The key field key may record a key identifier, where the key identifier is used to identify a listener generating a synchronization message, and may be used as a unique identifier between the listener and the listening management, for example, the notification key value is status bar notification. The category field categorild can record category identification, and the category identification is used for identifying scene categories corresponding to the synchronous message, such as an incoming call scene, a short message scene and a notification scene. The event identification field eventId can record event identification, the event identification value can be 0, 1 and 2,0 corresponds to adding synchronous information, 1 corresponds to updating synchronous information, and 2 corresponds to deleting synchronous information. The message status field state may record a message status, where the message status may take values of 0, 1 and 2,0 indicates a pending status (a synchronization node for a synchronization message has been added to a cache queue waiting for a synchronization request for the synchronization message to be sent), 1 indicates an in-process status (a synchronization request for a synchronization message has been sent (e.g., a004 signaling) but a synchronization response has not been received (e.g., a005 signaling)), 2 indicates a processed status (a synchronization response has been received (e.g., a005 signaling) or waiting for a timeout). The retry number field tryCount may record the number of retries, which is default to 0. The waiting timeout duration field timeout may record a waiting timeout duration, where the waiting timeout duration is used to represent a duration of waiting for a synchronous response by a synchronous message, and according to the waiting timeout duration, whether to change a message state recorded by the message node may be confirmed. The timestamp field processdtimestamp may record a timestamp of the synchronization message that completed synchronization. The message node identification field RequestItem next & previous may record a message node identification. The message identifications mentioned in the foregoing may include the key identifications and scene identifications described above.
It will be appreciated that in the figure, string indicates that the data type is a character String, byte indicates that the data type is a byte type, int indicates that the data type is an integer, and long indicates that the data type is a long integer. The fields in the Requestltem class provided in this example may be added or modified according to actual situations, which is not limited by the embodiment of the present application.
In the embodiment of the present application, after receiving the synchronization request sent by the mobile phone 100, the smart watch 200 may return a synchronization response replied to the synchronization request to the mobile phone 100. After receiving the synchronization response returned by the smart watch 200, the mobile phone 100 may send the full data of the first synchronization message to the smart watch 200, so as to realize message synchronization between the mobile phone 100 and the smart watch 200. After the mobile phone 100 transmits the full data of the synchronization message to the smart watch 200, the smart watch 200 does not need to return a synchronization response to the mobile phone 100. That is, after receiving the synchronization response returned by the smart watch 200, the mobile phone 100 can consider that synchronization of one synchronization message between the mobile phone 100 and the smart watch 200 is achieved.
In some embodiments, the handset 100 performs S73, after adding the synchronization request of the first synchronization message in the transmission queue, indicating that the handset 100 will transmit the synchronization request of the first synchronization message from the transmission queue to the wearable device. Thus, the synchronization information recorded in the message node of the first synchronization message needs to be updated. Specifically, after S73, the method according to the embodiment of the present application may further include S74. For example, as shown in fig. 9, after S73, the method of the embodiment of the present application may further include S74.
S74, the mobile phone 100 updates the synchronization information recorded by the first message node in the buffer queue. The first message node corresponds to a first synchronization message.
For example, the handset 100 may update the number of retries recorded by the first message node, or may update the message status recorded by the first message node. In this way, the synchronization information of the synchronization message recorded in the message node can be updated to the latest state.
The mobile phone 100 may update the synchronization information recorded in the message node of the first synchronization message according to the message state recorded in the first message node and the retry number. Specifically, S74 may include S74a-S74b.
If the message state recorded in the first message node is the to-be-processed state and the retry number recorded in the first message node is 0, the mobile phone 100 updates the message state recorded in the first message node to the in-process state, and the retry number recorded in the first message node is still 0.
Here, the message state recorded by the first message node is a pending state, which indicates that the first synchronization message corresponding to the first message node may be a newly triggered synchronization message, and the first message node has not yet been processed. The number of retries recorded by the first message node may be a default value of 0 when the mobile phone 100 has not added a synchronization request of the first synchronization message in the transmission queue. After the mobile phone 100 adds the synchronization request of the first synchronization message in the transmission queue, and after the mobile phone 100 sends the first synchronization request to the wearable device, the first message node is processed, the mobile phone 100 can update the message state recorded by the first message node from the to-be-processed state to the in-process state. Since the mobile phone 100 has not repeatedly sent the synchronization request of the first synchronization message to the wearable device, the number of retries recorded by the first message node may remain unchanged, i.e. the number of retries is still 0.
If the message state recorded in the first message node is the in-process state, S74b, the mobile phone 100 adds 1 to the retry number recorded in the first message node, and the message state recorded in the first message node is still the in-process state.
Here, if the message state recorded by the first message node is the in-process state, it may be considered that the number of retries of the synchronization request for sending the first synchronization message to the smart watch 200 by the mobile phone 100 has not reached the preset threshold number of retries, that is, has not reached the set maximum value. After the mobile phone 100 adds the synchronization request of the first synchronization message in the transmission queue, the mobile phone 100 may increase the number of retries recorded by the first message node. For example, the number of retries of the first message node is 0, and after the mobile phone 100 adds the synchronization request of the first synchronization message to the transmission queue, the mobile phone 100 sets the number of retries of the first message node to 1.
In one case, prior to performing S74b, the message state recorded by the first message node is an in-process state, and the number of retries recorded by the first message node is N-1. In this case, after the mobile phone 100 performs S74b, the message state recorded by the first message node is still in the in-process state, but the number of retries recorded by the first message node is updated to N.
In the case where the message state of the first synchronization message is in-process and the number of retries recorded by the first message node is N, the mobile phone 100 needs to update the message state recorded by the first message node from the in-process state to the processed state. Based on this, after S74, the method of the embodiment of the present application may further include S75. For example, as shown in fig. 9, after S74, the method of the embodiment of the present application may further include S75.
And S75, if the retry number of the first synchronous message is equal to the retry number threshold, the mobile phone 100 updates the message state recorded by the first message node to the processed state.
Here, if the number of retries of the first synchronization message is equal to the threshold number of retries, that is, the number of retries of the synchronization request that the mobile phone 100 sends the first synchronization message to the smart watch 200 reaches the set maximum value, the mobile phone 100 updates the message state recorded by the first message node to the processed state. In this way, when the mobile phone 100 repeatedly sends a synchronization request of a synchronization message to the smart watch 200, but does not receive a synchronization response of the mobile phone 100, the synchronization message can be considered to be processed, and the retry number of the synchronization message is not increased.
It will be appreciated that if the message state recorded by the message node of a synchronization message is a processed state, this indicates that the synchronization message does not need to be retransmitted. In this case, the handset 100 may delete the synchronization request of the synchronization message from the cache queue, and may provide a storage space for the cache queue in time. After S75, the method of the embodiment of the present application may further include S76a or S76b:
and S76a, the mobile phone 100 periodically deletes the message node corresponding to the synchronous message with the message state being the processed state from the cache queue.
And S76b, deleting the message node corresponding to the synchronous message with the message state being the processed state from the cache queue when the residual cache space of the cache queue is smaller than the preset cache threshold value by the mobile phone 100.
Here, the mobile phone 100 may periodically delete the message node corresponding to the synchronization message whose message state is the processed state from the buffer queue. For example, with 2 seconds as a period, the handset 100 deletes the message node whose message state is the processed state from the buffer queue. Or when the remaining buffer space of the buffer queue is smaller than the preset buffer threshold, the mobile phone 100 deletes the message node corresponding to the synchronous message with the message state being the processed state from the buffer queue. For example, the handset 100 may delete a message node in the cache queue whose message state is a processed state if the remaining cache space of the cache queue is less than 20%, 5%, etc. of the space share. Therefore, the message nodes which finish the message synchronization in the cache queue can be cleaned in time, and the cache space is saved.
In some examples, after receiving the synchronization response of any synchronization message, the mobile phone 100 may change the message state recorded by the message node corresponding to the synchronization response in the buffer queue to a processed state, and further delete the message node in the buffer queue. Alternatively, after receiving any synchronization response, the mobile phone 100 may delete one or more message nodes whose message status in the cache pair list is a processed status.
In some embodiments, considering that the buffer space of the buffer queue is limited, the mobile phone 100 may lower the retry number threshold when the buffer space of the buffer queue is insufficient, which may be beneficial to alleviating the buffer pressure of the buffer queue. Specifically, the method of the embodiment of the application can further include: the mobile phone 100 counts the number of nodes of the message nodes with the message state of the pending state and the in-process state in the cache queue; if the number of nodes reaches the preset threshold number of nodes, the mobile phone 100 sets the threshold number of retries as the first number of retries.
And when the number of the nodes does not reach the threshold value of the number of the nodes, the threshold value of the retry number is the second retry number, and the first retry number is smaller than the second retry number.
For example, the mobile phone 100 may acquire the message status recorded by each message node in the cache queue, and in the case where the message status of any one message node is either one of the waiting processing status and the in-processing status, the message node may be regarded as a message node that does not complete processing. The handset 100 counts the number of nodes in the cache queue that are not processing message nodes. If the number of nodes of the message nodes not completed reaches the preset threshold number of nodes, the mobile phone 100 may set the retry number threshold as the first retry number.
Here, in a case where the number of nodes of the message nodes that have not completed processing in the cache queue does not reach the threshold number of nodes, the threshold number of retries may be a second number of retries, the first number of retries being smaller than the second number of retries. Under the condition that the number of the nodes of the message nodes which are not processed in the cache queue reaches the threshold of the number of the nodes, the mobile phone 100 can consider that the synchronous messages which are not processed currently are overstocked too much, and in order to reduce the situation that the delay of the synchronous messages is too long, the mobile phone 100 can reduce the threshold of retry times, namely, the maximum value of synchronous requests for repeatedly sending the synchronous messages to the intelligent watch 200 by the mobile phone 100 is reduced.
In some embodiments, to reduce the backlog of synchronization messages, handset 100 may reduce the period of cache queue processing in the event that there are more message nodes in the cache queue. Specifically, the method of the embodiment of the application can further include: if the number of nodes of the message nodes in the buffer queue that are not processed reaches the threshold number of nodes, the handset 100 may set the cycle processing time interval of the buffer queue to be the first duration. In the case where the number of nodes does not reach the threshold number of nodes, the cycle processing time interval may be a second duration, the second duration being smaller than the first duration. That is, in the case where the number of nodes of the message nodes that have not completed processing in the cache queue reaches the threshold number of nodes, the cellular phone 100 can reduce the cycle processing time interval of the cache queue. In this way, under the condition that the backlog of the synchronous message which is not processed currently is excessive, the processing speed of the synchronous message can be accelerated by reducing the cyclic processing time interval, and the condition that the delay of the synchronous message is too long can be reduced.
Here, the handset 100 periodically processes the message nodes in the primary cache queue, and the cyclic processing time interval is used to represent a time interval during which the handset 100 periodically processes the message nodes in the cache queue. The handset 100 processes from the message node in the head of the cache queue to the message node in the tail of the queue, and can process the message node in the cache queue once. After processing the message nodes in the cache queue once, the handset 100 again processes the message nodes from the head of the cache queue to the tail of the queue. I.e. the handset 100 performs a round robin processing on the message nodes in the cache queue. The time interval between processing of message nodes in adjacent cache queues may be a round robin processing time interval.
Taking one period of processing the message node in the buffer queue by the mobile phone 100 as an example, that is, a retry flow of the synchronization message, as shown in fig. 10, the processing of the message node in the buffer queue by the mobile phone 100 once may include the following steps:
s801, the mobile phone 100 acquires the synchronization information of the synchronization message recorded by the first message node from the queue head of the buffer queue.
S802, the mobile phone 100 determines whether the currently processed message node is empty. If the currently processed message node is empty, ending the current flow; if the currently processed message node is not empty, S803 is executed.
S803, the mobile phone 100 determines whether the number of retries recorded by the message node currently processed reaches the set threshold number of retries (the first number of retries 2). If the set retry number threshold is reached (the first retry number is 2), S804 is executed. If the set retry number threshold (the first retry number is 2 times) is not reached, S806 is executed.
S804, the mobile phone 100 sets the message state recorded by the message node currently processed to the processed state.
S805, the mobile phone 100 continues to process the next message node, and returns to S802.
S806, if the message state recorded by the message node currently processed is the to-be-processed state, the mobile phone 100 updates the message state recorded by the message node to the in-process state; if the message state recorded by the current message node is in-process, the mobile phone 100 increases the retry number recorded by the current node.
S807, the mobile phone 100 adds a synchronization request of the synchronization message corresponding to the currently processed message node to the transmission queue, and transmits the synchronization request to the smart watch 200.
S808, the handset 100 acquires the node number of the message nodes in the buffer queue which have not completed processing.
S809, the mobile phone 100 determines whether the number of nodes reaches the threshold number of nodes (8). If the threshold number of nodes (8) is reached, S810 is executed. If the node number threshold (8) is not reached, S811 is executed.
S810, the mobile phone 100 sets the cycle processing time interval to be the first duration of 1S, sets the retry number threshold to be the first retry number of 1, and returns to S805.
S811, the mobile phone 100 sets the cycle processing time interval to the second duration 2S, sets the retry number threshold to the second retry number 2 times, and returns to S805.
In some embodiments, the mobile phone 100 performs S73 above, and after adding the synchronization request of the first synchronization message to the transmission queue, the mobile phone 100 sends the synchronization request of the first synchronization message to the wearable device from the transmission queue. Thus, after the smart watch 200 receives the synchronization request, a synchronization response of the synchronization request may be returned to the smart watch 200. Specifically, after S73, the method according to the embodiment of the present application may further include S77-S79.
S77, the mobile phone 100 receives the synchronous response returned by the intelligent watch 200;
s78, the mobile phone 100 searches a fourth message node corresponding to the synchronous response in the cache queue;
if the fourth message node is found, the mobile phone 100 sets the message state in the synchronization information recorded by the fourth message node to the processed state S79.
The synchronization response carries a communication identifier, which can be used as a unique identifier for interaction between the mobile phone 100 and the smart watch 200. The mobile phone 100 may search for a fourth message node corresponding to the synchronization response according to the communication identifier carried in the synchronization response. Specifically, S78 may include: according to the pre-established mapping table, the mobile phone 100 searches the cache queue for a fourth message node corresponding to the communication identifier. And storing the corresponding relation between the message nodes in the cache queue and the communication identifier in the mapping table.
Here, the mobile phone 100 may identify the synchronization message through the communication identifier during the message interaction with the smart watch 200. The mobile phone 100 may carry a communication identifier in the synchronization request of the synchronization message, and after receiving the synchronization request, the smart watch 200 carries the message identifier in the synchronization response and returns to the mobile phone 100. In this way, message interaction between the handset 100 and the smart watch 200 is possible. Because the synchronous response carries the communication identifier, the mobile phone 100 can confirm the message node corresponding to the synchronous response through the communication identifier in the synchronous response, for example, the message node corresponding to the communication identifier carried by the synchronous response can be searched in the mapping table.
Here, the mobile phone 100 receives the synchronization response, and transmits the full data of the response synchronization message to the wearable device, so that the synchronization message can be considered to be synchronized. Meanwhile, in the case that the message node corresponding to the synchronous response is not null and the message state of the message node is not the completed state, the message state recorded by the message node is changed into the completed state. In this way, the mobile phone 100 can timely update the message status of each message node, so as to request retry for the synchronization message that does not complete synchronization.
In some embodiments, if the message node found by the handset 100 is empty, the message node corresponding to the synchronization response is already removed from the cache queue, possibly due to a limitation of the size of the cache space, and no further operation is required.
Taking a scenario in which the mobile phone 100 receives the synchronization response returned by the smart watch 200 as an example, as shown in fig. 11, a processing flow of the synchronization response returned by the mobile phone 100 to the smart watch 200 may include the following steps:
s901, the mobile phone 100 receives the synchronization response sent by the smart watch 200, where the synchronization response carries the communication identifier.
S902, the mobile phone 100 searches the message nodes corresponding to the synchronous response in the cache queue according to the corresponding relation between the communication identifications and the message nodes recorded in the mapping table.
S903, the mobile phone 100 determines whether the message node is empty. Ending the flow if the message node is empty; if the message node is not empty, S904 is performed.
S904, the mobile phone 100 sets the message state recorded by the message node to the processed state.
S905, the handset 100 deletes the message node in the cache queue.
S906, the mobile phone 100 deletes the corresponding relationship of the message node in the mapping table.
In the above description, the preset buffer queue may store the message node of the synchronization message, and through the buffer queue, the mobile phone 100 may repeatedly send the synchronization request of the synchronization message to the smart band 200, so as to reduce the loss of the synchronization message. In addition, the number of retries for the mobile phone 100 to repeatedly send the synchronization request to the smart band 200 can be reduced under the condition that the message nodes in the buffer queue in the to-be-processed state are overstocked too much, the cyclic processing time interval of the periodic processing buffer queue is reduced, the processing speed of the synchronization message is improved, and the delay of synchronization of the synchronization message is reduced. In some embodiments, the handset 100 obtains a synchronization event triggered synchronization message and adds a message node of the synchronization message in a cache queue.
The process of adding message nodes of synchronization messages to a cache queue is further described below. The method of the embodiment of the application can also comprise the following steps:
S1001, the mobile phone 100 responds to the synchronous event, and if the synchronous event is a first event, a second message node is searched in the message nodes of the cache queue;
s1002, in the case that the second message node is found, the handset 100 deletes the second message node from the cache queue.
The synchronization event is used to trigger the mobile phone 100 to send a second synchronization message to the smart band 200, and the first event is used to instruct the smart band 200 to delete the synchronization message related to the first event. The second message node records a synchronization message related to the first event, and the message identifier recorded by the second message node is the same as the message identifier of the second synchronization message.
For example, the synchronization event may be generated based on a user operation or an external message received by the mobile phone 100, and in some cases, the synchronization event may be automatically generated by an application within the mobile phone 100. For example, user operation of a user setting a calendar or alarm may generate a synchronization event. For another example, a synchronization event may also be generated in the event that the handset 100 receives a communication call from another handset 100. For another example, the mobile phone 100 may generate a synchronization event when popup alert information is applied. The synchronization event is used to trigger the handset 100 to send a second synchronization message to the smart band 200.
Here, the mobile phone 100 may determine whether the synchronization event is the first event according to the event identification of the synchronization event in response to the synchronization event. The first event may be used to instruct the smart band 200 to delete the synchronization message associated with the first event. For example, after setting a reminder for an alarm, the user deletes the set reminder for the alarm again. The first event in this case may be a synchronization event indicating a deletion of a synchronization message of the alarm alert.
Here, the second synchronization message triggered by the synchronization event may carry a message identifier, and the mobile phone 100 may search for the second message node in the cache node through the message identifier carried by the second synchronization message. The message identifier recorded by the second message node is identical to the message identifier of the second synchronization message. That is, the synchronization message corresponding to the second message node may be considered to be related to the synchronization event of the second synchronization message, that is, may be considered to be the message node of the synchronization message indicated to be deleted by the second event. In the event that the second message node is found, the handset 100 may delete the second message node from the cache queue.
In this way, in case the synchronization event is the first event (event of deleting the synchronization message), the same message node in the cache queue as the message identification of the second synchronization message, i.e. the message node in the cache queue for which the synchronization message is not needed, can be deleted. Therefore, the mobile phone does not need to process the message nodes to be deleted, and processing resources are saved.
In some embodiments, the mobile phone 100 may determine the synchronization event according to the event identification carried in the synchronization message. In the embodiment of the application, the synchronization event can comprise adding a synchronization message, updating the synchronization message and deleting the synchronization message. If the synchronous event is the first event, the synchronous event indicated by the event identification of the second synchronous message is the deletion synchronous message. If the synchronous event is a second event, the synchronous event indicated by the event identification of the second synchronous message is a newly added synchronous message. If the synchronous event is a third event, the synchronous event indicated by the event identification of the second synchronous message is an updated synchronous message.
In some examples, after S1002 described above, the mobile phone 100 may further confirm whether to send the second synchronization message to the smart band 200. If the mobile phone 100 has sent a synchronization request for a synchronization message related to the first event to the smart band 200, the mobile phone 100 sends a second synchronization message to the smart band 200. If the mobile phone 100 does not send a synchronization request of the synchronization message related to the first event to the smart band 200, the mobile phone 100 does not send a second synchronization message to the smart band 200.
For example, the mobile phone 100 may determine whether the mobile phone 100 has sent a synchronization request of the synchronization message related to the first event to the smart band 200 according to whether the message status recorded in the second message node is a pending status. Or, the mobile phone 100 determines whether the synchronization of the synchronization message related to the first event is completed between the mobile phone 100 and the smart band 200 according to whether the smart band 200 returns the synchronization response of the related synchronization message.
If the mobile phone 100 has sent a synchronization request of the synchronization message related to the first event to the smart band 200, or if synchronization of the related synchronization message has been completed between the mobile phone 100 and the smart band 200, the mobile phone 100 may confirm that the second synchronization message is sent to the smart band 200. Further, the handset 100 may add a message node of the second synchronization message to the cache queue.
If the mobile phone 100 does not send the synchronization request of the synchronization message related to the first event to the smart band 200, or if the synchronization of the synchronization message related to the first event is not completed between the mobile phone 100 and the smart band 200, the second synchronization message may not be sent to the smart band 200. In this way, the mobile phone 100 may delete the message node in the cache queue, which is the same as the message identifier of the second synchronous message, directly according to the message identifier of the second synchronous message without adding the message node of the second synchronous message in the cache queue. Thus, the storage space of the buffer queue can be saved, and meanwhile, the processing flow of the synchronous message is saved.
It will be appreciated that if the synchronisation event triggering the second synchronisation message is not the first event deleting the synchronisation message, it may be the second event or the third event described above. In this case, the handset 100 may further determine whether to add a message node corresponding to the second synchronization message in the buffer queue. The method of the embodiment of the application can also comprise the following steps:
S1003, if the synchronous event is not the first event, the mobile phone 100 judges whether a third message node exists in the cache queue; the message identifier recorded by the third message node is the same as the second synchronous message;
if the third message node does not exist in the buffer queue, the mobile phone 100 adds the message node corresponding to the second synchronization message to the tail of the buffer queue in S1004.
Here, in the case that the synchronization event is not the second event, the mobile phone 100 may search the cache node for a third message node with the same message identifier as the second synchronization message through the message identifier carried by the second synchronization message, and if the third message node does not exist in the cache queue, it may be considered that the message node of the second synchronization message is a newly added synchronization message. The mobile phone 100 may add the message node of the second synchronization message to the tail of the buffer queue, so as to implement adding the message node of the newly added synchronization message to the buffer queue.
Accordingly, the method of the embodiment of the application can further comprise:
s1005, if the third message node exists in the buffer queue, the mobile phone 100 judges whether the message state recorded by the third message node is a processed state;
s1006, if the message status recorded by the third message node is the processed status, the mobile phone 100 deletes the third message node from the buffer queue, and adds the message node corresponding to the second synchronous message at the end of the buffer queue.
Here, if the handset 100 finds the third message node in the cache queue, the handset 100 further determines whether the message status recorded by the third message node is a processed status. If the message state recorded by the third message node is the processed state, it may be considered that the synchronization message corresponding to the third message node has reached the maximum retry number or has waited for timeout, and the mobile phone 100 has no longer sent the synchronization request of the synchronization message to the smart band 200. In this case, the mobile phone 100 may delete the third message node from the buffer queue, and add the message node corresponding to the second synchronization message at the tail of the buffer queue, so that the mobile phone 100 sends the second synchronization message to the smart band 200. In this way, the handset 100 may delete the message node associated with the second synchronization message from the cache queue and having a message state that is in a processed state, and add the message node of the second synchronization message to the tail of the cache queue. In this way, the buffer queue can be updated in time, so that the message synchronization between the mobile phone 100 and the smart band 200 is realized.
Further, the method of the embodiment of the application can further comprise the following steps:
s1007, if the message status recorded by the third message node is not the processed status, the mobile phone 100 determines whether the second synchronization message is a synchronization message triggered by the second event;
If the second synchronization message is the synchronization message triggered by the second event, the mobile phone 100 updates the synchronization information recorded by the third message node according to the second synchronization message S1008.
Here, the second event is used to instruct the mobile phone 100 to send a newly added synchronization message to the smart band 200. The event identifier carried in the second synchronization message triggered by the second event may be a newly added synchronization message. The mobile phone 100 may search the buffer queue for whether the message identifier is the same as the message identifier of the second synchronous message, and the message state is the third message node in the pending state or the in-process state. If there is a third message node in the cache queue whose message state is pending or in-process, it may be considered that there is a synchronization message related to the second synchronization message and that the processing is not completed. In this case, the mobile phone 100 may update the synchronization information recorded by the third message node according to the synchronization information of the second synchronization message. For example, the handset 100 may update the event identification recorded by the third message node to add the synchronization message. For another example, the handset 100 may reset the number of retries recorded by the third message node, i.e., set the number of retries recorded by the third message node to an initial value of 0.
In this way, in the case that there is a message node of the synchronization message that does not complete processing and is related to the second synchronization message in the buffer queue, the mobile phone 100 may update the existing related message node instead of adding the node of the second synchronization message in the buffer queue, that is, combine the related message nodes in the buffer queue, and only set one message node for the same type of synchronization message, so that the number of interactions of the synchronization message between the mobile phone 100 and the smart band 200 can be reduced, and occupation and power consumption of a transmission channel can be reduced to a certain extent.
Taking the mobile phone 100 receiving the second synchronization message triggered by the synchronization event as an example, as shown in fig. 12, the process of adding a message node to the cache queue by the mobile phone 100 may include the following steps:
s1101, the mobile phone 100 acquires the second synchronization message triggered by the synchronization event. The second synchronous message carries a message identifier, an event identifier and a communication identifier.
S1102, the mobile phone 100 determines whether the event identifier of the second synchronization message is a delete synchronization request. If the event identification of the second synchronization message is the delete synchronization request, S1103 is executed. If the event identification of the second synchronization message does not indicate a delete synchronization request, S1106 is performed.
S1103, the handset 100 deletes the message node with the same message identifier as the second synchronous message in the buffer queue.
S1104, the mobile phone 100 determines whether to send the second synchronization message to the smart band 200. The mobile phone 100 confirms the transmission of the second synchronization message to the smart band 200, and performs S1105. Otherwise, the current flow is ended.
S1105, the mobile phone 100 adds a message node of the second synchronization message to the buffer queue, and requests to send the second synchronization message to the smart band 200.
S1106, the mobile phone 100 determines whether there is a message node with the same message identifier as the second synchronization message in the buffer queue. If there is a message node whose message identity is the same as that of the second synchronization message, the mobile phone 100 performs S1108. If not, S1107 is performed.
S1107, the mobile phone 100 adds the message node of the second synchronization message to the tail of the buffer queue, and executes S1113.
S1108, the mobile phone 100 judges whether the message state recorded by the searched message node is a processed state. If the message status recorded by the searched message node is the processed status, the mobile phone 100 executes S1109. Otherwise, S1110 is performed.
S1109, the mobile phone 100 deletes the message node in the processed state from the buffer queue, and adds the message node of the second synchronization message to the end of the buffer queue, and the mobile phone 100 executes S1113.
S1110, the mobile phone 100 determines whether the event identifier of the second synchronization message is an add synchronization message. If the event identification of the second synchronization message is the addition synchronization message, the mobile phone 100 performs S1111. Otherwise, the handset 100 executes S1112.
S1111, the mobile phone 100 updates the event identifier recorded by the message node found in the buffer queue to add the synchronization message, and the mobile phone 100 resets the retry number recorded by the message node.
S1112, the mobile phone 100 performs S1113 without further processing on the second synchronization message whose event is identified as the update synchronization message.
S1113, the mobile phone 100 adds the correspondence between the communication identifier of the second synchronization message and the newly added message node in the mapping table.
Here, in response to the synchronization event, the mobile phone 100 may construct a message node according to the synchronization message carried by the synchronization message triggered by the synchronization event. For example, the key identifier keyId, the category identifier and the event identifier eventId carried by the synchronization message are respectively added in the fields corresponding to the message node, and other fields of the message node are set to default values, for example, the retry number is set to 0, the waiting timeout duration is set to 2s, and the like. In this way, message nodes that synchronize messages may be added to the cache queue.
It can be understood that the embodiment of the present application provides that the above-mentioned message synchronization method can be implemented by adding a preset buffer queue in the mobile phone 100. Accordingly, a message synchronization buffer management module may be added to the architecture of synchronous messaging in fig. 4, and the buffer queue is managed by the message synchronization buffer management module. In order to better explain the message synchronization scheme provided by the embodiment of the present application, the message synchronization scheme provided by the embodiment of the present application is described below by means of fig. 13.
Wherein the dashed box is an added portion. The monitoring management module receives synchronous messages sent by various monitors, wherein the synchronous messages carry key identifiers keyId, category identifiers categorid and event identifiers eventId. The monitoring management module generates a communication identifier (NOTICATIOId) for each synchronous message, and then transmits the synchronous message carrying keyId, categoryId, eventId and the NOTICATIOId to the message synchronous cache management module. The message synchronization management module processes the synchronization message according to the message synchronization scheme provided by the embodiment of the application, such as executing any one of the above retry flow of the synchronization message and the flow of adding the message node in the cache queue. The message synchronization buffer management module sends a synchronization request of the synchronization message to the synchronization messaging management module, and the synchronization messaging management module invokes the transmission channel to send the synchronization request of the synchronization message to the smart band 200. Accordingly, the synchronous messaging management module receives the synchronous response of the smart band 200 to the synchronous request and distributes the synchronous response to the listening management module. The synchronization response carries a notifiationId, and the monitoring management module informs the synchronization response to the cache message synchronization management module. The message synchronization buffer management module may execute the above process of processing the synchronization response according to the synchronization response carrying the notifiationid.
As shown in fig. 14, the message synchronization buffer management module may include a buffer queue, a mapping table, and message synchronization logic.
The buffer queue may be a bidirectional linked list structure, which is a buffer queue of synchronous messages, and has a queue head and a queue tail, and newly added synchronous messages may add message nodes at the queue tail, and the handset 100 may process the message nodes from the queue head to the queue tail of the buffer queue.
The mapping table can record the corresponding relation between the communication identifier of the synchronous message and the message node, and the message node corresponding to the communication identifier can be searched through the mapping table.
The message synchronization logic may include the above-mentioned flow of adding message nodes in the cache queue, the synchronization message retry flow, and the reply flow to the synchronization response returned by the smart band 200. In view of the above description of the flow of adding the message node, the reply flow, and the synchronous message retry flow, the description thereof is omitted here.
The message synchronization scheme provided by the embodiment of the application can be added with a buffer queue in the current synchronous message receiving and sending flow. The newly added buffer queue can realize a retry mechanism of the synchronous message, thereby reducing the loss of the synchronous message and improving the success rate of the message synchronization. In addition, the synchronous messages with the same message type can be combined through the buffer queue, so that the interaction times of the synchronous messages are reduced, the occupation of a transmission channel is reduced, and the power consumption is reduced.
Further embodiments of the present application provide an electronic device comprising: a memory, a communication module, and one or more processors. The memory, communication module, and processor are coupled. The communication module is used for transmitting data or signaling with the wearable device. The memory is used for storing a preset cache queue, the cache queue comprises at least one message node corresponding to the synchronous message, the message node records the synchronous information of the synchronous message, and the synchronous information comprises the retry times. The retry number is used to record the number of times the electronic device repeatedly sends a synchronization request for a synchronization message to the wearable device.
Wherein the memory also stores computer program code comprising computer instructions. The electronic device, when executed by the processor, can perform the various functions or steps performed by the handset 100 in the method embodiments described above. The structure of the electronic device may refer to the structure of the electronic device 500 (i.e., the cellular phone) shown in fig. 5.
The embodiment of the application also provides a chip system which comprises at least one processor and at least one interface circuit. The processors and interface circuits may be interconnected by wires. For example, the interface circuit may be used to receive signals from other devices (e.g., a memory of an electronic apparatus). For another example, the interface circuit may be used to send signals to other devices (e.g., processors). The interface circuit may, for example, read instructions stored in the memory and send the instructions to the processor. The instructions, when executed by a processor, may cause an electronic device to perform the various steps of the embodiments described above. Of course, the system-on-chip may also include other discrete devices, which are not particularly limited in accordance with embodiments of the present application.
Embodiments of the present application also provide a computer readable storage medium, where the computer readable storage medium includes computer instructions, where the computer instructions, when executed on an electronic device, cause the electronic device to perform the functions or steps performed by the mobile phone 100 in the foregoing method embodiments.
Embodiments of the present application also provide a computer program product which, when run on a computer, causes the computer to perform the functions or steps performed by the handset 100 in the method embodiments described above.
It will be apparent to those skilled in the art from this description that, for convenience and brevity of description, only the above-described division of the functional modules is illustrated, and in practical application, the above-described functional allocation may be performed by different functional modules according to needs, i.e. the internal structure of the apparatus is divided into different functional modules to perform all or part of the functions described above.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical functional division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another apparatus, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and the parts displayed as units may be one physical unit or a plurality of physical units, may be located in one place, or may be distributed in a plurality of different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a readable storage medium. Based on such understanding, the technical solution of the embodiments of the present application may be essentially or a part contributing to the prior art or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, including several instructions for causing a device (may be a single-chip microcomputer, a chip or the like) or a processor (processor) to perform all or part of the steps of the method described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read Only Memory (ROM), a random access memory (random access memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely illustrative of specific embodiments of the present application, but the scope of the present application is not limited thereto, and any changes or substitutions within the technical scope of the present application should be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (17)

1. The message synchronization method is characterized by being applied to electronic equipment, wherein the electronic equipment comprises a preset cache queue, the cache queue comprises at least one message node corresponding to a synchronization message, the message node records synchronization information of the synchronization message, and the synchronization information comprises retry times; the retry number is used for recording the number of times that the electronic device repeatedly sends the synchronization request of the synchronization message to the wearable device, and the method comprises the following steps:
the electronic equipment acquires the synchronization information of the first synchronization message recorded by the first message node in the cache queue;
if the retry number in the synchronization information of the first synchronization message is smaller than a preset retry number threshold, the electronic device adds a synchronization request of the first synchronization message in a transmission queue;
The electronic device sends a synchronization request of the first synchronization message from the sending queue to the wearable device.
2. The method of claim 1, wherein the synchronization information further comprises a message status, the message status comprising: a pending state and an in-process state;
the message node of which the to-be-processed state is the state that the message node of the synchronous message is added to the cache queue and waits to be processed but is not processed yet;
the state in the processing is a state that the synchronous request of the synchronous message is sent out from the sending queue for n times, but a synchronous response is not received; wherein N is smaller than N, N is the retry number threshold, and N and N are natural numbers.
3. The method of claim 2, wherein after the electronic device adds the synchronization request of the first synchronization message in the transmit queue, the method further comprises:
the electronic equipment updates the synchronous information recorded by the first message node in the cache queue; wherein the first message node corresponds to the first synchronization message;
the electronic device updates synchronization information recorded by a first message node in the cache queue, including:
If the message state recorded by the first message node is the to-be-processed state and the retry number recorded by the first message node is 0, the electronic device updates the message state recorded by the first message node to the in-process state, and the retry number recorded by the first message node is still 0;
if the message state recorded by the first message node is the in-process state, the electronic device adds 1 to the retry number recorded by the first message node, and the message state recorded by the first message node is still the in-process state.
4. A method according to claim 2 or 3, wherein the message status further comprises: a processed state; the processed state is a state that a synchronization request of the synchronization message has been sent from the send queue and a synchronization response has been received; or the processed state is a state that the synchronous request of the synchronous message is repeatedly sent out from the sending queue for N times, but a synchronous response is not received;
after the electronic device obtains the synchronization information of the first synchronization message recorded by the first message node in the cache queue, the method further includes:
And if the retry number of the first synchronous message is equal to the retry number threshold, the electronic equipment updates the message state recorded by the first message node to the processed state.
5. The method according to claim 4, wherein the method further comprises:
the electronic equipment periodically deletes the message node corresponding to the synchronous message with the message state being the processed state from the cache queue; or,
and deleting the message node corresponding to the synchronous message with the message state being the processed state from the cache queue when the residual cache space of the cache queue is smaller than a preset cache threshold value.
6. The method according to any one of claims 2-5, further comprising:
the electronic equipment counts the node quantity of the message nodes with the message states of the pending state and the in-process state in the cache queue;
if the number of the nodes reaches a preset threshold value of the number of the nodes, the electronic equipment sets the threshold value of the retry times as a first retry time;
and when the number of the nodes does not reach the threshold value of the number of the nodes, the threshold value of the retry number is a second retry number, and the first retry number is smaller than the second retry number.
7. The method of claim 6, wherein the method further comprises:
if the number of the nodes reaches the threshold value of the number of the nodes, the electronic equipment sets a cycle processing time interval of the cache queue as a first duration;
the electronic equipment periodically processes the message nodes in the cache queue once, and the cyclic processing time interval is used for representing the time interval of the electronic equipment periodically processing the message nodes in the cache queue; and under the condition that the number of the nodes does not reach the threshold value of the number of the nodes, the cyclic processing time interval is a second duration, and the second duration is smaller than the first duration.
8. The method according to any of claims 1-7, wherein the synchronization information further comprises a message identification; the method further comprises the steps of:
the electronic equipment responds to the synchronous event, and if the synchronous event is a first event, a second message node is searched in the message nodes of the cache queue; the synchronization event is used for triggering the electronic device to send a second synchronization message to the wearable device, the first event is used for indicating the wearable device to delete the synchronization message related to the first event, the second message node records the synchronization information of the synchronization message related to the first event, and the message identifier recorded by the second message node is the same as the message identifier of the second synchronization message;
And deleting the second message node from the cache queue by the electronic equipment under the condition that the second message node is found.
9. The method of claim 8, wherein the method further comprises:
if the synchronous event is not the first event, the electronic equipment judges whether a third message node exists in the cache queue; wherein, the message identifier recorded by the third message node is the same as the second synchronous message;
and if the third message node does not exist in the cache queue, the electronic equipment adds the message node corresponding to the second synchronous message at the tail of the cache queue.
10. The method of claim 9, wherein the synchronization information further comprises a message status; the method further comprises the steps of:
if the third message node exists in the cache queue, the electronic equipment judges whether the message state recorded by the third message node is a processed state or not;
and if the message state recorded by the third message node is a processed state, deleting the third message node from the cache queue by the electronic equipment, and adding the message node corresponding to the second synchronous message at the tail of the cache queue.
11. The method according to claim 10, wherein the method further comprises:
if the message state recorded by the third message node is not the processed state, the electronic device judges whether the second synchronous message is a synchronous message triggered by a second event; the second event is used for indicating the electronic equipment to send a new synchronization message to the wearable equipment;
and if the second synchronous message is the synchronous message triggered by the second event, the electronic equipment updates the synchronous information recorded by the third message node according to the second synchronous message.
12. The method according to any of claims 9-11, wherein the synchronization information further comprises an event identification of the synchronization message;
wherein the event identification is used for indicating a to-be-processed event of the synchronous message, and the to-be-processed event comprises: adding a synchronization message, updating the synchronization message, and deleting the synchronization message;
if the synchronous event is a first event, the event to be processed indicated by the event identifier of the second synchronous message is a synchronous message deletion;
if the synchronous event is a second event, the event to be processed indicated by the event identification of the second synchronous message is a newly added synchronous message.
13. The method according to any of claims 9-12, wherein the message identification comprises: a key identifier and a category identifier;
wherein the key identifier is used for identifying a listener generating the synchronization message; the category identification is used for identifying a scene category corresponding to the synchronous message.
14. The method according to any one of claims 1-13, further comprising:
the electronic equipment receives a synchronous response returned by the wearable equipment;
the electronic equipment searches a fourth message node corresponding to the synchronous response in the cache queue;
if the fourth message node is found, the electronic device sets the message state in the synchronization information recorded by the fourth message node to be a processed state.
15. The method according to any one of claims 1-14, wherein the synchronization response carries a communication identifier, and the electronic device searches the cache queue for a fourth message node corresponding to the synchronization response;
according to a pre-established mapping table, the electronic equipment searches a fourth message node corresponding to the communication identifier in the cache queue, wherein the mapping table stores the corresponding relation between the message node in the cache queue and the communication identifier.
16. An electronic device, comprising: a memory, a communication module, and one or more processors; the memory, the communication module, and the processor are coupled; the communication module is used for transmitting data or signaling with the wearable equipment; the memory is used for storing a preset cache queue, the cache queue comprises at least one message node corresponding to the synchronous message, the message node records the synchronous information of the synchronous message, and the synchronous information comprises retry times; the retry number is used for recording the number of times that the electronic device repeatedly sends the synchronization request of the synchronization message to the wearable device;
wherein the memory has stored therein also computer program code comprising computer instructions which, when executed by the processor, cause the electronic device to perform the method of any of claims 1-15.
17. A computer readable storage medium comprising computer instructions which, when run on an electronic device, cause the electronic device to perform the method of any of claims 1-15.
CN202211305813.2A 2022-10-24 2022-10-24 Message synchronization method, electronic equipment and storage medium Active CN116743693B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211305813.2A CN116743693B (en) 2022-10-24 2022-10-24 Message synchronization method, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211305813.2A CN116743693B (en) 2022-10-24 2022-10-24 Message synchronization method, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN116743693A true CN116743693A (en) 2023-09-12
CN116743693B CN116743693B (en) 2024-05-07

Family

ID=87908600

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211305813.2A Active CN116743693B (en) 2022-10-24 2022-10-24 Message synchronization method, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116743693B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106911666A (en) * 2017-01-04 2017-06-30 青岛海信移动通信技术股份有限公司 A kind of wearable smart machine and its message treatment method, system
WO2017214930A1 (en) * 2016-06-16 2017-12-21 华为技术有限公司 Method and device for communication between wearable device and mobile terminal
CN112615907A (en) * 2020-12-04 2021-04-06 北京齐尔布莱特科技有限公司 Data synchronization system and method
CN113765771A (en) * 2020-06-05 2021-12-07 安徽华米信息科技有限公司 Instant message processing method and device
CN114125786A (en) * 2021-12-29 2022-03-01 荣耀终端有限公司 Message synchronization method, readable medium and electronic device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017214930A1 (en) * 2016-06-16 2017-12-21 华为技术有限公司 Method and device for communication between wearable device and mobile terminal
CN106911666A (en) * 2017-01-04 2017-06-30 青岛海信移动通信技术股份有限公司 A kind of wearable smart machine and its message treatment method, system
CN113765771A (en) * 2020-06-05 2021-12-07 安徽华米信息科技有限公司 Instant message processing method and device
CN112615907A (en) * 2020-12-04 2021-04-06 北京齐尔布莱特科技有限公司 Data synchronization system and method
CN114125786A (en) * 2021-12-29 2022-03-01 荣耀终端有限公司 Message synchronization method, readable medium and electronic device

Also Published As

Publication number Publication date
CN116743693B (en) 2024-05-07

Similar Documents

Publication Publication Date Title
US11683850B2 (en) Bluetooth reconnection method and related apparatus
CN109891390B (en) Application switching method and device
CN113325996B (en) Split screen display method and device
CN108684206B (en) Searching method and device
CN115002934B (en) Audio service processing system, electronic equipment and Bluetooth headset
WO2020006711A1 (en) Message playing method and terminal
CN114168092B (en) Display method and device
WO2021169538A1 (en) Method for avoiding repeated prompt about notification message, and terminal
EP3499853A1 (en) Ppg authentication method and device
CN115016706B (en) Thread scheduling method and electronic equipment
CN114666694A (en) Bluetooth headset loss prevention method and electronic equipment
KR20150027459A (en) Content transmission method and apparatus
CN109933294B (en) Data processing method and device, wearable device and storage medium
WO2024082906A1 (en) Information acquisition method and apparatus, bluetooth device, terminal device, and storage medium
WO2019191996A1 (en) Data transmission method and device
CN116743693B (en) Message synchronization method, electronic equipment and storage medium
CN114647452A (en) System switching method, device, equipment and storage medium
WO2023179119A1 (en) Near field communication device connection method and apparatus, device, storage medium, and product
CN114371895B (en) Terminal equipment, mail marking method and storage medium
CN113805771A (en) Notification reminding method, terminal equipment and computer readable storage medium
CN115442472B (en) Terminal device, communication control method and storage medium
CN116541188B (en) Notification display method, terminal device and storage medium
CN116016418B (en) Information interaction method and electronic equipment
CN116841686B (en) Application page display method
CN115514840B (en) Method, system, equipment and readable storage medium for notifying message prompt

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