Data communication method and electronic device

By establishing a mapping relationship between the application identifiers and callback parameters of sub-applications in the main application, point-to-point communication between pluggable applications is realized, solving the problem of high performance consumption in communication between sub-applications and improving communication efficiency.

CN114741211BActive Publication Date: 2026-02-27LENOVO (BEIJING) LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210152232.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-18
Publication Date
2026-02-27
Estimated Expiration
2042-02-18

AI Technical Summary

Technical Problem

In pluggable applications, communication between sub-applications requires triggering all sub-application listener events, resulting in significant performance overhead.

Method used

The main application receives communication requests from sub-applications, determines the target callback parameters in the global state database based on the application identifier, and establishes a mapping relationship between the application identifier of the sub-application and the callback parameters to achieve point-to-point communication, avoiding traversing the callback parameters of all sub-applications.

Benefits of technology

It reduces performance overhead between sub-applications, improves communication efficiency, and enables real-time point-to-point bidirectional communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114741211B_ABST
    Figure CN114741211B_ABST
Patent Text Reader

Abstract

The application provides a data communication method, which comprises the following steps: a main application receives a communication request sent by a first sub-application, wherein the communication request carries an application identifier of a second sub-application to be communicated; a corresponding target callback parameter is determined in a global state database based on the application identifier; and the corresponding second sub-application is triggered based on the target callback parameter, so that the second sub-application performs callback. Meanwhile, the application also provides an electronic device.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the communication technology field, in particular to a data communication method and an electronic device. BACKGROUND

[0002] In a plug-in application, when each sub-application communicates, it is usually necessary to trigger all sub-application listening events by traversal, resulting in relatively large communication performance consumption between sub-applications. SUMMARY

[0003] Therefore, the technical solution of the present application is implemented as follows:

[0004] According to an aspect of the present application, a data communication method is provided, which comprises:

[0005] The main application receives a communication request sent by a first sub-application, wherein the communication request carries an application identifier of a second sub-application to be communicated;

[0006] A corresponding target callback parameter is determined in a global state database based on the application identifier;

[0007] The corresponding second sub-application is triggered based on the target callback parameter, so that the second sub-application performs callback.

[0008] In the above solution, the main application receives a communication request sent by a first sub-application, wherein the communication request carries an application identifier of a second sub-application to be communicated, which comprises:

[0009] If a modification event of the first sub-application to a current application identifier in the global state database is listened to, it is determined that the communication request sent by the first sub-application is received;

[0010] Based on the modification event, the modified application identifier is determined as the application identifier of the second sub-application, and the second sub-application is a target communication object of the first sub-application.

[0011] In the above solution, the corresponding target callback parameter is determined based on the application identifier, which comprises:

[0012] The target callback parameter corresponding to the application identifier is found in a listening collector, wherein the listening collector stores a mapping relationship between application identifiers of each sub-application and each callback parameter.

[0013] In the above solution, before the main application receives a communication request sent by a first sub-application, the method further comprises:

[0014] The state data of the first sub-application sent by the first sub-application is received;

[0015] Store the state data of the first sub-application into a global state database, and the global state database at least stores state data of each sub-application.

[0016] In the above scheme, before the main application receives the communication request sent by the first sub-application, the method further comprises:

[0017] Listening to the insertion event of the first sub-application;

[0018] Based on the application name of the first sub-application in the insertion event and the insertion timestamp of the first sub-application, the application identifier of the first sub-application is generated;

[0019] Establish a mapping relationship between the callback parameter of the first sub-application and the application identifier of the first sub-application;

[0020] Store the mapping relationship in a listener collector.

[0021] In the above scheme, before the mapping relationship between the callback parameter of the first sub-application and the application identifier of the first sub-application is established, the method further comprises:

[0022] Receive the callback parameter of the first sub-application sent by the first sub-application.

[0023] In the above scheme, further comprising:

[0024] Listen to the state change of each data and / or each sub-application in the global state database;

[0025] If at least one data and / or sub-application state change is monitored, send a state change notification to the corresponding each sub-application, so that the corresponding each sub-application obtains the latest data from the global state database based on the state change notification.

[0026] In the above scheme, further comprising:

[0027] Listen to the plug-out event of each sub-application including the first sub-application and the second sub-application;

[0028] Based on the plug-out timestamp and the application name in the plug-out event, record the data state of the target sub-application corresponding to the application name in the global state database.

[0029] In the above scheme, further comprising:

[0030] If the re-insertion event of the target sub-application is monitored, the historical insertion timestamp of the target sub-application is obtained from the global state database based on the application name of the target sub-application in the re-insertion event;

[0031] modify the historical insertion timestamp as an insertion timestamp corresponding to the target sub-application in the re-insertion event.

[0032] According to another aspect of the present application, an electronic device is provided, comprising:

[0033] a receiving unit configured to receive a communication request sent by a first sub-application, the communication request carrying an application identifier of a second sub-application to be communicated;

[0034] a determining unit configured to determine a corresponding target callback parameter in a global state database based on the application identifier;

[0035] a triggering unit configured to trigger the corresponding second sub-application based on the target callback parameter, so that the second sub-application performs callback.

[0036] The communication method and the electronic device provided by the present application can obtain the target callback parameter corresponding to the target application identifier through the mapping relationship between the application identifier and the callback parameter of each sub-application, trigger the target sub-application through the target callback parameter, and do not need to traverse the callback parameters of all sub-applications, thereby realizing point-to-point communication between sub-applications and reducing the performance consumption of each sub-application. BRIEF DESCRIPTION OF DRAWINGS

[0037] Figure 1 The flowchart of the data processing method in the present application is shown;

[0038] Figures 2A-2B The structural composition diagram of the plug-in application in the present application is shown;

[0039] Figure 3 The schematic diagram of the listener collector in the present application is shown;

[0040] Figure 4 The system implementation diagram of the embedded application in the present application is shown;

[0041] Figure 5 The schematic diagram of the point-to-point communication between sub-applications in the present application is shown;

[0042] Figure 6 The flowchart of the data communication method in the present application is shown;

[0043] Figure 7 The structural composition diagram of the electronic device in the present application is shown Figure 1 ;

[0044] Figure 8 The structural composition diagram of the electronic device in the present application is shown; DETAILED DESCRIPTION

[0045] The technical solutions of the present application are further described in detail below in combination with the accompanying drawings and specific embodiments.

[0046] Figure 1 For the flow implementation diagram of the data processing method in the present application, as shown in Figure 1 , it includes:

[0047] Step 101, the main application receives the communication request sent by the first sub-application, and the communication request carries the application identifier of the second sub-application to be communicated;

[0048] In the present application, the method can be applied to an electronic device, which can be a computer, a mobile phone, a server, a data processor, etc. The electronic device can run a base application, which can also be called a plug-in main application (hereinafter referred to as a main application), and multiple sub-applications can be inserted into the main application to form a complete communication system.

[0049] In the present application, the main application can listen to the insertion event of each sub-application, and based on the application name of each sub-application in the insertion event and the insertion timestamp corresponding to each sub-application, the application identifier corresponding to each sub-application can be generated for point-to-point communication between each sub-application. When each sub-application is inserted into the main application, it can also send its callback parameter to the main application. In the case where the main application receives the callback parameter sent by each sub-application, it can also establish a mapping relationship between the callback parameter of each sub-application and the corresponding application identifier based on the callback parameter and the application identifier, and then store the mapping relationship in the listener collector, so that when point-to-point communication between each sub-application is carried out subsequently, the target sub-application can be quickly found through the mapping relationship without traversing the callback parameters of all sub-applications, thereby improving the communication efficiency between each sub-application and reducing the performance consumption of each sub-application.

[0050] In an example, when the main application listens to the insertion event of the first sub-application, the application name (e.g., application A) and the insertion timestamp (e.g., January 1, 2021, 1:01:01) of the first sub-application can be extracted from the insertion event, and the application identifier (e.g., application identifier (A)) of the first sub-application can be generated based on the application name and the insertion timestamp. When the first sub-application is inserted into the main application, the first sub-application can also send the callback parameter (e.g., callback parameter A…1) of the first sub-application to the main application. After receiving the callback parameter of the first sub-application sent by the first sub-application, the main application can establish a mapping relationship between the callback parameter and the application identifier of the first sub-application (e.g., callback parameter A…1; application identifier (A)) based on the callback parameter and the application identifier of the first sub-application, and store the mapping relationship in the listener collector. In this way, by establishing the mapping relationship between the callback parameter and the application identifier of the first sub-application, the callback parameter of the first sub-application can be quickly found through the application identifier of the first sub-application when subsequent communication is performed between other sub-applications and the first sub-application, so that the first sub-application is called to perform callback based on the callback parameter. Without traversing all the callback parameters registered by the sub-applications in the main application, the communication consumption between the sub-applications is reduced.

[0051] In the present application, the main application also publishes a global state repository (hereinafter referred to as a global state database) for the data of all sub-applications and event listening. The main application can also listen to communication events between sub-applications through the global state database. If at least one communication event is listened to, it can be determined that the main application receives at least one communication request sent by the first sub-application. The communication request usually carries the application identifier of the second sub-application to be communicated, so that the callback parameter corresponding to the application identifier can be found in the listener collector based on the application identifier carried in the communication request, so as to determine the sub-application corresponding to the callback parameter as at least one second sub-application to be communicated.

[0052] For example, sub-application A wants to communicate with sub-application B in a point-to-point manner. Sub-application A can send a communication request to the main application, where the communication request carries the application identifier B of sub-application B. The main application finds the corresponding callback parameter B in the listener collector based on the application identifier B, and triggers sub-application B to perform the corresponding callback by sub-application B based on the callback parameter B, so as to realize real-time point-to-point communication between sub-application A and sub-application B, without traversing all the callback parameters registered by the sub-applications in the main application, improving the communication efficiency between the sub-applications and reducing the performance consumption between the sub-applications.

[0053] In the present application, the application identifier corresponding to each sub-application will not actually appear in the global state database when each sub-application is in the initialization state, but if at least one sub-application is in the running state, the host application can generate the application identifier of the sub-application in the running state in the global state database, and the application identifier can change with the running of the next sub-application.

[0054] For example, the first sub-application is currently in the running state, and the application identifier A of the first sub-application is generated in the global state database. Even if the first sub-application changes from the running state to the closed state, the application identifier A will still be stored in the global state database; until the next sub-application, for example, the second sub-application, is currently in the running state, the application identifier A in the global state database will be changed to the application identifier B corresponding to the second sub-application. In this way, the use of the historical sub-application can be known through the application identifier displayed in the global state database.

[0055] In the present application, the host application can also listen to the modification event of each sub-application to the current application identifier in the global state database. If at least one first sub-application is listened to the modification event of the current application identifier in the global state database, it can be determined that the at least one first sub-application sends a communication request to the host application. Here, the modification event can be a modification instruction, and the target application identifier to be modified is carried in the modification instruction. The host application can modify the application identifier in the global state database based on the target application identifier carried in the modification event, and determine the modified application identifier in the global state database as the application identifier of the at least one second sub-application to be communicated, and the at least one second sub-application is the target communication object of the at least one first sub-application.

[0056] Here, if the global state database is in the initialization state, it means that there is no application identifier of any sub-application in the global state database. After the host application listens to the modification instruction sent by the sub-application, the target application identifier is directly written into the global state database based on the target application identifier carried in the modification instruction.

[0057] Here, if the global state database already has an application identifier, the host application modifies the current application identifier in the global state database based on the target application identifier carried in the modification instruction after listening to the modification instruction sent by the sub-application, and specifically replaces the current application identifier with the target application identifier.

[0058] For example, the sub-application A intends to communicate with the sub-application B in a point-to-point manner. The sub-application A sends a modification instruction of an application identifier to the main application, where the modification instruction carries the application identifier B. After receiving the modification instruction sent by the sub-application A, the main application modifies the current application identifier in the global state database based on the application identifier B carried in the modification instruction, for example, modifies the current application identifier E to the application identifier B. Then, the main application can determine the application B corresponding to the application identifier B as the target communication object intended to be communicated by the sub-application A. The main application can also find the corresponding callback parameter B in the listening collector based on the application identifier B, so as to trigger the application B based on the callback parameter B, and execute the callback by the application B, thereby realizing the point-to-point communication between the sub-application A and the sub-application B, without the need to traverse all callback parameters registered by all sub-applications in the main application, thereby improving the communication efficiency between sub-applications and reducing the performance consumption between sub-applications.

[0059] In this application, the global state database can also store at least the state data of each sub-application.

[0060] In an example, the main application can also receive the state data of the at least one first sub-application before receiving the communication request sent by the at least one first sub-application, and then store the state data of each sub-application into the global state database. In this way, the main application can listen to the data state of each sub-application through the global state database. If the state and / or data state of at least one sub-application is found to have changed, the main application sends a state change notification to the corresponding sub-application, so that each corresponding sub-application obtains the latest data of the sub-application whose state and / or data state has changed from the global state database based on the state change notification, thereby facilitating the subsequent use and access of each corresponding sub-application.

[0061] In this application, the global state database also stores each data (such as user data, user behavior state data, menu bar data) required by each sub-application, and the main application can also listen to the state change of each data in the global state database. If the state of at least one data is found to have changed, the main application sends a state change notification to each corresponding sub-application, so that each corresponding sub-application obtains the latest data from the global state database based on the state change notification, thereby facilitating the use demand of each corresponding sub-application for the data.

[0062] In step 102, the corresponding target callback parameter is determined in the global state database based on the application identifier.

[0063] In this application, since the listening collector stores the mapping relationship between the application identifier of each sub-application and each callback parameter, the main application can find the target callback parameter corresponding to the application identifier in the listening collector based on the application identifier carried in the communication request.

[0064] For example, the application identifier carried in the communication request is application identifier A, and the main application can find the callback parameter A corresponding to the application identifier A in the listening collector based on the application identifier A. Thus, the search time for traversing all callback parameters registered by the sub-applications in the main application can be reduced.

[0065] In step 103, the second sub-application corresponding to the target callback parameter is triggered based on the target callback parameter, so that the second sub-application performs callback.

[0066] In this application, after the main application finds the target callback parameter in the listening collector, the second sub-application corresponding to the target callback parameter can be triggered based on the target callback parameter, so that the second sub-application performs callback. After the second sub-application listens to the triggering event of the main application, the subsequent logic processing in the second sub-application is executed. Thus, point-to-point communication between the first sub-application and the second sub-application is realized.

[0067] In this application, since the point-to-point communication connection between the first sub-application and the second sub-application is successfully established, at the same time, the second sub-application can also access the first sub-application, so that the first sub-application performs the corresponding callback, to realize the bidirectional communication between the first sub-application and the second sub-application, without considering the processing implementation of the reverse response.

[0068] In this application, the main application can also listen to the plug-out event of each sub-application; and in the case of listening to the plug-out event of at least one sub-application, the data state of the target sub-application corresponding to the application name is recorded in the global state database based on the plug-out timestamp and the application name in the plug-out event.

[0069] For example, the sub-applications inserted in the main application include sub-application A and sub-application B. In the case that the sub-application A is plugged out of the main application, the main application can listen to the plug-out event of the sub-application A, and based on the plug-out event, the plug-out timestamp (such as October 10, 2021, 10:10:10, 10 milliseconds) and the application name A of the sub-application A can be obtained, so that the data state of the target sub-application corresponding to the application name A is recorded in the global state database based on the plug-out timestamp and the application name. When the target sub-application is inserted again, it is not necessary to perform repeated operations such as registration of callback parameters, reporting of data states, etc., so that the insertion time of the target sub-application can be reduced.

[0070] In the present application, if the main application listens to the re-insertion event of the target sub-application, the application name of the target sub-application in the re-insertion event can be used to obtain the historical insertion timestamp (such as January 1, 2021, 1:01:01:001) of the target sub-application from the global state database, and the historical insertion timestamp can be modified to the current insertion timestamp (such as January 1, 2022, 1:01:01:001) of the target sub-application in the re-insertion event. In this way, when the sub-application is re-inserted, only the insertion timestamp of the sub-application needs to be modified, and there is no need to modify or re-register all the data of the sub-application, thereby reducing the performance consumption of each sub-application.

[0071] In the present application, the insertion timestamp and the application name of each sub-application are used to generate the corresponding application identifier, and the mapping relationship between the application identifier and the callback parameter of each sub-application is established. The point-to-point communication between each sub-application can be realized based on the mapping relationship, without the need to traverse all the sub-applications to register the callback parameter in the main application, thereby reducing the performance consumption of each sub-application and improving the implementation efficiency of each sub-application. In addition, the point-to-point communication between each sub-application realized through the mapping relationship is a two-way communication, and each sub-application that successfully establishes communication does not need to consider the reverse response data processing. Each sub-application in the communication can respond to the communication event of the other party in real time, thereby reducing the maintenance difficulty of each sub-application and the performance consumption of the application.

[0072] Figures 2A-2B The structure of the plug-in application in the present application is shown in the schematic diagram as shown in Figure 2A , which includes:

[0073] The main application 201 and a plurality of sub-applications 202, wherein, as shown in Figure 2B , the plurality of sub-applications 202 can be inserted into the main application 201 respectively to form a complete network communication system. For example, the main application 201 can be an IE browser base, and the plurality of sub-applications 202 can be a home page, a category, a shopping cart, a management, a message, and an order.

[0074] Here, the plurality of sub-applications 202 can be plug-ins of the main application 201, and the plurality of sub-applications 202 can be installed on the main application 201 through the insertion interface of the main application 201, or can be respectively unloaded from the main application 201 through the insertion interface, which is a plug-in application. As shown in Figure 2A , it is a schematic diagram before the plurality of sub-applications 202 are inserted into the main application 201, Figure 2B , it is a schematic diagram after the plurality of sub-applications 202 are respectively inserted into the main application 201.

[0075] Figure 3 The schematic diagram of the listening collector in the present application is shown in Figure 3As shown, the listening collector stores the mapping relationship between the application identifier of each sub-application and the corresponding callback parameter, such as: the callback parameter of the sub-application (APP1) is (APP1()), the application identifier is (APP1+16…1), the generated mapping relationship is (APP1+16…1; APP1()); the callback parameter of the sub-application (APP2) is (APP2()), the application identifier is (APP2+16…2), the generated mapping relationship is (APP2+16…2; APP2()); the callback parameter of the sub-application (APP3) is (APP3()), the application identifier is (APP3+16…3), and the generated mapping relationship is (APP3+16…3; APP3()). Wherein, each sub-application generates an insertion timestamp when inserted into the main application, wherein the insertion timestamp is a millisecond-level timestamp, such as a 16-bit numerical string "1611111111111111", and the main application can generate the application identifier corresponding to each sub-application based on the insertion timestamp of each sub-application and the application name corresponding to each sub-application. For example, the application identifier is (APP1+16…1), wherein APP1 is the application name, 16…1 is the insertion timestamp, and here "…" in 16…1 is the omission of the middle digits in the 16-bit data string. Since each sub-application has its own callback parameter, based on which the corresponding function of each application can be called, therefore, the main application can also establish the mapping relationship between the application identifier of each sub-application and the callback parameter corresponding to each sub-application after generating the application identifier corresponding to each sub-application, and store the mapping relationship in the listening collector, so as to quickly call the target sub-application when the point-to-point communication between each sub-application is performed, without traversing all the callback parameters registered by the sub-application in the main application.

[0076] Figure 4 The system implementation schematic diagram of the embedded application in the present application is shown as Figure 4 As shown, it includes:

[0077] The sub-application 401, the base application 402, the global state database 403 and the listening collector 404, wherein the sub-application 401 is embedded in the base application 402, and reports the application name, state data and callback parameter of itself to the base application 402; after the base application listens to the insertion event of the sub-application 401, the application identifier of the sub-application 401 is generated based on the application name and insertion timestamp of the sub-application 401, and the mapping relationship between the application identifier of the sub-application 401 and the callback parameter is established, at the same time, the main application 402 stores the mapping relationship into the listening collector 404; and the state data of the sub-application 401 is stored into the global state database 403.

[0078] Here, the global state database 403 stores the application state, data state, application identifier, user behavior state, user data, etc. of each sub-application.

[0079] Figure 5 This is a schematic diagram of point-to-point communication between the sub-applications in this application, such as... Figure 5 As shown, if sub-application 501 wants to communicate point-to-point with sub-application 502, when sub-application 501 sends a communication request to the main application, it carries the application identifier of sub-application 502 in the communication request. After receiving the communication request, the main application modifies the current application identifier in the global state database 503 based on the application identifier carried in the communication request, so that the modified current application identifier points to sub-application 502. For example, the current application identifier is modified to "APP2+16…2". Then, the main application searches for the callback parameter corresponding to the modified application identifier in the listener collector 504. For example, if the listener collector 504 finds that the callback parameter corresponding to the application identifier "APP2+16…2" is "APP2(){}", then sub-application 502 is triggered to execute the callback. After receiving the listening event, sub-application 502 executes the callback and then executes the subsequent logic inside sub-application 502. This enables real-time point-to-point communication between sub-application 501 and sub-application 502. This communication is bidirectional, and sub-application 501 and sub-application 502 can execute callbacks to each other without increasing their respective performance consumption.

[0080] Figure 6 This is a flowchart illustrating the data communication method in this application, as shown in Figure 2. Figure 6 As shown, the system includes a base application 601, a global state database 602, and a listener collector 603, where the listener collector 603 can be a listener collector registered in the global state database. APP1, APP2, and APP3 are inserted into the base application 601. When APP1, APP2, and APP3 are inserted into the base application 601, they can all register their application names and callback parameters with the base application 601. Each APP can generate an insertion timestamp. Based on the registered application names and corresponding insertion timestamps of APP1, APP2, and APP3, the base application 601 can generate application identifiers corresponding to APP1, APP2, and APP3, and establish a mapping relationship between these application identifiers and their corresponding callback parameters. This mapping relationship can be stored in the listener collector 603 to enable point-to-point communication between APP1, APP2, and APP3.

[0081] For example, APP1 has triggers and listeners. Triggers can initiate point-to-point communication with the target APP in real time, such as APP1 triggering APP2. At this time, the base application 601 can receive the communication request sent by APP1, and this request carries the application identifier of APP2. Simultaneously, when APP1 triggers APP2, it can also generate an application identifier for APP2 in the user menu of the global state database 602 (this application identifier points to APP2). Based on this application identifier (APP2), the global state database 602 can find the corresponding callback parameter in the listener collector 603, and then trigger the callback parameter (APP2). At this time, the listener in APP2 can listen for its own trigger event, and thus trigger the callback parameter module based on this trigger event, so that the callback parameter module can execute its own callback parameters and subsequent logic within APP2.

[0082] Here, APP1, APP2, and APP3 can have different functions. For example, APP1 includes triggers and listeners, APP2 includes listeners and callback parameter modules, and APP3 only includes listeners. Triggers can be used to trigger the target sub-application to be communicated with. Listeners can listen for trigger events (also called communication events), and when a trigger event is detected, the corresponding callback is executed through the callback parameter module.

[0083] Figure 7 This is a schematic diagram of the structural composition of the electronic device in this application. Figure 1 ,like Figure 7 As shown, the electronic device includes:

[0084] The receiving unit 701 is used to receive a communication request sent by the first sub-application, wherein the communication request carries the application identifier of the second sub-application to be communicated.

[0085] The determining unit 702 is used to determine the corresponding target callback parameter in the global state database based on the application identifier;

[0086] Triggering unit 703 is used to trigger the corresponding second sub-application based on the target callback parameter, so that the second sub-application executes the callback.

[0087] In a preferred embodiment, the electronic device further includes:

[0088] The monitoring unit 704 is used to monitor the data status in the global status database.

[0089] If the listening unit 704 listens to a modification event of the current application identifier in the global state database by the first sub-application, the determining unit 702 determines that the communication request sent by the first sub-application is received; and based on the modification event, the modified application identifier is determined as the application identifier of the second sub-application, the second sub-application being a target communication object of the first sub-application.

[0090] In a preferred solution, the electronic device further comprises:

[0091] The searching unit 705 is configured to search for a target callback parameter corresponding to the application identifier in a listening collector of the global state database, the listening collector storing a mapping relationship between application identifiers of each sub-application and each callback parameter.

[0092] In a preferred solution, the electronic device further comprises a storage unit 705;

[0093] The receiving unit 701 is further configured to receive state data of the first sub-application sent by the first sub-application.

[0094] The storage unit 705 is configured to store the state data of the first sub-application into the global state database, the global state database storing at least state data of each sub-application.

[0095] In a preferred solution, the electronic device further comprises a generating unit 706 and an establishing unit 707;

[0096] The listening unit 704 is further configured to listen to an insertion event; if the listening unit 704 listens to the insertion event of the first sub-application,

[0097] The generating unit 706 is configured to generate an application identifier of the first sub-application based on the application name of the first sub-application in the insertion event and the insertion timestamp of the first sub-application.

[0098] The establishing unit 707 is configured to establish a mapping relationship between the callback parameter of the first sub-application and the application identifier of the first sub-application.

[0099] The storage unit 705 is further configured to store the mapping relationship in the listening collector.

[0100] In a preferred solution, the receiving unit 701 is further configured to receive the callback parameter of the first sub-application sent by the first sub-application.

[0101] In a preferred solution, the electronic device further comprises a sending unit 708;

[0102] The listening unit 704 is further configured to listen to state changes of each data in the global state database and / or each sub-application.

[0103] If the monitoring unit 704 monitors that the state of at least one data and / or sub-application changes, the sending unit 708 triggers to send a state change notification to the corresponding sub-application, so that the corresponding sub-application obtains the latest data from the global state database based on the state change notification.

[0104] In a preferred scheme, the electronic device further comprises a recording unit 709;

[0105] The monitoring unit 704 is further configured to monitor a plug-out event of each sub-application including the first sub-application and the second sub-application.

[0106] The recording unit 709 is configured to record the data state of the target sub-application corresponding to the application name in the global state database based on the plug-out timestamp and the application name in the plug-out event.

[0107] In a preferred scheme, the electronic device further comprises an obtaining unit 710 and a modifying unit 711;

[0108] If the monitoring unit 704 monitors the re-plug-in event of the target sub-application, the obtaining unit 710 is triggered to obtain the historical plug-in timestamp of the target sub-application from the global state database based on the application name of the target sub-application in the re-plug-in event.

[0109] The modifying unit 711 is configured to modify the historical plug-in timestamp to the plug-in timestamp corresponding to the target sub-application in the re-plug-in event.

[0110] It should be noted that the electronic device provided in the above embodiments is only exemplified by the division of the above program modules when performing data communication. In actual applications, the above processes can be completed by different program modules according to needs, that is, the internal structure of the device is divided into different program modules to complete all or part of the above processes. In addition, the electronic device provided in the above embodiments and the data communication method provided in the above embodiments belong to the same concept, and the specific implementation process is described in the method embodiments, which will not be repeated here.

[0111] The electronic device provided in the above embodiments and the data communication method provided in the above embodiments belong to the same concept, and the specific implementation process is described in the method embodiments, which will not be repeated here.

[0112] The processor is configured to execute any method step of the above data communication method when running the computer program.

[0113] Figure 8Fig. 2 is a schematic diagram of a structure of an electronic device according to an embodiment of the present application. The electronic device 800 can be a mobile phone, a computer, a digital broadcast terminal, an information transmitting / receiving device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, or the like. Figure 8 The electronic device 800 shown includes at least one processor 801, a memory 802, at least one network interface 804, and a user interface 803. The various components in the electronic device 800 are coupled together by a bus system 805. It will be appreciated that the bus system 805 is used for communication among the components. The bus system 805 includes a data bus to which a processor, a memory, a user interface, and a network interface are connected, a power bus for supplying power to the components, a control bus for controlling the components, and a status signal bus for reporting the status of the components. However, for the sake of clarity, only the data bus is shown in Figure 8 Various buses are collectively referred to as the bus system 805.

[0114] The user interface 803 can include a display, a keyboard, a mouse, a trackball, a click wheel, a key, a button, a touchpad, or a touch screen, etc.

[0115] It can be appreciated that the memory 802 can be a volatile memory or a nonvolatile memory, and can also include both volatile and nonvolatile memory. Among them, the nonvolatile memory can be a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Programmable Read-Only Memory (EPROM), an Electrically Erasable Programmable Read-Only Memory (EEPROM), a ferromagnetic random access memory (FRAM), a Flash Memory, a magnetic surface memory, an optical disc, or a Compact Disc Read-Only Memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a Random Access Memory (RAM) used as an external cache. By way of example and not limitation, many forms of RAM can be used, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDR SDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), Sync Link Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memory 802 described in the embodiments of the present application is intended to include, but is not limited to, these and any other suitable type of memory.

[0116] The memory 802 in the embodiments of the present application is used to store various types of data to support the operation of the electronic device 800. Examples of these data include: any computer programs used for operation on the electronic device 300, such as an operating system 8021 and an application program 8022; contact data; phonebook data; messages; pictures; audio; etc. Among them, the operating system 8021 contains various system programs, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks. The application program 8022 can contain various application programs, such as a media player (Media Player), a browser (Browser), etc., for implementing various application services. The program for implementing the method of the embodiments of the present application can be contained in the application program 8022.

[0117] The method disclosed in the embodiments of the present application can be applied to the processor 801 or implemented by the processor 801. The processor 801 can be an integrated circuit chip with a processing capability. In the implementation process, each step of the above method can be completed by the integrated logic circuit or the instruction in the form of software in the processor 801. The processor 801 described above can be a general-purpose processor, a digital signal processor (DSP), or other programmable logic device, discrete gate or transistor logic device, discrete hardware component, etc. The processor 801 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiments of the present application, the above-mentioned method can be directly embodied as a hardware coding processor to execute, or be executed by a combination of hardware and software modules in the coding processor. The software module can be located in the storage medium, and the storage medium is located in the memory 802. The processor 801 reads the information in the memory 802 and combines the hardware to complete the steps of the above-mentioned method.

[0118] In an exemplary embodiment, the electronic device 800 can be implemented by one or more application specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, micro controllers (MCUs), microprocessors (Microprocessors), or other electronic elements for executing the aforementioned methods.

[0119] In an exemplary embodiment, the embodiments of the present application further provide a computer readable storage medium, for example, the memory 802 including a computer program, which can be executed by the processor 801 of the electronic device 800 to complete the steps of the aforementioned methods. The computer readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM, etc.; or can be various devices including one or any combination of the above memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.

[0120] A computer readable storage medium, which stores a computer program, when the computer program is run by a processor, executes any one of the steps of the above data communication method.

[0121] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative, for example, the division of the units is only a logical function division, and actual implementation can have another division manner, for example, multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the various components shown or discussed can be through some interfaces, indirect coupling or communication connection between devices or units, which can be electrical, mechanical or other forms.

[0122] The units described above as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place or distributed on multiple network units; some or all of the units can be selected according to actual needs to achieve the purpose of the embodiments.

[0123] The methods disclosed in the several method embodiments provided by the present application can be combined arbitrarily without conflict to obtain new method embodiments.

[0124] The features disclosed in the several product embodiments provided by the present application can be combined arbitrarily without conflict to obtain new product embodiments.

[0125] The features disclosed in the several method or device embodiments provided by the present application can be combined arbitrarily without conflict to obtain new method embodiments or device embodiments.

[0126] The above description is merely a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A data communication method, the method comprising: receiving, by a main application, a communication request sent by a first sub-application, the communication request carrying an application identifier of a second sub-application to be communicated; generating the application identifier based on an application name of the sub-application and an insertion timestamp corresponding to an insertion event of the sub-application; determining a corresponding target callback parameter in a global state database based on the application identifier; establishing a one-to-one mapping relationship between the application identifier of the sub-application and the callback parameter of the sub-application; and triggering the corresponding second sub-application based on the target callback parameter, so that the second sub-application performs callback.

2. The method of claim 1, wherein, The main application receives a communication request sent by a first sub-application, the communication request carrying an application identifier of a second sub-application to be communicated, comprising: If a modification event of the first sub-application to the current application identifier in the global state database is listened to, it is determined that the communication request sent by the first sub-application is received; Based on the modification event, the modified application identifier is determined as the application identifier of the second sub-application, and the second sub-application is the target communication object of the first sub-application.

3. The method of claim 1, wherein, The method comprises: In the global state database, the target callback parameter corresponding to the application identifier is searched in a listening collector, and the listening collector stores the mapping relationship between the application identifier of each sub-application and each callback parameter.

4. The method of claim 1, before the main application receives a communication request sent by a first sub-application, the method further comprising: receiving state data of the first sub-application sent by the first sub-application; storing the state data of the first sub-application into a global state database, the global state database storing at least the state data of each sub-application.

5. The method of claim 1, before the main application receives a communication request sent by a first sub-application, the method further comprising: listening to an insertion event of the first sub-application; generating the application identifier of the first sub-application based on the application name of the first sub-application and the insertion timestamp of the first sub-application in the insertion event; establishing a mapping relationship between the callback parameter of the first sub-application and the application identifier of the first sub-application; storing the mapping relationship in a listening collector.

6. The method of claim 5, before the mapping relationship between the callback parameter of the first sub-application and the application identifier of the first sub-application is established, the method further comprising: receiving the callback parameter of the first sub-application sent by the first sub-application.

7. The method of claim 1, further comprising: listening to the state changes of each data and / or each sub-application in the global state database; if at least one data and / or sub-application state change is listened to, sending a state change notification to the corresponding each sub-application, so that the corresponding each sub-application acquires the latest data from the global state database based on the state change notification.

8. The method of claim 1, further comprising: listening to a plug-out event of each sub-application including the first sub-application and the second sub-application; based on a plug-out timestamp and an application name in the plug-out event, recording a data state of a target sub-application corresponding to the application name in the global state database.

9. The method of claim 8, further comprising: if a re-plug-in event of the target sub-application is listened to, based on an application name of the target sub-application in the re-plug-in event, obtaining a historical plug-in timestamp of the target sub-application from the global state database; modifying the historical plug-in timestamp to a plug-in timestamp corresponding to the target sub-application in the re-plug-in event.

10. An electronic device, comprising: a receiving unit configured to receive a communication request sent by a first sub-application, the communication request carrying an application identifier of a second sub-application to be communicated; the application identifier is generated based on an application name of the sub-application and a plug-in timestamp corresponding to a plug-in event of the sub-application; a determining unit configured to determine a corresponding target callback parameter in a global state database based on the application identifier; the application identifier and the callback parameter have a one-to-one mapping relationship; a triggering unit configured to trigger the corresponding second sub-application based on the target callback parameter, so that the second sub-application performs callback.

Citation Information

Patent Citations

  • Method and device for transmitting information

    CN113312193A