A method of data transmission and related apparatus
By automating the processing of complex data types through preset encoding and decoding methods, the problem of cumbersome data exchange under the Flutter standard communication method is solved, and efficient data transmission across platforms is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2022-02-17
- Publication Date
- 2026-05-12
AI Technical Summary
The existing Flutter standard communication method does not support the exchange of complex data types, requiring developers to manually split and combine data, which is cumbersome and lacks versatility.
Complex data types are encoded using a preset encoding method and decoded using a preset decoding method, enabling cross-platform transmission and automated processing of complex data types.
It enables cross-platform transmission of complex data types, simplifies the development process, improves efficiency and versatility, and reduces manual operations.
Smart Images

Figure CN116667862B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, specifically to a data transmission method and related apparatus. Background Technology
[0002] Cross-platform communication refers to the transmission of data from one operating platform to another operating platform, that is, the exchange of data between one operating platform and another operating platform.
[0003] In most solutions, cross-platform communication is achieved using Flutter's standard communication methods. However, Flutter's standard communication methods do not support complex data type exchange; they are only suitable for basic data type exchange. When using Flutter's standard communication methods, developers need to manually determine the type of the communication data. When the data type is complex, they need to manually write code to split the communication data into basic data types. Then, each basic data type is independently transmitted to the other platform. This requires the developer to manually write code on the other platform to combine the received basic data types into complex data types.
[0004] However, the data structure of each complex data type may be inconsistent. If the current Flutter standard communication method is still used to achieve cross-platform transmission of complex data types, it will not only require repeated manual coding for each complex data type, which is lengthy and tedious, but also lacks versatility. Summary of the Invention
[0005] This application provides a data transmission method and related apparatus that can automatically transmit complex types of data across platforms and has versatility.
[0006] In a first aspect, embodiments of this application provide a data transmission method. This method can be applied in a transmitting device. The method includes: acquiring first data from a first operating platform, the first operating platform being carried in the transmitting device; when the data type of the first data is complex, encoding the first data based on a preset encoding method to obtain second data, wherein the preset encoding method is obtained from attribute information of the first data; and sending the second data to a receiving device, so that a second operating platform carried in the receiving device processes the first data, wherein the first operating platform and the second operating platform are different.
[0007] Secondly, embodiments of this application provide another method for data transmission. This method can be applied in a receiving device. The method may include: receiving second data transmitted by a transmitting device, the second data being obtained by the transmitting device encoding first data in a first operating platform based on a preset encoding method, the first operating platform being carried in the transmitting device; when the data type of the second data is complex, decoding the second data based on a preset decoding method to obtain the first data, the first data being processed by a second operating platform carried in the receiving device, the preset decoding method being obtained from the attribute information of the first data, the first operating platform being different from the second operating platform.
[0008] A third aspect of this application provides a transmitting device. The transmitting device may include an acquisition unit, a processing unit, and a transmitting unit. The acquisition unit is used to acquire first data from a first operating platform, which is carried in the transmitting device. The processing unit is used to encode the first data based on a preset encoding method to obtain second data when the data type of the first data is complex, wherein the preset encoding method is obtained from the attribute information of the first data. The transmitting unit is used to transmit the second data to a receiving device so that a second operating platform carried in the receiving device processes the first data, wherein the first operating platform and the second operating platform are different.
[0009] In one possible design, the processing unit is used to determine the basic type corresponding to each attribute information of the first data according to the preset encoding method when the data type of the first data is a complex type. Furthermore, the processing unit concatenates the type name, separator, and basic type corresponding to each attribute information of the first data to obtain the second data.
[0010] In another possible embodiment, the processing unit is configured to match the data type of the first data with a preset basic type in a preset basic type set. Furthermore, if the data type of the first data does not match any of the preset basic types in the preset basic type set, the processing unit determines that the data type of the first data is a complex type.
[0011] Fourthly, embodiments of this application provide a receiving device. The receiving device includes a receiving unit and a processing unit. The receiving unit receives second data transmitted by a transmitting device. The second data is obtained by the transmitting device encoding first data in a first operating platform based on a preset encoding method. The first operating platform is carried within the transmitting device. The processing unit decodes the second data based on a preset decoding method when the data type of the second data is complex, thereby obtaining the first data. The first data is processed by a second operating platform carried in the receiving device. The preset decoding method is obtained from the attribute information of the first data. The first operating platform and the second operating platform are different.
[0012] In some possible implementations, the processing unit is configured to, when the data type of the second data is complex, obtain the type name of the first data and the basic type corresponding to each attribute information in the first data from the second data based on the preset decoding method. Furthermore, the processing unit is configured to process the basic type corresponding to each attribute information to obtain the first data.
[0013] In some other possible implementations, the processing unit is used to obtain the type name of the first data and the basic type corresponding to each attribute information in the first data based on the preset decoding method when the second data includes the delimiter.
[0014] In some other possible implementations, the processing unit is configured to match the data type of the second data with a preset basic type in a preset basic type set. Furthermore, the processing unit is configured to determine that the data type of the second data is a complex type when the data type of the second data does not match any of the preset basic types in the preset basic type set.
[0015] A fifth aspect of this application provides a data transmission apparatus, including: a memory, a transceiver, a processor, and a bus system. The bus system connects the memory and the processor to enable communication between them. The memory stores a program. The processor executes the program in the memory to perform the method corresponding to the first aspect or any possible implementation thereof, or to perform the method corresponding to the second aspect or any possible implementation thereof.
[0016] A sixth aspect of this application provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the method corresponding to the first aspect or any possible implementation thereof, or to perform the method corresponding to the second aspect or any possible implementation thereof.
[0017] The seventh aspect of this application provides a computer program product containing instructions that, when run on a computer or processor, causes the computer or processor to execute the method corresponding to the first aspect or any possible implementation thereof, or to execute the method corresponding to the second aspect or any possible implementation thereof.
[0018] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:
[0019] In this embodiment, first data from a first operating platform is acquired, and if the data type of the first data is complex, it is encoded using a preset encoding method to obtain second data. Then, the second data is transmitted across platforms to a receiving device. When the receiving device determines that the second data is complex, it decodes the second data using a corresponding preset decoding method. This allows the second operating platform within the receiving device to process the decoded first data. This not only enables cross-platform transmission of complex data but also automates the encoding and decoding of complex data through the corresponding preset encoding and decoding methods. Developers do not need to manually perform judgment, encoding, and decoding operations for each complex data type, making the process simple and practical. Attached Figure Description
[0020] 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 drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This illustration shows a schematic diagram of a system framework provided in an embodiment of this application;
[0022] Figure 2 A first flowchart of the data transmission method provided in this application embodiment is shown;
[0023] Figure 3 A second flowchart of the data transmission method provided in the embodiments of this application is shown;
[0024] Figure 4 A schematic diagram of the structure of the transmitting device provided in an embodiment of this application is shown;
[0025] Figure 5 A schematic diagram of the receiving device provided in an embodiment of this application is shown;
[0026] Figure 6 A schematic diagram of the data transmission device provided in an embodiment of this application is shown. Detailed Implementation
[0027] This application provides a data transmission method and related apparatus that can automatically transmit complex types of data across platforms and has versatility.
[0028] The technical solutions of the embodiments 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 of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0029] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that implementations of this application described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion. In this application, “at least one” means one or more, and “more than one” means two or more. “And / or” describes the relationship between related objects, indicating that three relationships can exist; for example, A and / or B can mean: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character “ / ” generally indicates that the preceding and following related objects are in an “or” relationship. “At least one of the following” or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, "at least one of a, b, or c" can be expressed as: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, and c can be a single item or multiple items. It is worth noting that "at least one of a kind" can also be interpreted as "one item or multiple items".
[0030] Currently, when using Flutter's standard communication method to achieve cross-platform data transfer, this method itself does not support the transfer of complex data types and is only suitable for the transfer of basic data types. Therefore, for various complex data types with potentially inconsistent data structures, if the current Flutter communication method is still used, developers need to incur significant costs to perform type checks for each complex data type and to perform operations such as splitting and combining data. This process is lengthy, tedious, and lacks versatility.
[0031] To address the aforementioned technical problems, embodiments of this application provide a data transmission method. This method can be applied to... Figure 1 In the system architecture shown. For example... Figure 1 As shown, the system architecture includes a transmitting device and a receiving device. The transmitting device can support a first operating platform, and the receiving device can support a second operating platform. The first and second operating platforms are different. The transmitting device can acquire first data from the first operating platform and, if the data type of the first data is complex, automatically encode it based on a preset encoding method. Then, the transmitting device transmits the obtained second data to the receiving device. The receiving device can then decode the second data based on a preset decoding method and process the decoded first data through the second operating platform. This achieves cross-platform transmission of complex data types.
[0032] It should be understood that complex data types can be understood as data types composed of basic data types. Basic types can be understood as data types that conform to the Dart programming language. For example, basic types can be null, boolean, integer (int), double, string, list, map, int32list, float32list, etc., and this application does not impose any limitations. Complex types can be understood as data types other than those conforming to Dart code. For example, complex types can include, but are not limited to, Object type, enumeration type, or various user-defined data types, etc., and this application does not impose any limitations.
[0033] Additionally, a platform is sometimes also called a system, which can be understood as the operating environment of computer hardware or software. The first running platform can be the Flutter platform, the Apple iOS operating system, the Android operating system, the World Wide Web system, the Apple Mac operating system, the Windows operating system, or the Linux system, etc., and this application does not limit this. Similarly, the second running platform can also be the Flutter platform, the iOS system, the Android system, the web system, the macOS system, the Windows operating system, or the Linux system, etc., and this application does not limit this.
[0034] The transmitting device can be understood as a device that carries the first operating platform, such as a terminal device or a server. The receiving device can be understood as a device that carries the second operating platform, such as a terminal device or a server. It should be understood that the described terminal device may include, but is not limited to, mobile phones, foldable electronic devices, tablets, laptops, handheld devices, laptops, netbooks, personal digital assistants (PDAs), artificial intelligence (AI) devices, intelligent voice interaction devices, smart home appliances, aircraft, wearable devices, in-vehicle devices, or other processing devices connected to a wireless modem, as well as various forms of user equipment (UE), mobile stations (MS), etc. The embodiments of this application do not impose special limitations on the specific type of terminal device. In addition, the transmitting device and the receiving device may also be functional modules deployed in the same device, which is not limited here. Furthermore, the embodiments of this application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, and assisted driving.
[0035] It should be noted that in the following embodiments, only the first running platform being the Flutter platform and the second running platform being the Android system are used as examples for illustration, and this application does not make any specific limitations.
[0036] Figure 2 A first flowchart of a data transmission method provided in an embodiment of this application is shown. Figure 2 As shown, the method for transmitting data may include the following steps:
[0037] 201. The transmitting device acquires the first data from the first operating platform, which is carried in the transmitting device.
[0038] In this example, the first operating platform is housed within the transmitting device. Therefore, the transmitting device can obtain the corresponding first data from the first operating platform.
[0039] 202. When the data type of the first data is complex, the transmitting device encodes the first data based on a preset encoding method to obtain the second data, wherein the preset encoding method is obtained from the attribute information of the first data.
[0040] In this example, after receiving the first data from the first operating platform, the sending device can determine the data type of the first data. Then, if it determines that the data type of the first data is complex, the sending device can encode the first data based on a preset encoding method to obtain the second data. It should be noted that the described preset encoding method is obtained based on the attribute information of the first data. This preset encoding method can convert the data format of the first data into a JSON string.
[0041] The following explains how to obtain the preset encoding and decoding methods based on the attribute information of the first data. Specifically, all complex data types that need to be transmitted across platforms are placed in a designated directory, for example, denoted as "channels". Then, the input / output (I / O) module of the first running platform reads all files under the directory "channels" to obtain a file list, for example, denoted as "files". For each file in the file list "files", all complex data types included in the currently looped file can be obtained through regular expression matching rules. It should be noted that the described regular expression matching rules can be as shown in the following code example, for example:
[0042] r”[]*class[]*\S+[]*\{”};or,
[0043] r”[]*abstract[]*class[]*\S+[]*\{”} etc. Specific regular expression matching rules are not limited in this application embodiment.
[0044] For example, suppose the content of a file in the file list `files` is:
[0045]
[0046] Here, IPhoto is the type name, and its attribute information includes 'a' and String type, etc. Furthermore, the file carries encoding / decoding methods including method aaa and method bbb. Method aaa has a return type of void. Method bbb includes an integer (int) parameter t and a return type of int.
[0047] In this example, the code "abstract class IPhoto" in the file can be matched using the regular expression matching rules mentioned above. Then, by removing keywords such as "class," the abstract modifier, punctuation marks, and parentheses from this code, the complex data type "IPhoto" can be obtained. After the loop ends, all the complex data types that need to be transmitted across platforms are added to a list collection, which can be denoted as "Types".
[0048] Thus, after obtaining complex data, the type object of that complex data type is determined. This type object includes the structural information of the complex data type, including its encoding / decoding method and corresponding attribute information. For example, by calling the `reflectClass(Type)` method in Dart's reflection module, the structure of the complex data type can be analyzed, and a type object containing the structural information of the complex data type is returned. Then, each complex data type in `Types` is retrieved in a loop, and the `reflectClass()` method is called, inputting the currently selected complex data type to obtain its type object. This type object can be denoted as `classMirror`.
[0049] It should be noted that the values in this classMirror are attribute information inherent to the classMirror itself. By calling the values in this classMirror, one can obtain information such as the encoding / decoding method and attribute information carried by the complex data type. For example, the encoding / decoding method carried by the complex data type could be the method 'aaa' or the method 'bbb' in the example above. The attribute information could be the parameter 'a', string, etc., and this application does not impose specific limitations.
[0050] Next, after obtaining the encoding / decoding methods for this complex data type, all the acquired encoding / decoding methods are matched against pre-set encoding / decoding methods. If each acquired encoding / decoding method matches a pre-set method, the next complex data type can be processed. Otherwise, if the acquired encoding / decoding method does not match a pre-set method, a corresponding target encoding / decoding method needs to be generated based on the acquired attribute information. For example, generating the target encoding / decoding method can be done by determining the basic type of the attribute information and then determining the return result for each attribute. Then, all the return results are combined to generate the corresponding target encoding / decoding method.
[0051] For example, pre-defined encoding / decoding methods may include fromJson and toJson. The fromJson method converts a JSON string into the data format required for complex data types. The toJson method converts complex data types into JSON strings.
[0052] At this point, we can match the method 'aaa' with both 'fromJson' and 'toJson' methods, and match the method 'bbb' with both 'fromJson' and 'toJson' methods respectively. Clearly, 'aaa' and 'bbb' do not match either 'fromJson' or 'toJson'. Therefore, we can call the '_create From JsonMethod(Object)' method, which returns a String code. Then, we can loop through and retrieve all the attribute information from the classMirror. Specifically, we can use the following possible methods to obtain it:
[0053] a) If the current property is a primitive type or an Object, then the property name "name" is returned directly.
[0054] b) If the current property is a list, then for each item in the list (the current loop item is denoted as v), the _create From JsonMethod(Object) method is recursively called, input into v, and the corresponding property information is returned after obtaining the result.
[0055] c) If the current attribute is a Map, then for each item in the Map (the current loop items are denoted as k and v), recursively call _create From JsonMethod(Object) with input to k. Then recursively call _create From JsonMethod(Object) with input to v, and return the corresponding attribute information after obtaining the result.
[0056] d) If the current property is of another type, determine whether the type is a complex type. If the type is complex, directly return the property name string "name.fromJson()".
[0057] By assembling the strings returned in a) to d) above, the fromJson() method is generated.
[0058] Similarly, the generation process for the `toJson` method can be understood by referring to the generation process for the `fromJson` method described above, and will not be repeated here. It is worth noting that the difference between the `fromJson` and `toJson` methods is that the final step of the `fromJson` method is to combine all the strings together and return them, while the `toJson` method creates a Map object, adds all the strings to the Map, and then returns the Map.
[0059] The following code demonstrates the generation result of a simple encoding / decoding method:
[0060] It should be noted that the various values shown above are merely illustrative examples and are not intended to be limiting in this application.
[0061] After generating the fromJson and toJson methods described above, these fromJson and toJson methods can be stored in the storage location where the complex data type is located.
[0062] In this way, when the transmitting device determines that the data type of the first data is complex, it can encode the first data based on the preset encoding method obtained from the corresponding storage location to obtain the second data.
[0063] In some optional examples, when the data type of the first data is complex, the second data is obtained by encoding the first data based on a preset encoding method. This can be achieved as follows: When the data type of the first data is complex, the sending device determines the basic type corresponding to each attribute information of the first data according to the preset encoding method. Then, the sending device concatenates the type name, separator, and basic type corresponding to each attribute information of the first data to obtain the second data.
[0064] For example, the transmitting device can match the data type of the first data with a preset basic type in a preset basic type set. When the data type of the first data does not match any preset basic type in the preset basic type set, it can be determined that the data type of the first data is a complex type. It should be noted that the described preset basic type set can be Dart. Preset basic types can include, but are not limited to: null, bool, int, double, string, list, map, int32list, float32list, etc., and this application does not impose any limitations on this.
[0065] Thus, when the data type of the first data is determined to be complex, a preset encoding method (such as tojson) can be used to split the first data into basic data types, that is, to determine the basic type corresponding to each attribute information in the first data, which can be denoted as jsonStr. Then, for each attribute information corresponding to the basic type of the first data, a separator and type name are concatenated. For example, taking the basic type as String, IPhoto and _custom_ can be concatenated (e.g., IPhoto+_custom_+String) to obtain the second data. For example, the described separator can include, but is not limited to, _custom_, etc., and this application does not impose any restrictions.
[0066] 203. The transmitting device sends the second data to the receiving device.
[0067] In this example, the transmitting device can transmit the second data to the receiving device via platform communication channels or similar means. The described platform communication channels may include, but are not limited to, basic channels, method channels, or event channels, and this application does not impose any limitations. All mentioned basic channels, method channels, or event channels are prior art and will not be described further in this application.
[0068] 204. When the data type of the second data is complex, the receiving device decodes the second data based on a preset decoding method to obtain the first data. The first data is processed by the second operating platform carried in the receiving device. The preset decoding method is obtained from the attribute information of the first data.
[0069] In this example, the preset decoding method mentioned can be the fromJson method. For details, please refer to step 202 above. It will not be elaborated here.
[0070] After receiving the second data sent by the transmitting device, the receiving device can determine whether the data type of the second data is a complex type. Specifically, the receiving device can match the data type of the second data with preset basic types in a preset set of basic types. If the data type of the second data does not match any preset basic type in the preset set of basic types, it can be determined that the data type of the second data is a complex type. Then, when the data type of the second data is a complex type, the receiving device decodes the second data based on the preset decoding method to obtain the first data. It should be noted that the preset set of basic types described refers to the content in step 202 above, and will not be repeated here.
[0071] In some optional examples, when the data type of the second data is complex, the second data is decoded based on a preset decoding method to obtain the first data. This can be achieved as follows: When the data type of the second data is complex, the receiving device obtains the type name of the first data and the basic type corresponding to each attribute information in the first data from the second data based on the preset decoding method. Then, the receiving device processes the basic type corresponding to each attribute information to obtain the first data.
[0072] In other examples, obtaining the type name of the first data and the basic type corresponding to each attribute information in the first data from the second data based on a preset decoding method can also be achieved in the following way: The receiving device determines whether the second data includes a delimiter. Then, if the second data includes a delimiter, the receiving device obtains the type name of the first data and the basic type corresponding to each attribute information in the first data based on the preset decoding method.
[0073] For example, the receiving device can determine whether the data type of the second data is string. If it is not string, it can determine whether the second data contains a separator (such as _custom_). Then, if the second data contains the separator, it can be split to obtain the customInfo array. For the customInfo array, the complete type name of the first data can be obtained by calling the package.getName+pre+customInfo[0]. Then, the Class.forName() method is called to input the type name and obtain the data type of the first data. Next, the parseObject method is called to parse the customInfo[1] in the customInfo array and obtain the basic type corresponding to each attribute information of the first data. Then, the first data can be obtained by concatenating the basic types corresponding to each attribute information.
[0074] It should be noted that the above embodiments describe the transmission of first data carried on a first operating platform of a transmitting device to a second operating platform carried in a receiving device, and are merely illustrative. In practical applications, complex types of data carried on a second operating platform can also be transmitted across platforms to the first operating platform in a similar manner, and this application does not limit this.
[0075] Figure 3 A second flowchart illustrating the data transmission method provided in an embodiment of this application is shown. Figure 3 As shown, during the injection phase, complex data types are first scanned and obtained. Then, the `reflectClass(Type)` method of the reflection module is used to analyze and obtain the type object `classMirror` of the complex data type. Based on the type object `classMirror`, the encoding / decoding method and attribute information corresponding to the complex data type can be obtained. Further, it is determined whether the encoding / decoding method conforms to the pre-defined encoding / decoding method (such as `fromJson` or `toJson`). On one hand, if it does not conform, the corresponding encoding / decoding method (such as `fromJson` or `toJson`) is generated based on the obtained attribute information, and all generated code is assembled. The assembled result is stored at the location `path` where the complex data type is located. Then, the description file of the current complex data type is modified based on the result stored at this location, and the target file is output. On the other hand, if it conforms, the existing encoding / decoding method can be directly called for encoding / decoding processing.
[0076] During the encoding phase, after obtaining complex data types, the corresponding `toJson` method is called for encoding. The encoded second data is then passed to `MethodChannel` to be transmitted to other platforms via the Flutter standard communication framework.
[0077] During the decoding phase, the device supporting other platforms receives the second data and checks whether the data type of the second data is string and whether it contains a specified encoding format. If the second data is string and contains a specified encoding format, it is decoded according to a preset decoding method (such as fromJson) to obtain the basic type corresponding to each attribute information in the first data. Then, the JsonParse method is called to parse the basic type corresponding to each attribute information, and the parsed results are concatenated to obtain the first data.
[0078] It should be noted that the above Figures 2-3The described method can also enable cross-platform transmission of basic data types. Please refer to the above embodiments for details, which will not be elaborated upon in this application.
[0079] In this embodiment, first data from a first operating platform is acquired, and if the data type of the first data is complex, it is encoded using a preset encoding method to obtain second data. Then, the second data is transmitted across platforms to a receiving device. When the receiving device determines that the second data is complex, it decodes the second data using a corresponding preset decoding method. This allows the second operating platform within the receiving device to process the decoded first data. In other words, this application achieves seamless data format conversion by automatically performing encoding and decoding on complex data. It not only enables cross-platform transmission of complex data but also eliminates the need for developers to manually perform judgment, encoding, and decoding operations for each complex data type. The process is simple, capable of handling any type of complex data, and is practical.
[0080] The foregoing primarily describes the solutions provided by the embodiments of this application from a methodological perspective. It is understood that to achieve the above functions, corresponding hardware structures and / or software modules are included to execute each function. Those skilled in the art should readily recognize that, based on the modules and algorithm steps described in conjunction with the embodiments disclosed in this application, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0081] This application embodiment can divide the device into functional modules according to the above method example. For example, each function can be divided into its own functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.
[0082] The transmitting device in the embodiments of this application will now be described in detail. Figure 4 This is a schematic diagram of one embodiment of the transmitting device provided in this application. For example... Figure 4 As shown, the transmitting device may include an acquisition unit 401, a processing unit 402, and a transmitting unit 403.
[0083] The acquisition unit 401 is used to acquire first data from the first operating platform, which is carried in the sending device. For details, please refer to the foregoing. Figure 2 The content of step 201 in the previous section will be understood and will not be elaborated here.
[0084] Processing unit 402 is configured to encode the first data based on a preset encoding method to obtain second data when the data type of the first data is complex, wherein the preset encoding method is obtained from the attribute information of the first data. For details, please refer to the foregoing. Figure 2 The content of step 202 in the previous section will be understood and will not be elaborated here.
[0085] The transmitting unit 403 is used to transmit the second data to the receiving device, so that a second operating platform carried in the receiving device processes the first data. The first operating platform is different from the second operating platform. See the foregoing for details. Figure 2 The content of step 203 in the previous section will be understood and will not be elaborated here.
[0086] In one possible design, processing unit 402 is used to determine the basic type corresponding to each attribute information of the first data according to the preset encoding method when the data type of the first data is a complex type. Furthermore, processing unit 402 concatenates the type name, separator, and basic type corresponding to each attribute information of the first data to obtain the second data.
[0087] In another possible embodiment, the processing unit 402 is configured to match the data type of the first data with a preset basic type in a preset basic type set. Furthermore, if the data type of the first data does not match any preset basic type in the preset basic type set, the processing unit 402 determines that the data type of the first data is a complex type.
[0088] The receiving device in the embodiments of this application will be described in detail below. Figure 5 This is a schematic diagram of one embodiment of the receiving device provided in this application. Figure 5 As shown, the receiving device may include a receiving unit 501 and a processing unit 502.
[0089] The receiving unit 501 is used to receive second data sent by the sending device. The second data is obtained by the sending device encoding the first data in the first operating platform based on a preset encoding method. The first operating platform is carried in the sending device.
[0090] The processing unit 502 is used to decode the second data based on a preset decoding method when the data type of the second data is complex, to obtain the first data. The first data is processed by a second operating platform carried in the receiving device, and the preset decoding method is obtained from the attribute information of the first data. The first operating platform is different from the second operating platform. For details, please refer to the foregoing. Figure 2 The content of step 204 in the previous section will be understood and will not be elaborated here.
[0091] In some possible implementations, the processing unit 502 is used to, when the data type of the second data is a complex type, obtain the type name of the first data and the basic type corresponding to each attribute information in the first data from the second data based on the preset decoding method. Furthermore, the processing unit 502 is used to process the basic type corresponding to each attribute information to obtain the first data.
[0092] In some other possible implementations, the processing unit 502 is used to obtain the type name of the first data and the basic type corresponding to each attribute information in the first data based on the preset decoding method when the second data includes the delimiter.
[0093] In some other possible implementations, the processing unit 502 is configured to match the data type of the second data with a preset basic type in a preset basic type set. Furthermore, the processing unit 502 is configured to determine that the data type of the second data is a complex type when the data type of the second data does not match any preset basic type in the preset basic type set.
[0094] The transmitting and receiving devices in the embodiments of this application have been described above from the perspective of modular functional entities. The transmitting and receiving devices in the embodiments of this application are described below from the perspective of hardware processing. Figure 6 This is a schematic diagram of the structure of a data transmission device provided in an embodiment of this application. The data transmission device may include the transmitting device and receiving device described above. The data transmission device may vary considerably due to differences in configuration or performance. The data transmission device may include at least one processor 601, a communication line 607, a memory 603, and at least one communication interface 604.
[0095] The processor 601 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (server IC), or one or more integrated circuits used to control the execution of the program of the present application.
[0096] Communication line 607 may include a path for transmitting information between the aforementioned components.
[0097] Communication interface 604 uses any transceiver-like device for communicating with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area networks (WLAN), etc.
[0098] The memory 603 can be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (RAM) or other type of dynamic storage device that can store information and instructions. The memory can exist independently and be connected to the processor via communication line 607. The memory can also be integrated with the processor.
[0099] The memory 603 stores computer execution instructions for implementing the scheme of this application, and its execution is controlled by the processor 601. The processor 601 executes the computer execution instructions stored in the memory 603, thereby implementing the data transmission method provided in the above embodiments of this application.
[0100] Optionally, the computer execution instructions in the embodiments of this application may also be referred to as application code, and the embodiments of this application do not specifically limit this.
[0101] In a specific implementation, as one example, the computer device may include multiple processors, for example... Figure 6 Processors 601 and 602 are described herein. Each of these processors may be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor. A processor here may refer to one or more devices, circuits, and / or processing cores used to process data (e.g., computer program instructions).
[0102] In a specific implementation, as one embodiment, the computer device may further include an output device 605 and an input device 606. The output device 605 communicates with the processor 601 and can display information in various ways. The input device 606 communicates with the processor 601 and can receive user input in various ways. For example, the input device 606 may be a mouse, a touch screen device, or a sensing device, etc.
[0103] The aforementioned computer device can be a general-purpose device or a special-purpose device. In specific implementations, the computer device can be a microscope or something similar. Figure 6 A device with a similar structure. The embodiments of this application do not limit the type of computer device.
[0104] It should be noted that Figure 6 The processor 601 can invoke computer execution instructions stored in the memory 603 to cause the transmitting and receiving devices to perform actions such as... Figure 2 The method in the corresponding method embodiment.
[0105] Specifically, Figure 4 Processing unit 402 in Figure 5 The function / implementation process of the processing unit 502 can be achieved through... Figure 6 The processor 601 in the memory calls computer execution instructions stored in the memory 603 to implement the function. Figure 4 The acquisition unit 401 and the sending unit 403 in the middle Figure 5 The function / implementation process of the receiving unit 501 can be achieved through... Figure 6 It is implemented using the communication interface 604.
[0106] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.
[0107] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0108] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or indirect coupling or communication connection between apparatuses or units, and may be electrical, mechanical, or other forms.
[0109] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0110] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0111] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0112] The above embodiments can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, they can be implemented in whole or in part in the form of a computer program product.
[0113] A computer program product includes one or more computer instructions. When these computer instructions are loaded and executed on a computer, they generate, in whole or in part, the processes or functions according to embodiments of this application. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions may be transmitted from one website, computer, server, or data center to another 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 may be any available medium that a computer can store or a data storage device such as a server or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., SSDs), etc.
[0114] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A method for data transmission, characterized in that, A sending device for cross-platform data transmission using Flutter standard communication methods, the method comprising: Acquire first data from a first operating platform, which is carried in the transmitting device; When the data type of the first data is a complex type, the basic type corresponding to each attribute information of the first data is determined according to the preset encoding method. The complex type data is composed of basic type data. The basic type is a data type of the Dart programming language. The complex type is a data type other than that of the Dart programming language. The preset encoding method is obtained from the attribute information of the first data. The data format of the first data is converted into a JSON string through the preset encoding method. The type object of the complex type data includes the structure information of the complex type data. The structure information includes the encoding and decoding method corresponding to the complex type data and the corresponding attribute information. The type name, separator, and basic type corresponding to each attribute information of the first data are concatenated to obtain the second data; The second data is sent to the receiving device so that a second operating platform carried in the receiving device processes the first data, the first operating platform being different from the second operating platform.
2. The method according to claim 1, characterized in that, The data type of the first data is a complex type, including: Match the data type of the first data with the preset basic types in the preset basic type set; If the data type of the first data does not match any of the preset basic types in the preset basic type set, then the data type of the first data is determined to be a complex type.
3. A method for data transmission, characterized in that, A receiving device for cross-platform data transmission using Flutter standard communication methods, the method comprising: The system receives second data sent by a transmitting device. This second data is obtained by encoding first data in a first operating platform using a preset encoding method. The first operating platform is hosted within the transmitting device. The method for obtaining the second data is as follows: when the data type of the first data is complex, the basic type corresponding to each attribute information of the first data is determined according to the preset encoding method. The complex data is composed of basic data types, where the basic type is a data type in the Dart programming language, and the complex type is a data type other than that satisfying the Dart programming language. The type name, separator, and basic type corresponding to each attribute information of the first data are concatenated to obtain the second data. The data format of the first data is converted into a JSON string using the preset encoding method. The type object of the complex data includes the structural information of the complex data, which includes the encoding / decoding method corresponding to the complex data and the corresponding attribute information. When the data type of the second data is complex, the second data is decoded based on a preset decoding method to obtain the first data. The first data is processed by the second operating platform carried in the receiving device. The preset decoding method is obtained from the attribute information of the first data. The first operating platform is different from the second operating platform.
4. The method according to claim 3, characterized in that, When the data type of the second data is complex, the second data is decoded based on a preset decoding method to obtain the first data, including: When the data type of the second data is a complex type, the type name of the first data and the basic type corresponding to each attribute information in the first data are obtained from the second data based on the preset decoding method; The basic type corresponding to each attribute information is processed to obtain the first data.
5. The method according to claim 4, characterized in that, The step of obtaining the type name of the first data and the basic type corresponding to each attribute information in the first data from the second data based on the preset decoding method includes: When the second data includes a delimiter, the type name of the first data and the basic type corresponding to each attribute information in the first data are obtained based on the preset decoding method.
6. The method according to any one of claims 3-5, characterized in that, The second data is of a complex data type, including: Match the data type of the second data with the preset basic types in the preset basic type set; If the data type of the second data does not match any of the preset basic types in the preset basic type set, then the data type of the second data is determined to be a complex type.
7. A transmitting device, characterized in that, This is applied to cross-platform data transfer using Flutter's standard communication methods, including: An acquisition unit is used to acquire first data from a first operating platform, which is carried in the sending device. The processing unit is configured to, when the data type of the first data is a complex type, determine the basic type corresponding to each attribute information of the first data according to a preset encoding method, wherein the complex type data is composed of basic type data, the basic type is a data type of the Dart programming language, and the complex type is a data type other than that satisfying the Dart programming language, the preset encoding method is obtained from the attribute information of the first data, and convert the data format of the first data into a JSON string through the preset encoding method, wherein the type object of the complex type data includes the structure information of the complex type data, the structure information includes the encoding and decoding method corresponding to the complex type data and the corresponding attribute information; and concatenate the type name, separator, and basic type corresponding to each attribute information of the first data to obtain the second data. The transmitting unit is used to transmit the second data to the receiving device so that the second operating platform carried in the receiving device processes the first data, wherein the first operating platform is different from the second operating platform.
8. The apparatus according to claim 7, characterized in that, The processing unit is configured to match the data type of the first data with a preset basic type in a preset basic type set; if the data type of the first data does not match any preset basic type in the preset basic type set, then the data type of the first data is determined to be a complex type.
9. A receiving device, characterized in that, This is applied to cross-platform data transfer using Flutter's standard communication methods, including: A receiving unit is used to receive second data sent by a sending device. The second data is obtained by the sending device encoding first data in a first operating platform based on a preset encoding method. The first operating platform is carried in the sending device. The method of obtaining the second data is as follows: when the data type of the first data is a complex type, the basic type corresponding to each attribute information of the first data is determined according to the preset encoding method. The complex type data is composed of basic type data. The basic type is a data type of the Dart programming language, and the complex type is a data type other than that that satisfies the Dart programming language. The type name, separator, and basic type corresponding to each attribute information of the first data are concatenated to obtain the second data. The data format of the first data is converted into a JSON string through the preset encoding method. The type object of the complex type data includes the structure information of the complex type data. The structure information includes the encoding and decoding method corresponding to the complex type data and the corresponding attribute information. The processing unit is configured to decode the second data based on a preset decoding method when the data type of the second data is complex, to obtain the first data. The first data is processed by a second operating platform carried in the receiving device. The preset decoding method is obtained from the attribute information of the first data. The first operating platform is different from the second operating platform.
10. The apparatus according to claim 9, characterized in that, The processing unit is used for: When the data type of the second data is a complex type, the type name of the first data and the basic type corresponding to each attribute information in the first data are obtained from the second data based on the preset decoding method; The basic type corresponding to each attribute information is processed to obtain the first data.
11. The apparatus according to claim 10, characterized in that, The processing unit is used for: When the second data includes a delimiter, the type name of the first data and the basic type corresponding to each attribute information in the first data are obtained based on the preset decoding method.
12. The apparatus according to any one of claims 9-11, characterized in that, The processing unit is used for: Match the data type of the second data with the preset basic types in the preset basic type set; If the data type of the second data does not match any of the preset basic types in the preset basic type set, then the data type of the second data is determined to be a complex type.
13. A data transmission device, characterized in that, The data transmission device includes: an input / output (I / O) interface, a processor, and a memory. The memory stores program instructions; The processor is used to execute program instructions stored in the memory to perform the method as described in any one of claims 1 to 2 or 3 to 6.
14. A computer-readable storage medium comprising instructions, characterized in that, When the instructions are executed on a computer device, the computer device causes the computer device to perform the method as described in any one of claims 1 to 2 or 3 to 6.
15. A computer program product, characterized in that, The computer program product includes instructions that, when executed on a computer or processor, cause the computer or processor to perform the method as described in any one of claims 1 to 2 or 3 to 6.