A method and apparatus for inter-container communication, an electronic device, and a storage medium

By setting a manager within the application's native interface to record and forward cross-container communication messages, the problem of communication barriers between Flutter containers is solved, enabling data interaction and business collaboration, and improving the application's flexibility and scalability.

CN122507533APending Publication Date: 2026-08-04HANGZHOU EZVIZ SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HANGZHOU EZVIZ SOFTWARE CO LTD
Filing Date
2026-04-20
Publication Date
2026-08-04

AI Technical Summary

Technical Problem

In an application, the inability of multiple Flutter containers to communicate with each other prevents data interaction and business collaboration between pages, reducing the application's business flexibility and scalability.

Method used

Set up a manager within the application's native side to record the communication channels of each container, and receive and forward cross-container communication messages through the manager to achieve message passing and response processing between containers.

Benefits of technology

It enables communication between Flutter containers, improving the application's business flexibility and scalability, and ensuring that the pages hosted by each container can interact with data and collaborate on business processes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122507533A_ABST
    Figure CN122507533A_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a container inter-communication method and device, electronic equipment and storage medium, and relate to the technical field of application programs. In the container inter-communication method, the manager determines the current recorded candidate communication channels after receiving a target communication message; wherein the target communication message is a communication message belonging to cross-container communication transmitted by a container in the application program through a communication channel; from the current recorded candidate communication channels, a target communication channel required for message transmission to at least one target container is determined; wherein the target container is a container to which the target communication message needs to be transmitted; the target communication message is transmitted to each target container through the determined target communication channel, so that each target container performs message response processing on the target communication message. It can be seen that through the present solution, communication between containers in the application program can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of application technology, and in particular to a method, apparatus, electronic device, and storage medium for inter-container communication. Background Technology

[0002] In application development, native code is typically used in conjunction with user interface frameworks such as Flutter. Flutter is an open-source, cross-platform UI (User Interface) framework that allows for the rapid creation of high-quality pages on native platforms (such as Android and iOS).

[0003] In related technologies, communication between the native client and the Flutter container is usually achieved using methods such as BasicMessageChannel (a bidirectional asynchronous message communication channel provided by Flutter) and MethodChannel (a method call communication channel provided by Flutter). In other words, these technologies can enable communication between the native side and the Flutter side.

[0004] However, when an application contains multiple Flutter containers, these containers are isolated from each other and cannot communicate. This results in the inability of the pages hosted by each container to interact with each other and collaborate on business processes, reducing the application's business flexibility and scalability. Summary of the Invention

[0005] The purpose of this application is to provide a method, apparatus, electronic device, and storage medium for inter-container communication, so as to realize communication between containers in an application. The specific technical solution is as follows:

[0006] In a first aspect, embodiments of this application provide a method for inter-container communication, applied to a manager. The manager is located within the native endpoint of an application and records various candidate communication channels. Each candidate communication channel is a communication channel registered by each container of the application with the manager. The communication channel registered by each container is a component used for message communication between the container and the native endpoint. The method includes:

[0007] Upon receiving the target communication message, determine each candidate communication channel currently recorded; wherein, the target communication message is: a cross-container communication message transmitted by a container within the application through a communication channel;

[0008] From the currently recorded candidate communication channels, determine the target communication channel to be used when transmitting messages to at least one target container; wherein, the target container is the container to which the target communication message is to be transmitted.

[0009] The target communication message is transmitted to each target container through the determined target communication channel, so that each target container can perform message response processing on the target communication message.

[0010] Secondly, embodiments of this application provide an inter-container communication apparatus applied to a manager. The manager is located within the native endpoint of an application and records various candidate communication channels. Each candidate communication channel is a communication channel registered by each container of the application with the manager. The communication channel registered by each container is a component used for message communication between the container and the native endpoint. The apparatus includes:

[0011] The first determining module is used to determine each candidate communication channel currently recorded after receiving the target communication message; wherein, the target communication message is: a cross-container communication message transmitted by a container within the application through a communication channel;

[0012] The second determining module is used to determine, from the currently recorded candidate communication channels, the target communication channel to be used when transmitting messages to at least one target container; wherein, the target container is the container to which the target communication message is to be transmitted.

[0013] The forwarding module is used to transmit the target communication message to each target container through the determined target communication channel, so that each target container can perform message response processing on the target communication message.

[0014] Thirdly, embodiments of this application also provide an electronic device, including:

[0015] Memory, used to store computer programs;

[0016] The processor, when executing a program stored in memory, implements the aforementioned method of inter-container communication.

[0017] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-described method for inter-container communication.

[0018] Fifthly, embodiments of this application also provide a computer program product containing instructions that, when run on a computer, cause the computer to perform the aforementioned method of inter-container communication.

[0019] Beneficial effects of the embodiments in this application:

[0020] In the solution provided in this application embodiment, a manager is set up in the native end of the application, and each container in the application can register a communication channel with the manager, that is, register a component for message communication with the native end. This allows the manager to record each candidate communication channel, thereby providing an implementation basis for the manager set up in the native end to call the communication channels of each container. Specifically, after a container generates a cross-container communication message (i.e., a target communication message), it is transmitted to the manager through a communication channel of that container. After receiving the target communication message, the manager determines the target communication channel to be used for message transmission to at least one target container from the currently recorded candidate communication channels. The target communication message is then transmitted to each target container through the determined target communication channel, so that each target container can perform message response processing on the target communication message. It can be seen that this solution can realize communication between containers in the application.

[0021] Of course, implementing any product or method of this application does not necessarily require achieving all of the advantages described above at the same time. Attached Figure Description

[0022] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other embodiments can be obtained based on these drawings.

[0023] Figure 1 A flowchart illustrating a method for inter-container communication provided in an embodiment of this application;

[0024] Figure 2 This is an architectural diagram showing the relationship between the singleton manager and multiple containers of BasicMessageChannel provided in the embodiments of this application.

[0025] Figure 3 Another flowchart of a method for inter-container communication provided in an embodiment of this application;

[0026] Figure 4 This is a diagram illustrating the interaction between the Flutter container and the native client in related technologies.

[0027] Figure 5 Another flowchart of a method for inter-container communication provided in an embodiment of this application;

[0028] Figure 6 Another flowchart of a method for inter-container communication provided in an embodiment of this application;

[0029] Figure 7 A schematic diagram of the structure of an inter-container communication device provided in an embodiment of this application;

[0030] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0031] The technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art based on this application are within the scope of protection of this application. In the technical solutions of this application, the operations of obtaining, storing, using, processing, transmitting, providing, and disclosing user personal information are all performed with the user's authorization.

[0032] To facilitate understanding of the solution, the following is a description of the terminology and concepts involved in the embodiments of this application:

[0033] Flutter: An open-source, cross-platform UI framework that uses the Dart language and allows you to build multi-platform applications from a single codebase.

[0034] Flutter container: A carrier that holds Flutter modules in a native application; an application (also called an application) can contain multiple Flutter containers, each of which is an independent Flutter runtime instance.

[0035] Native: The code portion for platforms such as Android or iOS, responsible for handling platform-specific functions and managing the lifecycle of the Flutter container; native can also be called the native side of the application, and for the Android platform, the native development language is usually Java or Kotlin, while for the iOS platform, the native development language is usually Objective-C or Swift.

[0036] BasicMessageChannel: A bidirectional asynchronous message communication channel provided by Flutter, which supports communication initiated by either party (native or Flutter), and is suitable for scenarios with frequent bidirectional data exchange.

[0037] MethodChannel: A method call communication channel provided by Flutter, which adopts a request-response model and is mainly used for Flutter to call native platform methods and obtain return values.

[0038] Flutter Engine: The core runtime engine of Flutter (the underlying core execution module implemented in C++ within the Flutter framework), responsible for graphics rendering, Dart virtual machine management, and platform message distribution. It serves as a bridge connecting Dart code and the native platform.

[0039] In order to enable communication between containers in an application, thereby enabling data interaction and business collaboration between the pages carried by each container, and improving the business flexibility and scalability of the application, this application provides a method, apparatus, electronic device and storage medium for inter-container communication.

[0040] The following section first introduces a method for inter-container communication provided in the embodiments of this application.

[0041] The method for inter-container communication provided in this application embodiment is applied to a manager. The manager is set in the native end of the application and records each candidate communication channel. Each candidate communication channel is a communication channel registered by each container of the application with the manager. The communication channel registered by each container is a component used for message communication between the container and the native end.

[0042] It's understandable that a manager is a native module within an application (APP) used for inter-container communication. Through this manager, cross-container communication messages transmitted from various communication channels (such as BasicMessageChannel) can be uniformly received. In other words, all cross-container communication messages are passed to the manager for forwarding and processing. For example, in one implementation, the manager can be a centralized manager set up using the singleton pattern (managing cross-container message communication through channels). That is, for an application, there is only one manager for centralized management. Of course, in other implementations, there can be multiple managers, each responsible for a portion of the inter-container message communication, which is also reasonable. Furthermore, it should be noted that a cross-container communication message is a message generated by one container and processed by another container; that is, the destination of this cross-container communication message is not the native application, but another container. For example, container A is used to implement business functions such as displaying product information, adding to cart, adding to favorites, and rating, while container B is used to implement functions such as shopping cart data management, checkout, and amount calculation. When "Add to Cart" is clicked on the product details page, the shopping cart container needs to be notified to refresh the quantity. At this time, container A generates a cross-container communication message, and the destination of this cross-container communication message is container B.

[0043] Furthermore, the application in this application can be a program developed based on a hybrid native and cross-platform UI framework (such as Flutter), and the specific type is not limited. For example, the application can be an instant messaging program, a video platform program, an office program, and so on. In addition, the application in this application can be a program on mobile terminals such as smartphones and tablets, but it is not limited to these.

[0044] In addition, the native side of the application can be the native code side of the system (such as Android or iOS) of the device on which the application runs; when the application is a program developed based on a hybrid of native and Flutter, the container involved in this application embodiment can be a Flutter container; of course, the application can also be a program developed based on a hybrid of native and other cross-platform UI frameworks, and there are problems of mutual isolation between containers and inability to achieve communication. In this case, the container involved in this application embodiment can be a container under the other cross-platform UI framework.

[0045] Furthermore, different containers within the same application can be used to implement different business functions. For example, the homepage container is used for homepage content display, recommendation stream, activity entry, etc.; the personal center container is used for user information display, login status management, settings, etc.; the product details container is used for product information display, adding to cart, favorites, reviews, etc.; the shopping cart container is used for shopping cart data management, settlement, amount calculation, etc.; the payment container is used for payment process, order submission, result callback, etc.; and each container within the same application is generally rendered independently and has an independent lifecycle, corresponding to a complete business scenario. This application does not limit the number of containers within the application, the container creation process, or the business functions implemented.

[0046] It's understandable that each container (such as a Flutter container) has an independent "message processing entry point" on the native side, which can be called a processor. Processors from different containers do not interfere with each other; each only processes communication messages passed by its corresponding container through the communication channel. Based on this, in one optional implementation, the native manager can embed the native-side processor functionality of each container. This processor functionality can then receive cross-container messages passed by the corresponding container through the communication channel. Correspondingly, the communication channel registered by each container can be considered a component used for message communication between that container and the native manager. Of course, in other optional implementations, the native manager can interact with the processors of different containers on the native side to receive cross-container communication messages forwarded by the processor, which is also reasonable.

[0047] One method for inter-container communication may include:

[0048] Upon receiving the target communication message, determine each candidate communication channel currently recorded; wherein, the target communication message is: a cross-container communication message transmitted by a container within the application through a communication channel;

[0049] From the currently recorded candidate communication channels, determine the target communication channel to be used when transmitting messages to at least one target container; wherein, the target container is the container to which the target communication message is to be transmitted.

[0050] The target communication message is transmitted to each target container through the determined target communication channel, so that each target container can perform message response processing on the target communication message.

[0051] In the solution provided in this application embodiment, a manager is set up in the native end of the application, and each container in the application can register a communication channel with the manager, that is, register a component for message communication with the native end. This allows the manager to record each candidate communication channel, thereby providing an implementation basis for the manager set up in the native end to call the communication channels of each container. Specifically, after a container generates a cross-container communication message (i.e., a target communication message), it is transmitted to the manager through a communication channel of that container. After receiving the target communication message, the manager determines the target communication channel to be used for message transmission to at least one target container from the currently recorded candidate communication channels. The target communication message is then transmitted to each target container through the determined target communication channel, so that each target container can perform message response processing on the target communication message. It can be seen that this solution can realize communication between containers in the application.

[0052] The following description, in conjunction with the accompanying drawings, introduces a method for inter-container communication provided by an embodiment of this application.

[0053] like Figure 1 As shown in the embodiments of this application, the method for inter-container communication may include the following steps:

[0054] S101, after receiving the target communication message, determine each candidate communication channel currently recorded;

[0055] The target communication message is: a cross-container communication message transmitted by a container within an application through a communication channel;

[0056] S102, determine the target communication channel to be used when sending messages to at least one target container from the currently recorded candidate communication channels;

[0057] The target container is the container to which the target communication message is to be transmitted;

[0058] S103, through the determined target communication channel, the target communication message is transmitted to each target container so that each target container can perform message response processing on the target communication message.

[0059] The manager can provide registration and deregistration mechanisms for each container of the application (such as a Flutter container). After each container in the application is created, the components used for message communication between the container and the native client can be registered with the manager, so that the manager can record each registered communication channel as a candidate communication channel. When the life cycle of a container ends, the manager can deregister the communication channels registered by the container. Thus, the manager can ensure the synchronization of the container life cycle and channel management.

[0060] For example, the manager can maintain a dynamic array (or list) to store and manage all active candidate communication channels (i.e., currently existing candidate communication channels). Understandably, for the Flutter container, the registered communication channels can be bidirectional asynchronous message communication channels (such as BasicMessageChannel, also known as BasicMessageChannel instances). In this case, the manager stores and manages all active BasicMessageChannel instances through a dynamic array (or list); for example... Figure 2 As shown: The application's native side has a singleton manager (i.e., the manager in this application). There are three containers in the application: Flutter container 1, Flutter container 2, and Flutter container 3. The communication channels of these three containers are BasicMessageChannel1, BasicMessageChannel2, and BasicMessageChannel3, respectively. These three containers can register their respective communication channels with the singleton manager, so that the singleton manager can maintain a Channel array [Channel1, Channel2, Channel3]. Channel1, Channel2, and Channel3 are BasicMessageChannel1, BasicMessageChannel2, and BasicMessageChannel3, respectively. In this way, the singleton manager performs unified reception of native messages (i.e., unified native message reception and processing). Thus, through this centralized management method, the message routing and distribution problem when multiple channels coexist is effectively solved.

[0061] Of course, for containers under other cross-platform UI frameworks, the communication channel registered by each container can be a component under that other cross-platform UI framework used for message communication with the native side. The manager can be used to store and manage the components under that other cross-platform UI framework used for message communication with the native side.

[0062] Furthermore, to facilitate understanding of containers, we will use the Flutter container as an example: The Flutter container is managed by the native platform and internally hosts the Flutter engine and the Flutter client. Specifically, the Flutter client: relies on the FlutterEngine (engine) to run and communicates with the native platform across platforms through BasicMessageChannel (i.e., the communication channel). It is implemented in Dart and is a logic module used to display pages, handle interactions, and communicate with the native platform. BasicMessageChannel is provided by the Flutter framework and relies on the Flutter engine's message passing mechanism (BinaryMessenger) at its core, acting as a communication intermediary between the Flutter client and the native platform (also known as a communication intermediary between the Flutter container and the native platform). For clarity and a well-defined layout, the following text will combine... Figure 4 This paper introduces the role of BasicMessageChannel in the interaction between the Flutter container and the native client. It should be noted that if the container in this application is a Flutter container, the steps executed by the container can be specifically executed by the Flutter client within the Flutter container, and the communication between containers can refer to the communication between Flutter clients carried between different containers.

[0063] Based on the aforementioned registration mechanism, after a container generates a cross-container communication message (i.e., the target communication message), since containers are isolated, it can be transmitted to the manager through the container's communication channel for forwarding. Correspondingly, upon receiving the target communication message, the manager, which maintains a list of communication channels registered by each container, can determine the target communication channel to use when forwarding the message, based on the currently recorded candidate communication channels. This involves finding the communication channel registered by the destination container (i.e., the target container). There can be one or more target containers, and correspondingly, one or more target communication channels. Thus, the target communication message is forwarded to the target container via the target communication channel (e.g., by calling the target communication channel's native channel method). This allows the target container to process the message if it can respond to it, thereby achieving communication between a container and a target container. In the Flutter container context, this translates to communication between the Flutter client hosted in one container and the Flutter client hosted in the target container. It should be noted that when an application is developed using a hybrid approach of native and Flutter, after a container generates cross-container communication messages, these messages are passed to the manager via a communication channel. This communication channel can serialize the cross-container communication messages and then pass the serialized messages through the Flutter Engine to the native-side manager. For details on the specific processing of this communication channel, please refer to [link to relevant documentation]. Figure 4 The relevant embodiments are described below.

[0064] Furthermore, the at least one target container can be a container other than the message sender, in which case the communication between containers is point-to-point; or, the at least one target container can be multiple containers other than the message sender, in which case the communication between containers is point-to-multipoint; or, the at least one target container can be any other container other than one or more containers, in which case the communication between containers is exclusive broadcast. For example, in one implementation, the at least one target container can be determined by analyzing the target communication message, the specific process of which is described below; of course, in other implementations, it is also reasonable for the manager to determine the target container based on a pre-determined communication relationship between containers (i.e., the correspondence between each container and other containers capable of cross-container communication).

[0065] Taking the example that the at least one target container is all containers except the message sender of the target communication message (which can be understood as exclusionary broadcasting), in the case of application development that is a hybrid of native and Flutter, the solutions implemented by S101-S103 above are as follows:

[0066] When the native singleton manager receives a cross-container communication message from a BasicMessageChannel, it will execute the following message forwarding process:

[0067] Step 1, Message Source Identification: Record the BasicMessageChannel (also known as a BasicMessageChannel instance) that sent the target communication message and mark it as the message source channel;

[0068] Step 2, Target Channel Filtering: Filter and exclude message source channels from the BasicMessageChannel array maintained by the manager to form a target channel set;

[0069] Step 3: The BasicMessageChannel array is an array that records each candidate communication channel. When the at least one target container comprises all containers except the message sender, the process of identifying the message source and filtering the target channel described above can be used to determine each target communication channel, thus forming a target channel set.

[0070] Step 4, Message Broadcasting and Distribution: Traverse the target channel set and forward the message to the corresponding Flutter container through each BasicMessageChannel;

[0071] Step 5, Anomaly Handling: Capture and handle anomalies that may occur during the forwarding process, such as channel failure or message sending failure, to ensure the reliability of message forwarding.

[0072] The method for capturing abnormal situations can be any method that can achieve this; and for exception handling, mechanisms such as retransmission mechanisms can be used to ensure the reliability of message forwarding. This application does not impose any specific limitations.

[0073] The specific execution process is as follows: Figure 3 As shown:

[0074] S301, The manager has received a message; that is, it has received the target communication message transmitted through the BasicMessageChannel.

[0075] S302, Get all BasicMessageChannel arrays; that is, get the BasicMessageChannel array;

[0076] S303, filter out BasicMessageChannel messages;

[0077] S304, Create a new array; this new array does not contain the BasicMessageChannel that sent the target communication message;

[0078] S305, Traverse the new array. During the traversal of the new array, if there is a BasicMessageChannel (there is a BasicMessageChannel that has not been traversed), then S306 is triggered; if there is no BasicMessageChannel, then the forwarding is completed.

[0079] S306 forwards the message via BasicMessageChannel (forwarding the message via the currently traversed BasicMessageChannel) to send it to other Flutter containers, and returns S305 to perform traversal.

[0080] In this way, the message broadcasting capability of exclusionary broadcasting is achieved, enabling messages sent by a single container to be received by all other containers.

[0081] Additionally, as an example, in one implementation, determining the target communication channel to be used when message passing to at least one target container from the currently recorded candidate communication channels may include:

[0082] Based on a pre-established mapping relationship between containers and candidate communication channels, the target communication channel to be used when sending messages to at least one target container is determined from the currently recorded candidate communication channels; wherein, the candidate communication channel mapped to each container in the mapping relationship is the communication component registered by that container.

[0083] In this implementation, the at least one target container can be determined first, and then, based on the pre-established mapping relationship, the target communication channel to be used when transmitting messages to the at least one target container can be quickly determined from the currently recorded candidate communication channels.

[0084] Furthermore, to enable effective and reliable communication between multiple containers, the message format for interaction between the two parties can be standardized to ensure that both the message sender and receiver can accurately identify and parse the message content. Based on this requirement, a message data structure (i.e., message structure) can be defined, namely the preset message data structure. For clarity and ease of understanding, the preset message data structure and the processing procedure of the target container message for the target communication message will be illustrated in the following text.

[0085] Optionally, the communication method between containers may also include the following steps:

[0086] Receive feedback messages about the target communication messages transmitted through the target communication channel;

[0087] The feedback message is fed back to the corresponding container (i.e., the container that is the message sender) through the communication channel used to transmit the target communication message.

[0088] For certain target communication messages, after the target container responds to the communication message, it needs to provide feedback on the return value to the container that is the message sender. Therefore, the manager can receive the feedback message about the target communication message transmitted through the target communication channel, and send the feedback message back to the container that is the message sender through the communication channel used to transmit the target communication message, so that the container that is the message sender can process the received feedback message accordingly, such as displaying or storing it.

[0089] In the solution provided in this application embodiment, a manager is set up in the native end of the application, and each container in the application can register a communication channel with the manager, that is, register a component for message communication with the native end. This allows the manager to record each candidate communication channel, thereby providing an implementation basis for the manager set up in the native end to call the communication channels of each container. Specifically, after a container generates a cross-container communication message (i.e., a target communication message), it is transmitted to the manager through a communication channel of that container. After receiving the target communication message, the manager determines the target communication channel to be used for message transmission to at least one target container from the currently recorded candidate communication channels. The target communication message is then transmitted to each target container through the determined target communication channel, so that each target container can perform message response processing on the target communication message. It can be seen that this solution can realize communication between containers in the application.

[0090] To better understand BasicMessageChannel, the following will combine... Figure 4This section introduces the role of BasicMessageChannel in the interaction between the Flutter container and the native client.

[0091] BasicMessageChannel is an important platform communication mechanism provided by Flutter. It serializes transmitted data into binary format using a built-in message codec and then uses the Flutter Engine as an intermediary bridge for message forwarding, thus enabling bidirectional communication between the Flutter layer and the native platform (Android / iOS). The advantage of this communication method is that it supports continuous message passing and bidirectional communication, making it suitable for scenarios requiring frequent interaction. Specifically,

[0092] like Figure 4 As shown, a Flutter container can contain the Flutter side, a message codec (built into BasicMessageChannel), and the Flutter Engine. The native side (Android / iOS) is the code portion based on the Android / iOS platform. The native codec serves the native side and can be built into the native side or not; for example, it can exist in the system, hardware, drivers, or external devices. The interaction process between the Flutter container and the native side can include:

[0093] Step 1. Send a message (Dart object);

[0094] In other words, the Flutter client sends a message (Dart object) to the BasicMessageChannel for processing by the message codec within the BasicMessageChannel. Here, the Dart object can be understood as the representation of the message in the Dart code (the Flutter client encapsulates the message to be transmitted into a Dart object), and the message here is a communication message, which is the message that the native client needs to process.

[0095] Step 2. Serialize into binary data;

[0096] In other words, BasicMessageChannel serializes received messages (Dart objects) into binary data using its internal message codec.

[0097] Step 3. Pass the information via channel name;

[0098] After BasicMessageChannel serializes the message (Dart object) into binary data using its internal message codec, it passes the binary data to the Flutter Engine. During this process, the channel name of BasicMessageChannel can be passed to the Flutter Engine as a routing identifier, enabling the Flutter Engine to determine the target channel of the message based on the channel name and thus correctly route the message. Specifically, the Flutter Engine can route the binary data to the corresponding native endpoint (the processor corresponding to the container mentioned above) based on the channel name.

[0099] Step 4. Forward binary data;

[0100] That is, Flutter Engine forwards binary data to the native codec.

[0101] Step 5. Deserialization;

[0102] In other words, the native codec deserializes binary data to obtain a native object, which is an equivalent representation of the message content carried by the Dart object on the native platform.

[0103] Step 6. Pass the raw object;

[0104] In other words, the native codec passes the native object to the native end, that is, the native object obtained by deserialization is passed to the native end for subsequent processing.

[0105] Step 7. Process the message.

[0106] That is, the native client processes messages.

[0107] Implement Scenario 1: The message sending process from Flutter to native code through steps 1-7.

[0108] Step 8. Send a response / message;

[0109] In other words, when the native application needs to send a response / message to the Flutter container, it can send the response / message to the native codec to call the native codec to serialize the response / message.

[0110] Step 9. Serialization;

[0111] That is, the native codec serializes the received response / message to obtain binary data.

[0112] Step 10. Transmit via channel;

[0113] The native client calls the corresponding native interface method of BasicMessageChannel to write the serialized binary data into the channel (i.e., into the corresponding field in the native interface method) and pass it to Flutter Engine.

[0114] Step 11. Forward the data;

[0115] After receiving binary data, Flutter Engine forwards it to the corresponding BasicMessageChannel based on the channel name.

[0116] Step 12. Deserialization;

[0117] That is, under the call of BasicMessageChannel, the message codec can deserialize binary data to obtain Dart objects (i.e. Dart objects that represent the above-mentioned responses / messages).

[0118] Step 13. Pass the Dart object;

[0119] In other words, after BasicMessageChannel obtains a Dart object by calling the message codec, it can pass the obtained Dart object to the Flutter side.

[0120] Step 14. Process the message.

[0121] That is, the Flutter side processes the message response of the received Dart object.

[0122] Implement Scenario 2: The message sending process from native to Flutter (reply or send proactively) through steps 8-14.

[0123] Thus, by executing steps 1-14, bidirectional communication between native and Flutter is completed, and during the bidirectional communication process, BasicMessageChannel can be used to implement cross-platform communication between the native end and the Flutter container.

[0124] To better understand the preset message data structure, the following provides an exemplary description of the preset message data structure and the target container's processing of the target communication message.

[0125] The preset message data structure contains a first field representing the message type and a second field representing the message content.

[0126] For example, the structure of the preset message data structure can be as follows:

[0127] class Message {

[0128] / / / Message Types

[0129] final String type;

[0130] / / / Message data (i.e., message content)

[0131] final dynamic data;

[0132] };

[0133] The aforementioned preset message data structure contains two fields:

[0134] The `type` field (i.e., the first field): Serves as a unique identifier for the message type. Its value is a string, used to distinguish messages with different purposes and meanings. Through the `type` field, the target container of the message receiver can quickly determine the category of the communication message and execute corresponding business logic processing based on different `type` values. For example, in specific applications, different `type` values ​​such as "getUserInfo", "updateConfig", and "navigateToPage" can be defined to represent different operation requests. `getUserInfo` represents an operation request to retrieve the current user information (a query request), `updateConfig` represents an operation request to update the APP (application) configuration (a modification request), and `navigateToPage` represents a page navigation operation request (a navigation request).

[0135] The `data` field (the second field) carries the actual message content transmitted in the communication message. Its type is `dynamic`, indicating that it accepts data of any type, including basic data types (such as `String`, `int`, and `bool`), collection types (such as `List` and `Map`), and complex custom objects. This flexible design allows cross-container communication messages to adapt to various communication scenarios and data transmission needs.

[0136] Based on the first and second fields mentioned above, the preset message data structure can also take the following form:

[0137] class Message {

[0138] / / / Message Types

[0139] final String type;

[0140] / / / Message data (i.e., message content)

[0141] final dynamic data;

[0142] const Message({required this.type, this.data});

[0143] };

[0144] In the aforementioned default message data structure, `const Message({required this.type,this.data})` is a Dart constructor. `required this.type` in this Dart constructor indicates that the `type` parameter must be passed in, while `this.data` is an optional parameter. This default message data structure allows for a more comprehensive representation of the `Message` class.

[0145] It should be emphasized that the two preset message data structures mentioned above are merely examples and should not be construed as limiting this application.

[0146] Based on the aforementioned preset message data structure, after the manager forwards the target communication message, in one implementation, the target container can directly perform message response processing based on the field values ​​of the first and second fields in the target communication message; or, in another implementation, if it is determined that the field value of the first field in the target communication message matches the message type it can process, then message response processing is performed based on the field values ​​of the first and second fields. That is, the message type is first verified using the field value of the first field in the target communication message; if the verification passes, message response processing is performed based on the field values ​​of the first and second fields, thereby ensuring the reliability and effectiveness of the message processing process. For example, whether the field value of the first field in the target communication message matches the message type it can process can be identified through matching analysis.

[0147] Taking an application developed using a hybrid approach of native and Flutter as an example, the process of the Flutter container (i.e., the target container) receiving and processing messages can be described as follows:

[0148] Step 1, Message Reception:

[0149] The destination Flutter container listens for message events in BasicMessageChannel (i.e., the target communication channel) and obtains the target communication message (also known as message data) forwarded by the native client.

[0150] Step 2, message type parsing;

[0151] Extract the type field from the received target communication message; the type field is used to identify the message type.

[0152] Step 3: Message filtering and judgment;

[0153] By comparing strings and other methods, it is determined whether the type of the received message matches the type of message that the destination's Flutter container needs to process;

[0154] Step four, message processing;

[0155] If the message type matches, extract the business data (i.e., message content) carried in the data field from the target communication message and execute the corresponding business logic processing;

[0156] If the message type does not match, the message is ignored and no processing is performed to avoid unnecessary resource consumption.

[0157] Step 5, Feedback of Processing Results (Optional): Depending on business needs, the processing results can be fed back to the message sender or other containers through the same channel mechanism.

[0158] Thus, through steps one through five, the destination Flutter container can receive and process messages across containers. A message type filtering mechanism ensures that each Flutter container only processes messages relevant to its own business logic, achieving precise cross-container communication.

[0159] In one possible embodiment, such as Figure 5 As shown, the inter-container communication method provided in this application, applied to a manager, may include the following steps:

[0160] S501, after receiving the target communication message, determine each candidate communication channel currently recorded;

[0161] The target communication message is a cross-container communication message transmitted by a container within an application through a communication channel; and the target communication message carries first indication information, which is used to identify the container that is the message receiver.

[0162] S502, first indication information is parsed from the target communication message, and at least one target container is determined based on the parsed first indication information;

[0163] The target container is the container to which the target communication message needs to be transmitted;

[0164] S503, determine the target communication channel to be used when transmitting messages to the at least one target container from the currently recorded candidate communication channels;

[0165] S504, through the determined target communication channel, transmit the target communication message to each target container so that each target container can perform message response processing on the target communication message.

[0166] S501 is the same as S101 in the above embodiments, and S503-S504 are the same as S102-S103 in the above embodiments, and will not be described again here. Furthermore, determining the current recorded candidate communication channels does not have a strict execution order with S502; they can be executed in parallel or sequentially, which is reasonable.

[0167] In this embodiment, to enable the manager to quickly identify the target container, a first indication information can be set in the target communication message. The manager can then parse the target communication message to obtain the first indication information, and thereby determine the target container as the message receiver using this information. The specific form of the first indication information is not limited, provided that the target container can be identified using it. For example, the first indication information can be an ID array, where the IDs can be identifiers of the target container, or they can be identifiers of containers that need to be excluded as message receivers, which is also reasonable.

[0168] The specific setting of the first indication information in the target communication message can be varied. Correspondingly, there are also various ways to parse the first indication information from the target communication message. For the sake of clarity and layout, these will be described in other embodiments.

[0169] In this embodiment, by setting a first indication information in the target communication message, the manager can quickly determine the target container corresponding to the target communication message based on the first indication information; therefore, high communication efficiency can be guaranteed while realizing inter-container communication.

[0170] In one possible embodiment, the target communication message satisfies a preset message data structure, which includes a first field for characterizing the message type. The value of the first field is the value obtained by concatenating the first indication information and the type information for indicating the message type according to a predetermined concatenation method.

[0171] The first indication information parsed from the target communication message includes:

[0172] Parse the value of the first field in the target communication message and extract the first indication information from the parsed field value.

[0173] In this embodiment, when the target communication message meets the preset message data structure, the first indication information can be set in the target communication message based on the existing first field. Specifically, the first indication information and the type information used to indicate the message type can be concatenated according to a predetermined concatenation method, and the concatenated content is used as the field value of the first field. At this time, the first field (such as the type field) can be used to represent two meanings: message type and message receiver.

[0174] The pre-defined splicing method can be set according to the actual situation. For example, the first indication information and the type information used to indicate the message type can be spliced ​​together by setting splicing characters or placeholders.

[0175] Accordingly, when it is necessary to parse the first indication information from the target communication message, the field value of the first field can be parsed first, and then the first indication information can be extracted from the parsed field value according to the extraction method corresponding to the predetermined splicing method, so as to determine the at least one target container based on the extracted first indication information.

[0176] In this embodiment, the first indication information is set in the target communication message based on the first field in the preset message data structure. This can achieve the goal of balancing the need for setting the first indication information with the simplicity and lightweight nature of the preset message data structure, thereby ensuring the stability of message transmission.

[0177] In one possible embodiment, the target communication message satisfies a preset message data structure, which includes a third field; the value of the third field is a first indication information.

[0178] The first indication information parsed from the target communication message includes:

[0179] Parse the value of the third field in the target communication message to obtain the first indication information.

[0180] Provided that the target communication message meets the preset message data structure, a third field can be added to set the first indication information. Specifically, given that the preset message data structure includes a first field and a second field, a third field is added to identify the container of the message receiver, and the value of this third field is the first indication information. It is understood that the name of this third field can be set according to the actual situation, and this application does not limit it.

[0181] Correspondingly, when it is necessary to parse the first indication information from the target communication message, the first indication information can be obtained by simply parsing the field value of the third field in the target communication message. Based on the extracted first indication information, the at least one target container can be determined.

[0182] In this embodiment, by adding a third field to the preset message data structure, the first indication information is set in the target communication message, which can achieve the goal of balancing the need for setting the first indication information and the extraction efficiency of the first indication information.

[0183] In one possible embodiment, any container is used to: generate a communication message matching the page operation to be passed to the manager if the page operation is a cross-container communication operation when any page operation occurs on the page it contains; and pass the generated communication message to the manager through a communication channel.

[0184] The method for determining whether a target communication message has been received may include:

[0185] If a communication message is received from a container through a communication channel, it is determined that the target communication message has been received.

[0186] In this embodiment, the manager can only receive and process cross-container communication messages between containers. In this case, for any page operation within a container, if any page operation is a cross-container operation, the container can generate a communication message matching the page operation to be passed to the manager; this is the target communication message. Correspondingly, since any container only passes cross-container communication messages to the manager, the manager can determine that it has received the target communication message when it receives a communication message from a container through a communication channel. It is understood that other communication messages between containers besides cross-container messages can be sent to other processing modules on the native side (similar to...). Figure 4 (The processing procedure).

[0187] There are several ways to identify whether a page operation is an operation that triggers cross-container communication. For example, in one implementation, the types of operations used to trigger cross-container communication can be pre-recorded. Then, after any page operation is generated, it can be identified whether the type of the page operation matches the pre-recorded types. If they match, the page operation is identified as an operation that triggers cross-container communication; otherwise, it is identified as an operation that does not trigger cross-container communication. Alternatively, in another implementation, a correspondence can be established between various page operations that can be generated by the page within the container and the tag values ​​of specified tags. The specified tags are used to indicate whether an operation triggers cross-container communication. For example, the tag values ​​of the specified tags may include a first tag value indicating that an operation triggers cross-container communication, and a second tag value indicating that an operation does not trigger cross-container communication. Therefore, after any page operation is generated, based on this correspondence, it can be identified whether the page operation is an operation that triggers cross-container communication.

[0188] Wherein, when the target communication message conforms to the above-mentioned preset message data structure, the method for generating the communication message that matches any page operation and is used to transmit to the manager may include: determining the message type and message content of the communication message to be generated based on any page operation, thereby generating the field value of the first field based on the determined message type, and generating the field value of the second field based on the determined message content, and generating the field value of the first field and the field value of the second field.

[0189] In this embodiment, the manager is only used to process cross-container communication messages between containers. Specifically, when any container performs a cross-container communication operation on any page, it generates a communication message matching that page operation and transmits it to the manager via a communication channel. Correspondingly, the communication message directly received by the manager is identified as the target communication message. Therefore, the solution provided in this embodiment enables communication between containers within an application, ensuring communication reliability and efficiency while effectively alleviating the processing load on the manager.

[0190] In one possible embodiment, any container is used to: generate a communication message matching the page operation according to a predetermined message generation method when any page operation occurs on the page it contains, and send the generated communication message to the manager through a communication channel; the predetermined message generation method includes: analyzing whether the page operation is a cross-container communication operation, and if so, generating a communication message matching the page operation and carrying second indication information for indicating that it belongs to cross-container communication;

[0191] The methods for determining whether a target communication message has been received include:

[0192] When a communication message is received from a container through a communication channel, if the received communication message carries second indication information, it is determined that the target communication message has been received.

[0193] In this embodiment, the manager can process cross-container communication messages or non-cross-container communication messages. That is, the manager can receive both cross-container and non-cross-container communication messages, acting as a relay for each communication message from each container. Based on this approach, when any page operation occurs on any page within a container, it can analyze whether the page operation triggers cross-container communication. If yes, a communication message matching the page operation and carrying second indication information indicating cross-container communication is generated; if no, a communication message matching the page operation but not carrying the second indication information, or a communication message matching the page operation but carrying third indication information indicating non-cross-container communication, can be generated. The generated communication message is then transmitted to the manager. Correspondingly, upon receiving a communication message, if the manager analyzes and finds that the received communication message carries the second indication information, it determines that the target communication message has been received; otherwise, it determines that the target communication message has not been received. The communication messages generated by any of these containers can conform to the aforementioned preset message data structure.

[0194] Understandably, in order to set the second indication information in a cross-container communication message, for example, in one optional implementation, a field can be added to the preset message data structure: a fourth field. This fourth field indicates whether it belongs to cross-container communication. If the field value of the fourth field is the second indication information, it can be considered a cross-container communication message. Of course, in other optional implementations, the first indication information can also be used as concatenation content and concatenated into the field value of the first field, the field value of the second field, or the field value of the third field, which is also reasonable.

[0195] This application does not limit the specific naming of the fourth field, nor does it limit the specific form of the second instruction information.

[0196] Regarding the analysis method for determining whether any page operation constitutes an operation that triggers cross-container communication, and the implementation method for generating communication messages conforming to the message data structure based on page operations, please refer to the relevant content in the foregoing embodiments, which will not be elaborated here.

[0197] Additionally, it should be noted that if the manager determines that the received communication message does not carry the second indication information, it can pass the communication message to the corresponding processing module on the native side for message response processing.

[0198] In this embodiment, the manager acts as a relay for each communication message from each container. With the aid of second indication information and through the collaboration between the container and the manager, the manager can determine whether a received communication message is the target communication message and thus perform the corresponding message forwarding. Therefore, the solution provided in this embodiment enables communication between containers within an application, ensuring the reliability and efficiency of communication. Furthermore, by centrally processing the communication messages of each container through the manager, unified scheduling and distribution of communication messages can be achieved, reducing repetitive message processing or forwarding logic on the native end.

[0199] The following example uses a program developed using a hybrid native and Flutter architecture to illustrate the method for inter-container communication provided in this application.

[0200] Specifically, such as Figure 6 As shown, the method for inter-container communication may include the following steps:

[0201] S601, binds the Container ID with the BasicMessageChannel to store it in the manager's mapping table;

[0202] When a container is created, it is assigned a unique identifier, Container ID, which is the container's ID.

[0203] Furthermore, after each container is created, it can register the established BasicMessageChannel with the manager. Thus, the manager can bind the Container ID with the BasicMessageChannel and store it in the mapping table. The contents recorded in the mapping table are the mapping relationship mentioned above. The BasicMessageChannel registered by each container are the candidate communication channels mentioned above.

[0204] S602, receives cross-container messages and parses the message data structure;

[0205] The manager can receive cross-container messages (i.e. target communication messages) transmitted through any BasicMessageChannel, parse the message data structure of the cross-container message to obtain the field value of the first field, which contains first indication information (as the identifier of the container of the message recipient).

[0206] S603, Analyze the field value of the first field in the cross-container message. If the analysis result is a single ID, then trigger S6041. If the analysis result is an array of IDs, then trigger S6042. If the analysis result is an exclusion list, then trigger S6043.

[0207] S6041, Point-to-point communication: forwarding to the specified container;

[0208] S6042, Point-to-Multipoint Communication: Forwarded to all containers in the data group;

[0209] S6043, Exclusionary Broadcast: Forward to other containers outside the specified container;

[0210] After parsing the value of the first field, the first indication information can be extracted from the value of the first field, thus obtaining the analysis result. If the analysis result is the identifier of a specified container to be forwarded (i.e., a single ID), then the communication process of cross-container messages can be considered point-to-point communication. If the analysis result is a data set containing the identifiers of multiple containers to be forwarded (i.e., an ID array), then the communication process of cross-container messages can be considered point-to-multipoint communication. If the analysis result is the identifier of the containers to be excluded during message forwarding (i.e., an exclusion list), then the communication process of cross-container messages can be considered exclusionary broadcasting.

[0211] S605, performs message forwarding;

[0212] S606, was the forwarding successful?

[0213] If successful, S607 is triggered; if unsuccessful, S608 is triggered.

[0214] S607, Update message status;

[0215] S608, record failure information and clean up failed channels;

[0216] S609, Remove the failed container from the mapping table.

[0217] After obtaining any of the analysis results in S6041, S6042, and S6043, message forwarding can be performed; and when forwarding is successful, the message status is updated (e.g., updated to a forwarding success status); when forwarding fails, failure information can be recorded and failed channels can be cleaned up, and the failed container can be removed from the mapping table.

[0218] Based on the above embodiments and the specific embodiment, it can be seen that for native applications combined with Flutter, the inter-container communication method provided in this application has the following effects:

[0219] To address the technical gap of complete isolation and inability to communicate directly between Flutter containers, a multi-container communication scheme based on a native singleton manager is proposed. This scheme breaks container isolation, solves the problem of complete isolation and inability to interact with data among multiple Flutter containers, and establishes a reliable communication channel between containers. By centrally managing multiple BasicMessageChannel instances and forwarding messages in a unified manner, it breaks through the limitations of traditional one-to-one communication channels.

[0220] The design incorporates routing strategies that support multiple communication modes, including point-to-point, point-to-multipoint, and exclusionary broadcasting. It achieves flexible message distribution through a unified message data structure and container identification mechanism, without specific restrictions on message data types. Furthermore, it enhances architectural flexibility by supporting multiple message routing modes to meet the communication needs of different business scenarios.

[0221] The core communication logic is encapsulated on the native side. This way, after initialization, subsequent inter-container communication development can be completed entirely on the Flutter side without modifying the native code, reducing the development threshold and development cost. In other words, the communication logic is centrally managed, and subsequent development only requires the Flutter side, reducing the complexity of cross-platform code maintenance and improving the cross-platform code reusability.

[0222] Enhance application stability by automatically cleaning up failed channels and preventing exceptions caused by sending messages to invalid containers.

[0223] Corresponding to the above method embodiments, this application also provides an inter-container communication device applied to a manager. The manager is located within the native end of the application and records various candidate communication channels. Each candidate communication channel is a communication channel registered by each container of the application with the manager. The communication channel registered by each container is a component used for message communication between the container and the native end. Figure 7 As shown, the device includes:

[0224] The first determining module 710 is used to determine each candidate communication channel currently recorded after receiving the target communication message; wherein, the target communication message is: a cross-container communication message transmitted by a container within the application through a communication channel;

[0225] The second determining module 720 is used to determine, from the currently recorded candidate communication channels, the target communication channel to be used when transmitting messages to at least one target container; wherein, the target container is the container to which the target communication message is to be transmitted.

[0226] The forwarding module 730 is used to transmit the target communication message to each target container through the determined target communication channel, so that each target container can perform message response processing on the target communication message.

[0227] Optionally, the target communication message carries first indication information, which is used to characterize the identifier of the container that is the message receiver;

[0228] The device further includes:

[0229] The container analysis module is used to parse the first indication information from the target communication message before the second determination module determines the target communication channel to be used when transmitting messages to at least one target container from the currently recorded candidate communication channels, and to determine at least one target container based on the parsed first indication information.

[0230] Optionally, the target communication message satisfies a preset message data structure, which includes a first field for characterizing the message type. The value of the first field is the value obtained by concatenating the first indication information and the type information for indicating the message type according to a predetermined concatenation method.

[0231] Parsing the first indication information from the target communication message includes:

[0232] The field value of the first field in the target communication message is parsed, and the first indication information is extracted from the parsed field value.

[0233] Optionally, the target communication message satisfies a preset message data structure, which includes a third field; the value of the third field is the first indication information.

[0234] Parsing the first indication information from the target communication message includes:

[0235] The first indication information is obtained by parsing the value of the third field in the target communication message.

[0236] Optionally, any container is used to: generate a communication message matching the page operation to be passed to the manager if the page operation is a cross-container communication operation when any page operation occurs on the page it contains; and pass the generated communication message to the manager through a communication channel.

[0237] The methods for determining whether a target communication message has been received include:

[0238] If a communication message is received from a container through a communication channel, it is determined that a communication message has been received through the target.

[0239] Optionally, any container is used to: generate a communication message matching the page operation according to a predetermined message generation method when any page operation occurs on the page it contains, and send the generated communication message to the manager through a communication channel; the predetermined message generation method includes: analyzing whether the page operation is a cross-container communication operation, and if so, generating a communication message matching the page operation and carrying second indication information for indicating that it belongs to cross-container communication;

[0240] The methods for determining whether a target communication message has been received include:

[0241] When a communication message is received from a container through a communication channel, if the received communication message carries second indication information, it is determined that the target communication message has been received.

[0242] Optionally, each container is a Flutter container, and the communication channel registered by each container is a bidirectional asynchronous message communication channel.

[0243] This application also provides an electronic device, such as... Figure 8 As shown, it includes:

[0244] Memory 801 is used to store computer programs;

[0245] The processor 802, when executing a program stored in the memory 801, implements the method for inter-container communication provided in the embodiments of this application.

[0246] Furthermore, the aforementioned electronic device may also include a communication bus and / or a communication interface, with the processor 802, the communication interface, and the memory 801 communicating with each other via the communication bus.

[0247] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.

[0248] The communication interface is used for communication between the aforementioned electronic devices and other devices.

[0249] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0250] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0251] In another embodiment provided in this application, a computer-readable storage medium is also provided, which stores a computer program that, when executed by a processor, implements the inter-container communication method provided in the embodiments of this application.

[0252] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to perform any of the container communication methods described in the above embodiments.

[0253] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a solid-state drive (SSD), etc.

[0254] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0255] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0256] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.

Claims

1. A method for inter-container communication, characterized in that, The method is applied to a manager, which is set within the native application and records various candidate communication channels. Each candidate communication channel is a communication channel registered by each container of the application with the manager. The communication channel registered by each container is a component used for message communication between that container and the native application. Upon receiving the target communication message, determine each candidate communication channel currently recorded; wherein, the target communication message is: a cross-container communication message transmitted by a container within the application through a communication channel; From the currently recorded candidate communication channels, determine the target communication channel to be used when transmitting messages to at least one target container; wherein, the target container is the container to which the target communication message is to be transmitted. The target communication message is transmitted to each target container through the determined target communication channel, so that each target container can perform message response processing on the target communication message.

2. The method according to claim 1, characterized in that, The target communication message carries first indication information, which is used to characterize the identifier of the container that is the message receiver. Before determining the target communication channel to be used when message passing to at least one target container from the currently recorded candidate communication channels, the method further includes: The first indication information is parsed from the target communication message, and at least one target container is determined based on the parsed first indication information.

3. The method according to claim 2, characterized in that, The target communication message satisfies a preset message data structure, which includes a first field for characterizing the message type. The value of the first field is the value obtained by concatenating the first indication information and the type information for indicating the message type according to a predetermined concatenation method. Parsing the first indication information from the target communication message includes: The field value of the first field in the target communication message is parsed, and the first indication information is extracted from the parsed field value.

4. The method according to claim 2, characterized in that, The target communication message satisfies a preset message data structure, which includes a third field; the value of the third field is the first indication information. Parsing the first indication information from the target communication message includes: The first indication information is obtained by parsing the value of the third field in the target communication message.

5. The method according to claim 1 or 2, characterized in that, Any container is used to: generate a communication message matching the page operation to be passed to the manager if the page operation is a cross-container communication operation, in the event of any page operation occurring on any page contained therein; and pass the generated communication message to the manager through a communication channel. The methods for determining whether a target communication message has been received include: If a communication message is received from a container through a communication channel, it is determined that a communication message has been received through the target.

6. The method according to claim 1 or 2, characterized in that, Any container is used to: generate a communication message matching the page operation according to a predetermined message generation method when any page operation occurs on the page it contains, and send the generated communication message to the manager through a communication channel; The predetermined message generation method includes: analyzing whether any page operation is a cross-container communication operation; if so, generating a communication message that matches any page operation and carries a second indication information for representing that it belongs to cross-container communication. The methods for determining whether a target communication message has been received include: When a communication message is received from a container through a communication channel, if the received communication message carries second indication information, it is determined that the target communication message has been received.

7. The method according to claim 1 or 2, characterized in that, Each container is a Flutter container, and the communication channel registered by each container is a bidirectional asynchronous message communication channel.

8. A device for inter-container communication, characterized in that, An application manager is configured within the native endpoint of an application and records various candidate communication channels. Each candidate communication channel is a communication channel registered by each container of the application with the manager. Each communication channel registered by a container is a component used for message communication between that container and the native endpoint. The device includes: The first determining module is used to determine each candidate communication channel currently recorded after receiving the target communication message; wherein, the target communication message is: a cross-container communication message transmitted by a container within the application through a communication channel; The second determining module is used to determine, from the currently recorded candidate communication channels, the target communication channel to be used when transmitting messages to at least one target container; wherein, the target container is the container to which the target communication message is to be transmitted. The forwarding module is used to transmit the target communication message to each target container through the determined target communication channel, so that each target container can perform message response processing on the target communication message.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the method described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method described in any one of claims 1-7.