Data transmission equipment, method and device, electronic equipment and medium
By employing asynchronous transmission in Java applications to generate identifiers for data and the user interface, and using the JCEF interface for data transmission, the data transmission blocking problem between the user interface layer and the processing layer is solved, achieving fast and efficient data transmission and stability of the user interface layer.
Patent Information
- Application Number
- CN202411246300.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-06
- Publication Date
- 2025-01-07
AI Technical Summary
In Java applications, synchronous data transfer between the user interface layer and the processing layer can cause page blocking, impacting the user experience.
An asynchronous transmission method is adopted. By generating identifiers for data and user interface, and using the JCEF CefMessageRouter interface and executeJavaScript function for data transmission, the user interface layer and processing layer modules can identify different data and processing results based on the identifiers, thereby reducing page blocking.
It enables fast and efficient data transfer between the user interface layer and the processing layer, reduces page blocking, improves user experience, and saves storage resources.
Smart Images

Figure CN119271430A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data transmission device, method, apparatus, electronic device and medium. Background Art
[0002] For software programs written in Java (for ease of description, referred to as Java applications), when using the Java Chromium Embedding Frame (JCEF) to perform cross-environment development between the environment where the user interface layer in the Java application is located and the environment where the processing layer is located, it is inevitable that data needs to be transmitted between the user interface layer and the processing layer. In related technologies, for example, when the user interface (user interface layer) transmits the generated data to the processing layer for processing, the user interface layer usually transmits the data to the processing layer based on synchronous transmission. For example, after the user interface layer sends the data to the processing layer, while the processing layer processes the data accordingly, the user interface layer also needs to wait in real time for the processing result of the processing layer on the data. In the process of waiting for the processing result, page blocking and other situations are likely to occur, thereby affecting the user experience.
[0003] Therefore, there is an urgent need for a technical solution that can quickly and efficiently transmit data between the user interface layer and the processing layer. Summary of the invention
[0004] The present application provides a data transmission device, method, apparatus, electronic device and medium for quickly and efficiently transmitting data between a user interface layer and a processing layer.
[0005] In a first aspect, the present application provides a data transmission device, the device comprising:
[0006] A user interface layer module, for generating, for data generated by any user interface to be transmitted to the processing layer, an identifier corresponding to the data and the user interface, and sending the identifier and the data to the processing layer module;
[0007] The processing layer module is used for processing the data accordingly upon receiving the identifier and the data, and sending the processing result and the identifier to the user interface layer module after the processing is completed;
[0008] The user interface layer module is further used to receive the identifier and the processing result, and to display the processing result accordingly in the user interface.
[0009] Compared with the related art in which data is transmitted between the user interface (user interface layer) and the processing layer based on synchronous transmission, after the user interface sends the data to the processing layer, while the processing layer processes the data accordingly, the user interface also needs to wait in real time for the processing results of the data by the processing layer. In the process of waiting for the processing results, it is easy for the user interface (page) to be blocked, which affects the user experience. The embodiment of the present application provides a method for transmitting data between the user interface layer module and the processing layer module through asynchronous transmission. The user interface layer module and the processing layer module can identify different data and the processing results corresponding to different data based on identifiers. For example, in the process of the processing layer module processing the data, the user interface layer module and the user interface (user interface layer) do not need to wait in real time for the processing results of the data by the processing layer module, thereby reducing the occurrence of user interface blocking and achieving the purpose of quickly and efficiently transmitting data between the user interface layer and the processing layer.
[0010] In a possible implementation manner, the user interface layer module is specifically used to:
[0011] If the processing result is a successful processing result, calling the execution completion resolve callback function in the created Promise object corresponding to the identifier, and displaying the corresponding first page in the user interface;
[0012] If the processing result is a processing result of execution failure, the execution failure reject callback function in the Promise object is called, and the corresponding second page is displayed in the user interface.
[0013] Through the above method, a Promise object corresponding to the identifier of the data generated by the user interface can be created, and the first page corresponding to the user interface when the processing result is successful can be displayed based on the resolve callback function in the Promise object, and the second page corresponding to the user interface when the processing result is failed can be displayed based on the reject callback function in the Promise object, so that the processing results of the data by the processing layer (processing layer module) can be displayed in the user interface quickly and efficiently.
[0014] In a possible implementation manner, the user interface layer module is further used to:
[0015] After corresponding display is performed in the user interface according to the processing result, the created Promise object corresponding to the identifier is deleted.
[0016] In the above manner, after the entire data transmission process is completed, the corresponding saved Promise object can be deleted, thereby reclaiming storage space and saving storage resources.
[0017] In a possible implementation manner, the user interface layer module is further used to:
[0018] If the processing result corresponding to the identifier sent by the processing layer module is not received within the set time period, a prompt message indicating that the processing timeout has occurred for the user interface is output.
[0019] By means of the above method, when the processing result corresponding to the above identification is not received from the processing layer module within the set time period, a prompt message indicating that the processing timeout of the user interface corresponding to the identification has occurred can be output to prompt the user and improve the user experience.
[0020] In a possible implementation manner, the user interface layer module is specifically used to:
[0021] Based on at least one of the timestamp information when the data is generated and the generated random number, an identifier corresponding to the data and the user interface is generated.
[0022] Through the above method, since it is relatively easy to obtain timestamp information and random numbers, and the probability of duplication between different timestamps and different random numbers is relatively small, the present application generates an identifier corresponding to the data and the user interface based on the timestamp information when the user interface generates data, and at least one of the generated random numbers, which can improve the speed and flexibility of generating identifiers.
[0023] In a possible implementation manner, the user interface layer module is specifically used to:
[0024] Based on the CefMessageRouter interface of jcef, the identifier and the data are sent to the processing layer module.
[0025] In the above manner, since the user interface layer module can send the identifier and data to the processing layer module based on the CefMessageRouter interface provided by jcef, the speed, stability and accuracy of data transmission can be guaranteed to the greatest extent.
[0026] In a possible implementation manner, the processing layer module is specifically used to:
[0027] Based on the executeJavaScript function of jcef, the processing result and the identifier are sent to the user interface layer module.
[0028] In the above manner, since the processing layer module can send the identifier and the processing result to the user interface layer module based on the executeJavaScript function provided by jcef, the speed, stability and accuracy of data transmission can be guaranteed to the greatest extent.
[0029] In a second aspect, the present application provides a data transmission method, the method comprising:
[0030] For data generated by any user interface to be transmitted to the processing layer, generate an identifier corresponding to the data and the user interface, and send the identifier and the data to the processing layer module, so that the processing layer module processes the data accordingly;
[0031] Receive the processing result of the data and the identifier sent by the processing layer module, and display them accordingly in the user interface according to the processing result.
[0032] In a possible implementation, displaying the processing result in the user interface accordingly includes:
[0033] If the processing result is a successful processing result, calling the execution completion resolve callback function in the created Promise object corresponding to the identifier, and displaying the corresponding first page in the user interface;
[0034] If the processing result is a processing result of execution failure, the execution failure reject callback function in the Promise object is called, and the corresponding second page is displayed in the user interface.
[0035] In a possible implementation, after performing corresponding display in the user interface according to the processing result, the method further includes:
[0036] Delete the created Promise object corresponding to the specified identifier.
[0037] In a possible implementation, after sending the identifier and the data to the processing layer module and before receiving the processing result of the data and the identifier sent by the processing layer module, the method further includes:
[0038] If the processing result corresponding to the identifier sent by the processing layer module is not received within the set time period, a prompt message indicating that the processing timeout has occurred for the user interface is output.
[0039] In a possible implementation, the generating an identifier corresponding to the data and the user interface includes:
[0040] Based on at least one of the timestamp information when the data is generated and the generated random number, an identifier corresponding to the data and the user interface is generated.
[0041] In a possible implementation manner, sending the identifier and the data to a processing layer module includes:
[0042] Based on the CefMessageRouter interface of jcef, the identifier and the data are sent to the processing layer module.
[0043] In a third aspect, the present application provides another data transmission method, the method comprising:
[0044] Receiving an identifier and data sent by a user interface layer module, wherein the identifier corresponds to the data and a user interface generating the data;
[0045] The data is processed accordingly, and after the processing is completed, the processing result and the identifier are sent to the user interface layer module, so that the user interface layer module performs corresponding display in the user interface according to the processing result.
[0046] In a possible implementation manner, sending the processing result and the identifier to the user interface layer module includes:
[0047] Based on the executeJavaScript function of jcef, the processing result and the identifier are sent to the user interface layer module.
[0048] In a fourth aspect, the present application provides a data transmission device, the device comprising:
[0049] A first transmission unit is used to generate, for data generated by any user interface to be transmitted to the processing layer, an identifier corresponding to the data and the user interface, and send the identifier and the data to the processing layer module so that the processing layer module processes the data accordingly;
[0050] The first receiving unit is used to receive the processing result of the data and the identifier sent by the processing layer module, and display the processing result in the user interface accordingly.
[0051] In a possible implementation manner, the first receiving unit is specifically configured to:
[0052] If the processing result is a successful processing result, calling the execution completion resolve callback function in the created Promise object corresponding to the identifier, and displaying the corresponding first page in the user interface;
[0053] If the processing result is a processing result of execution failure, the execution failure reject callback function in the Promise object is called, and the corresponding second page is displayed in the user interface.
[0054] In a possible implementation manner, the first receiving unit is further configured to:
[0055] Delete the created Promise object corresponding to the specified identifier.
[0056] In a possible implementation manner, the first transmission unit is further configured to:
[0057] If the processing result corresponding to the identifier sent by the processing layer module is not received within the set time period, a prompt message indicating that the processing timeout has occurred for the user interface is output.
[0058] In a possible implementation manner, the first transmission unit is specifically configured to:
[0059] Based on at least one of the timestamp information when the data is generated and the generated random number, an identifier corresponding to the data and the user interface is generated.
[0060] In a possible implementation manner, the first transmission unit is specifically configured to:
[0061] Based on the CefMessageRouter interface of jcef, the identifier and the data are sent to the processing layer module.
[0062] In a fifth aspect, the present application provides another data transmission device, the device comprising:
[0063] A second receiving unit, configured to receive an identifier and data sent by the user interface layer module, wherein the identifier corresponds to the data and a user interface generating the data;
[0064] The second transmission unit is used to process the data accordingly, and after the processing is completed, send the processing result and the identifier to the user interface layer module, so that the user interface layer module performs corresponding display in the user interface according to the processing result.
[0065] In a possible implementation manner, the second transmission unit is specifically configured to:
[0066] Based on the executeJavaScript function of jcef, the processing result and the identifier are sent to the user interface layer module.
[0067] In a sixth aspect, the present application further provides an electronic device, comprising at least a processor and a memory, wherein the processor is configured to implement the steps of the data transmission method as described in any one of the second aspect and the third aspect when executing a computer program stored in the memory.
[0068] In the seventh aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer performs the steps of the data transmission method as described in any one of the second and third aspects.
[0069] In an eighth aspect, an embodiment of the present application provides a computer program product, which includes: a computer program code, which, when executed on a computer, enables the computer to execute the steps of the data transmission method described in any one of the second and third aspects. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] In order to more clearly illustrate the implementation methods in the embodiments of the present application or the related technologies, the following is a brief introduction to the drawings required for use in the embodiments or the related technology descriptions. Obviously, the drawings described below are some embodiments of the present application, and a person skilled in the art can also obtain other drawings based on these drawings.
[0071] Figure 1 A schematic diagram of the structure of a data transmission device provided in an embodiment of the present application;
[0072] Figure 2 A schematic diagram of a data transmission process provided in an embodiment of the present application;
[0073] Figure 3 A schematic diagram of another data transmission process provided in an embodiment of the present application;
[0074] Figure 4 A schematic diagram of another data transmission process provided in an embodiment of the present application;
[0075] Figure 5 A schematic diagram of another data transmission process provided in an embodiment of the present application;
[0076] Figure 6 A schematic diagram of another data transmission process provided in an embodiment of the present application;
[0077] Figure 7 A schematic diagram of another data transmission process provided in an embodiment of the present application;
[0078] Figure 8 A schematic diagram of another data transmission process provided in an embodiment of the present application;
[0079] Fig. 9 A schematic diagram of another data transmission process provided in an embodiment of the present application;
[0080] Fig.10A schematic diagram of the structure of a data transmission device provided in an embodiment of the present application;
[0081] Fig.11 A schematic diagram of another data transmission device structure provided in an embodiment of the present application;
[0082] Fig.12 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0083] Fig.13 A schematic diagram of the structure of another electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0084] In order to make the purpose and implementation method of the present application clearer, the exemplary implementation method of the present application will be clearly and completely described below in conjunction with the drawings in the exemplary embodiments of the present application. Obviously, the described exemplary embodiments are only part of the embodiments of the present application, rather than all the embodiments.
[0085] It should be noted that the brief description of terms in this application is only for the convenience of understanding the embodiments described below, and is not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their common and usual meanings.
[0086] The terms "first", "second", "third", etc. in the specification and claims of this application and the above drawings are used to distinguish similar or similar objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise noted. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances.
[0087] The terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover but not exclude inclusion, for example, a product or device comprising a list of components is not necessarily limited to all the components expressly listed but may include other components not expressly listed or inherent to such product or device.
[0088] The term "module" refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code that is capable of performing the functions associated with that element.
[0089] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
[0090] For the convenience of explanation, the above description has been made in conjunction with specific embodiments. However, the above exemplary discussion is not intended to be exhaustive or limit the embodiments to the specific forms disclosed above. Based on the above teachings, various modifications and variations can be obtained. The selection and description of the above embodiments are to better explain the principles and practical applications, so that those skilled in the art can better use the embodiments and various different variations of the embodiments suitable for specific use considerations.
[0091] The embodiments of the present application provide a data transmission device, method, apparatus, equipment and medium. In the device, the user interface layer module can generate an identifier corresponding to the data and the user interface generated by any user interface to be transmitted to the processing layer, and send the identifier and the data to the processing layer module; when the processing layer module receives the identifier and the data, it can perform corresponding processing on the data, and after the processing is completed, it can send the processing result and the identifier to the user interface layer module; after receiving the identifier and the processing result, the user interface layer module can make a corresponding display in the user interface according to the processing result.
[0092] Compared with the related art in which data is transmitted between the user interface (user interface layer) and the processing layer based on synchronous transmission, after the user interface sends the data to the processing layer, while the processing layer processes the data accordingly, the user interface also needs to wait in real time for the processing results of the data by the processing layer. In the process of waiting for the processing results, it is easy for the user interface (page) to be blocked, which affects the user experience. The embodiment of the present application provides a method of transmitting data between the user interface layer module and the processing layer module through asynchronous transmission. The user interface layer module and the processing layer module can identify different data and the processing results corresponding to different data based on identifiers. For example, in the process of the processing layer module processing the data, the user interface layer module and the user interface do not need to wait in real time for the processing results of the data by the processing layer module, thereby reducing the occurrence of user interface blocking and achieving the purpose of quickly and efficiently transmitting data between the user interface layer and the processing layer.
[0093] Embodiment 1:
[0094] Figure 1 A schematic diagram of a data transmission device structure provided in an embodiment of the present application, the device includes:
[0095] The user interface layer module 11 is used to generate an identifier corresponding to the data and the user interface generated by any user interface to be transmitted to the processing layer, and send the identifier and the data to the processing layer module 12;
[0096] The processing layer module 12 is used for processing the data accordingly upon receiving the identification and the data, and sending the processing result and the identification to the user interface layer module 11 after the processing is completed;
[0097] The user interface layer module 11 is further used to receive the identifier and the processing result, and to display the processing result in the user interface accordingly.
[0098] The data transmission device provided in the embodiment of the present application may be a personal computer (PC). In addition, the data transmission device may also be an electronic device such as a mobile terminal or a server, and the present application does not make any specific limitation on this.
[0099] In a possible implementation, in order to quickly and efficiently transmit data between the user interface layer and the processing layer, when the user interface in the user interface layer generates data that needs to be processed by the processing layer, the user interface layer module 11 in the data transmission device can generate an identifier corresponding to the data and the user interface for the data. The identifier can be a string including at least one of numbers, letters, symbols, and text, and the application does not specifically limit the specific content of the identifier.
[0100] In a possible implementation, in order to quickly and flexibly generate the corresponding data and the identification of the user interface, the user interface layer module 11 can obtain the timestamp information when the user interface generates the data. In addition, a random number can be generated based on a random number generation algorithm, etc. After that, the user interface layer module 11 can generate the identification of the corresponding data and the user interface based on at least one of the timestamp information when the user interface generates the data and the generated random number. For example, only the timestamp information when the user interface generates the data can be used as the identification of the corresponding data and the user interface, or only the generated random number can be used as the identification of the corresponding data and the user interface, or a combination of the above timestamp information and random numbers can be used as the identification of the corresponding data and the user interface, which can be flexibly set according to needs.
[0101] Since it is relatively easy to obtain timestamp information and random numbers, and the probability of duplication between different timestamps and different random numbers is relatively small, the present application generates an identifier corresponding to the data and the user interface based on the timestamp information when the user interface generates data, and at least one of the generated random numbers, which can improve the speed and flexibility of generating identifiers.
[0102] In a possible implementation, after generating the corresponding data and the identifier of the user interface, the user interface layer module 11 may send the identifier and the data together to the processing layer module 12 in the data transmission device. In a possible implementation, when the user interface layer module 11 sends the identifier and the data together to the processing layer module 12 in the data transmission device, the user interface layer module 11 may send the identifier and the data to the processing layer module 12 based on the CefMessageRouter interface provided by jcef and the like in the data transmission device.
[0103] Among them, for Java applications, its processing layer (processing layer module, also known as control layer, Controller, C layer) can be a Java base, and the user interface (User Interface, UI) can be a user interface built based on the open source web browser Chromium as the kernel. Data can be exchanged between the processing layer and the user interface layer through jcef. jcef is a framework that can embed the open source web browser Chromium into Java applications, which will not be repeated here.
[0104] Since the user interface layer module 11 can send the identifier and data to the processing layer module 12 based on the CefMessageRouter interface, the speed, stability and accuracy of data transmission can be guaranteed to the greatest extent.
[0105] In a possible implementation, after receiving the identifier and data sent by the user interface layer module 11, the processing layer module 12 may perform corresponding processing on the data based on the processing layer, and after the data processing is completed, the processing result and the identifier may be sent (returned) to the user interface layer module 11. The process of processing the data by the processing layer module 12 may adopt the existing technology, which will not be described in detail here.
[0106] In a possible implementation, when the processing layer module 12 sends (returns) the processing result and the identifier to the user interface layer module 11, it can send the processing result and the corresponding identifier to the user interface layer module 11 based on the executeJavaScript function (method) provided by jcef.
[0107] Since the processing layer module 12 can send the identifier and the processing result to the user interface layer module 11 based on the executeJavaScript function provided by jcef, the speed, stability and accuracy of data transmission can be guaranteed to the greatest extent.
[0108] It is worth noting that in the related art, for example, when the user interface sends (transmits) the generated data to the processing layer based on synchronous transmission, after the user interface sends the data to the processing layer, while the processing layer processes the data accordingly, the user interface also needs to wait in real time for the processing result of the data by the processing layer. In the process of waiting for the processing result, it is easy for the user interface (browser page) to be blocked. In the embodiment of the present application, the user interface layer module 11 and the processing layer module 12 can identify different data and the processing results corresponding to different data based on the identifier. For example, in the process of the processing layer module 12 processing the data, the user interface layer module 11 and the user interface do not need to wait in real time for the processing result of the data by the processing layer module 12, thereby reducing the occurrence of user interface (browser page) blocking. The data transmission method provided in the embodiment of the present application can be called an asynchronous transmission method.
[0109] In a possible implementation, when the user interface layer module 11 receives the identifier and processing result sent by the processing layer module 12, it can identify the user interface corresponding to the identifier, and can display it in the user interface corresponding to the identifier according to the processing result. The present application does not specifically limit the specific content of the user interface display.
[0110] Compared with the related art in which data is transmitted between the user interface and the processing layer in the user interface layer based on synchronous transmission, after the user interface sends the data to the processing layer, while the processing layer processes the data accordingly, the user interface also needs to wait in real time for the processing results of the data by the processing layer. In the process of waiting for the processing results, user interface blocking and the like are prone to occur, which affects the user experience. In the embodiment of the present application, the user interface layer module 11 and the processing layer module 12 are provided with a method of transmitting data through asynchronous transmission. The user interface layer module 11 and the processing layer module 12 can identify different data and the processing results corresponding to different data based on identifiers. For example, in the process of the processing layer module 12 processing the data, the user interface layer module 11 and the user interface do not need to wait in real time for the processing results of the data by the processing layer module 12, thereby reducing the occurrence of user interface blocking and achieving the purpose of quickly and efficiently transmitting data between the user interface layer and the processing layer.
[0111] In addition, the method of performing data transmission between the user interface layer module 11 and the processing layer module 12 through asynchronous transmission provided in the embodiment of the present application can be applied to each data transmission process between any user interface in the user interface layer and the processing layer. There is no need to separately configure a specific data transmission method for each data transmission process, which can improve the speed and convenience of data transmission.
[0112] Embodiment 2:
[0113] In order to quickly and efficiently display the data processing results in the user interface, based on the above embodiment, in the embodiment of the present application, the user interface layer module 11 is specifically used for:
[0114] If the processing result is a successful processing result, calling the execution completion resolve callback function in the created Promise object corresponding to the identifier, and displaying the corresponding first page in the user interface;
[0115] If the processing result is a processing result of execution failure, the execution failure reject callback function in the Promise object is called, and the corresponding second page is displayed in the user interface.
[0116] In a possible implementation, the user interface layer module 11 may create a promise object corresponding to the identifier when creating the identifier corresponding to the above identifier and the user interface. The Promise object may include a resolve callback function and a reject callback function. The Promise object corresponds to the user interface that generates the data of the above identifier, and the Promise object may be returned to the user interface (caller).
[0117] In a possible implementation, the Promise object can be saved in a pre-created request line (requestLine) object using the above identifier as a keyword (key) and the resolve callback function and the reject callback function contained in the Promise object as the values (value) corresponding to the keyword. The requestLine object can store Promise objects corresponding to several different identifiers. Among them, the requestLine object can be a JavaScript object (JavaScript Object Notation, JSON), that is, a js object, which will not be repeated here.
[0118] In a possible implementation, the user interface layer module 11 receives the above-mentioned identifier and the corresponding processing result. According to the processing result, when the corresponding display is performed in the user interface corresponding to the identifier, when the processing result is a processing result of successful execution, the resolve callback function in the Promise object is called, so as to realize the display of the corresponding first page in the user interface corresponding to the identifier. When the processing result is a processing result of failed execution, the reject callback function in the Promise object is called, so as to realize the display of the corresponding second page in the user interface corresponding to the identifier. Among them, the present application does not specifically limit the specific content of the first page and the second page. For example, when the data generated by the user interface is data generated in response to a user click operation, the first page may be a page displayed when the user click operation is successfully responded to, and the second page may be a prompt page displayed when the user click operation fails.
[0119] Since the present application can create a Promise object corresponding to the identifier of the data generated by the user interface, the first page corresponding to the user interface when the processing result is successful execution can be displayed based on the resolve callback function in the Promise object, and the second page corresponding to the user interface when the processing result is failed execution can be displayed based on the reject callback function in the Promise object, thereby quickly and efficiently displaying the processing results of the data by the processing layer (processing layer module 12) in the user interface.
[0120] In a possible implementation, in order to save storage resources, the user interface layer module 11 can also delete the saved (created) Promise object corresponding to the above identifier after completing the entire process of asynchronous data transmission according to the processing result and displaying it in the user interface. Exemplarily, the Promise object corresponding to the identifier saved in the requestLine object can be deleted.
[0121] Since the present application can delete the saved corresponding Promise object after completing the entire process of data transmission, the storage space can be reclaimed and storage resources can be saved.
[0122] In a possible implementation, the user interface layer module 11 may also output a prompt message indicating that the processing of the user interface corresponding to the identifier has timed out when it identifies that the processing result corresponding to the above identifier sent by the processing layer module 12 has not been received within a set time period, so as to prompt the user for reference, etc. Exemplarily, the user interface layer module 11 may identify whether the processing result corresponding to the identifier sent by the processing layer module 12 has been received within a set time period based on the Promise object corresponding to the identifier. If the processing result corresponding to the identifier sent by the processing layer module 12 has not been received within the set time period, a prompt message indicating that the data processing of the user interface has timed out may be output in the corresponding user interface based on the Promise object corresponding to the identifier. The set time period and the specific content of the prompt message may be flexibly set according to demand, and this application does not specifically limit this.
[0123] When the processing result corresponding to the above-mentioned identifier is not received from the processing layer module 12 within the set time period, a prompt message of processing timeout for the user interface corresponding to the identifier is output to prompt the user, thereby improving the user experience.
[0124] For ease of understanding, the data transmission process provided by the present application is explained below through a specific embodiment. Figure 2 , Figure 2 A schematic diagram of a data transmission process provided in an embodiment of the present application, the process includes the following steps:
[0125] S201 : the user interface layer module 11 generates an identifier corresponding to the data and the user interface for data to be transmitted to the processing layer generated by any user interface, and sends the identifier and the data to the processing layer module 12 .
[0126] S202 : When the processing layer module 12 receives the identifier and the data, it processes the data accordingly, and after the processing is completed, sends the processing result and the identifier to the user interface layer module 11 .
[0127] S203: After the user interface layer module 11 receives the identifier and processing result sent by the processing layer module 12, if the processing result is a successful processing result, the resolve callback function in the created Promise object corresponding to the identifier is called, and the corresponding first page is displayed in the user interface corresponding to the identifier. If the processing result is a failed processing result, the reject callback function in the Promise object corresponding to the identifier is called, and the corresponding second page is displayed in the user interface corresponding to the identifier.
[0128] For ease of understanding, the data transmission process provided by the present application is explained below through a specific embodiment. Figure 3 , Figure 3 A schematic diagram of another data transmission process provided in an embodiment of the present application, the process includes the following steps:
[0129] S301: The user interface layer module 11 generates an identifier corresponding to the data and the user interface for data to be transmitted to the processing layer generated by any user interface, and sends the identifier and the data to the processing layer module 12. At the same time, the user interface layer module 11 can create a Promise object corresponding to the identifier, save the Promise object in the requestLine object, and return the Promise object to the user interface.
[0130] S302 : When the processing layer module 12 receives the identifier and the data, it processes the data accordingly, and after the processing is completed, sends the processing result and the identifier to the user interface layer module 11 .
[0131] S303: After the user interface layer module 11 receives the identifier and processing result sent by the processing layer module 12, if the processing result is a successful processing result, then according to the identifier, the Promise object corresponding to the identifier is matched in the requestLine object, and the resolve callback function in the Promise object is called to display the corresponding first page in the user interface corresponding to the identifier. If the processing result is a failed processing result, the reject callback function in the Promise object is called to display the corresponding second page in the user interface corresponding to the identifier.
[0132] S304: the user interface layer module 11 deletes the created Promise object corresponding to the identifier.
[0133] For ease of understanding, the data transmission process provided by the present application is explained below through a specific embodiment. Figure 4 , Figure 4 A schematic diagram of another data transmission process provided in an embodiment of the present application, the process includes the following steps:
[0134] S401: The user interface layer module 11 generates an identifier corresponding to the data and the user interface for data to be transmitted to the processing layer generated by any user interface, and sends the identifier and the data to the processing layer module 12. At the same time, the user interface layer module 11 can create a Promise object corresponding to the identifier, save the Promise object in the requestLine object, and return the Promise object to the user interface.
[0135] S402: When the processing layer module 12 receives the identifier and the data, it processes the data accordingly.
[0136] S403: If the user interface layer module 11 recognizes that the processing result corresponding to the identifier sent by the processing layer module 12 is not received within the set time period based on the Promise object corresponding to the identifier, it can display a processing timeout prompt message in the user interface corresponding to the identifier based on the Promise object.
[0137] For ease of understanding, the data transmission process provided by the present application is explained below through a specific embodiment. Figure 5 , Figure 5 A schematic diagram of another data transmission process provided in an embodiment of the present application, the process includes the following steps:
[0138] S501: The user interface layer module 11 generates an identifier corresponding to the data and the user interface for any user interface to be transmitted to the processing layer, and sends the identifier and the data to the processing layer module 12 based on the CefMessageRouter interface provided by jcef.
[0139] S502: When the processing layer module 12 receives the identifier and the data, it processes the data accordingly, and after the processing is completed, based on the executeJavaScript function provided by jcef, sends the processing result and the identifier to the user interface layer module 11.
[0140] S503: After the user interface layer module 11 receives the identifier and processing result sent by the processing layer module 12, if the processing result is a successful processing result, the resolve callback function in the Promise object created corresponding to the identifier is called, and the corresponding first page is displayed in the user interface corresponding to the identifier. If the processing result is a failed processing result, the reject callback function in the Promise object created corresponding to the identifier is called, and the corresponding second page is displayed in the user interface corresponding to the identifier.
[0141] S504: the user interface layer module 11 deletes the created Promise object corresponding to the identifier.
[0142] For ease of understanding, the data transmission process provided by the present application is explained below through a specific embodiment. Figure 6 , Figure 6 A schematic diagram of another data transmission process provided in an embodiment of the present application, the process includes the following steps:
[0143] S601: The user interface layer module 11 generates an identifier corresponding to the data and the user interface for data generated by any user interface to be transmitted to the processing layer based on the timestamp information when the data is generated and the generated random number.
[0144] S602: The user interface layer module 11 sends the identifier and the data to the processing layer module 12 based on the CefMessageRouter interface provided by jcef. At the same time, the user interface layer module 11 can create a Promise object corresponding to the identifier, save the Promise object in the requestLine object, and return the Promise object to the user interface.
[0145] S603: When the processing layer module 12 receives the identifier and the data, it processes the data accordingly, and after the processing is completed, sends the processing result and the identifier to the user interface layer module 11.
[0146] S604: After the user interface layer module 11 receives the identifier and processing result sent by the processing layer module 12, if the processing result is a successful processing result, then according to the identifier, the Promise object corresponding to the identifier is matched in the requestLine object, and the resolve callback function in the Promise object is called to display the corresponding first page in the user interface corresponding to the identifier. If the processing result is a failed processing result, the reject callback function in the Promise object is called to display the corresponding second page in the user interface corresponding to the identifier.
[0147] Embodiment 3:
[0148] For ease of understanding, the data transmission process provided by this application is explained below through a specific embodiment. Figure 7 , Figure 7 A schematic diagram of another data transmission process provided in an embodiment of the present application, the process includes the following steps:
[0149] S701: The user interface layer module 11 generates an identifier corresponding to the data and the user interface for data generated by any user interface to be transmitted to the processing layer based on the timestamp information when the data is generated and the generated random number.
[0150] S702: The user interface layer module 11 sends the identifier and the data to the processing layer module 12 based on the CefMessageRouter interface provided by jcef. At the same time, the user interface layer module 11 can create a Promise object corresponding to the identifier, save the Promise object in the requestLine object, and return the Promise object to the user interface.
[0151] S703: When the processing layer module 12 receives the identifier and the data, it processes the data accordingly, and after the processing is completed, based on the executeJavaScript function provided by jcef, sends the processing result and the identifier to the user interface layer module 11.
[0152] S704: After the user interface layer module 11 receives the identifier and processing result sent by the processing layer module 12, if the processing result is a successful processing result, then according to the identifier, the Promise object corresponding to the identifier is matched in the requestLine object, and the resolve callback function in the Promise object is called to display the corresponding first page in the user interface corresponding to the identifier. If the processing result is a failed processing result, the reject callback function in the Promise object is called to display the corresponding second page in the user interface corresponding to the identifier.
[0153] S705: The user interface layer module 11 deletes the created Promise object corresponding to the identifier.
[0154] Embodiment 4:
[0155] Based on the same technical concept, on the basis of the above embodiments, the present application provides a data transmission method, which is applied to an electronic device, such as a PC, a mobile terminal, a server, etc., which is not specifically limited in the present application. Figure 8 , Figure 8 A schematic diagram of a data transmission process provided in an embodiment of the present application, the process includes the following steps:
[0156] S801: For data generated by any user interface to be transmitted to the processing layer, generate an identifier corresponding to the data and the user interface, and send the identifier and the data to the processing layer module, so that the processing layer module processes the data accordingly.
[0157] S802: Receive the processing result of the data and the identifier sent by the processing layer module, and display the processing result in the user interface accordingly.
[0158] In a possible implementation, displaying the processing result in the user interface accordingly includes:
[0159] If the processing result is a successful processing result, calling the execution completion resolve callback function in the created Promise object corresponding to the identifier, and displaying the corresponding first page in the user interface;
[0160] If the processing result is a processing result of execution failure, the execution failure reject callback function in the Promise object is called, and the corresponding second page is displayed in the user interface.
[0161] In a possible implementation, after performing corresponding display in the user interface according to the processing result, the method further includes:
[0162] Delete the created Promise object corresponding to the specified identifier.
[0163] In a possible implementation, after sending the identifier and the data to the processing layer module and before receiving the processing result of the data and the identifier sent by the processing layer module, the method further includes:
[0164] If the processing result corresponding to the identifier sent by the processing layer module is not received within the set time period, a prompt message indicating that the processing timeout has occurred for the user interface is output.
[0165] In a possible implementation, the generating an identifier corresponding to the data and the user interface includes:
[0166] Based on at least one of the timestamp information when the data is generated and the generated random number, an identifier corresponding to the data and the user interface is generated.
[0167] In a possible implementation manner, sending the identifier and the data to a processing layer module includes:
[0168] Based on the CefMessageRouter interface of jcef, the identifier and the data are sent to the processing layer module.
[0169] Embodiment 5:
[0170] Based on the same technical concept, on the basis of the above embodiments, the present application provides a data transmission method, which is applied to an electronic device, such as a PC, a mobile terminal, a server, etc., which is not specifically limited in the present application. Fig. 9 , Fig. 9 A schematic diagram of another data transmission process provided in an embodiment of the present application, the process includes the following steps:
[0171] S901: Receive an identifier and data sent by a user interface layer module, wherein the identifier corresponds to the data and a user interface that generates the data.
[0172] S902: Process the data accordingly, and after the processing is completed, send the processing result and the identifier to the user interface layer module, so that the user interface layer module performs corresponding display in the user interface according to the processing result.
[0173] In a possible implementation manner, sending the processing result and the identifier to the user interface layer module includes:
[0174] Based on the executeJavaScript function of jcef, the processing result and the identifier are sent to the user interface layer module.
[0175] Embodiment 6:
[0176] Based on the same technical concept, on the basis of the above embodiments, the present application provides a data transmission device, referring to Fig.10 , Fig.10 A schematic diagram of a data transmission device 1000 provided in an embodiment of the present application, the device comprising:
[0177] The first transmission unit 1001 is used to generate an identifier corresponding to the data and the user interface for data generated by any user interface to be transmitted to the processing layer, and send the identifier and the data to the processing layer module so that the processing layer module processes the data accordingly;
[0178] The first receiving unit 1002 is used to receive the processing result of the data and the identifier sent by the processing layer module, and display the processing result in the user interface accordingly.
[0179] In a possible implementation manner, the first receiving unit 1002 is specifically configured to:
[0180] If the processing result is a successful processing result, calling the execution completion resolve callback function in the created Promise object corresponding to the identifier, and displaying the corresponding first page in the user interface;
[0181] If the processing result is a processing result of execution failure, the execution failure reject callback function in the Promise object is called, and the corresponding second page is displayed in the user interface.
[0182] In a possible implementation manner, the first receiving unit 1002 is further configured to:
[0183] Delete the created Promise object corresponding to the specified identifier.
[0184] In a possible implementation manner, the first transmission unit 1001 is further configured to:
[0185] If the processing result corresponding to the identifier sent by the processing layer module is not received within the set time period, a prompt message indicating that the processing timeout has occurred for the user interface is output.
[0186] In a possible implementation manner, the first transmission unit 1001 is specifically configured to:
[0187] Based on at least one of the timestamp information when the data is generated and the generated random number, an identifier corresponding to the data and the user interface is generated.
[0188] In a possible implementation manner, the first transmission unit 1001 is specifically configured to:
[0189] Based on the CefMessageRouter interface of jcef, the identifier and the data are sent to the processing layer module.
[0190] Embodiment 7:
[0191] Based on the same technical concept, on the basis of the above embodiments, the present application provides a data transmission device, referring to Fig.11 , Fig.11 A schematic diagram of another data transmission device 1100 provided in an embodiment of the present application, the device comprising:
[0192] The second receiving unit 1101 is used to receive an identifier and data sent by the user interface layer module, wherein the identifier corresponds to the data and a user interface that generates the data;
[0193] The second transmission unit 1102 is used to process the data accordingly, and after the processing is completed, send the processing result and the identifier to the user interface layer module, so that the user interface layer module performs corresponding display in the user interface according to the processing result.
[0194] In a possible implementation manner, the second transmission unit 1102 is specifically configured to:
[0195] Based on the executeJavaScript function of jcef, the processing result and the identifier are sent to the user interface layer module.
[0196] Embodiment 8:
[0197] Based on the same technical concept, the present application also provides an electronic device, Fig.12 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Fig.12As shown, it includes: a processor 1201, a communication interface 1202, a memory 1203 and a communication bus 1204, wherein the processor 1201, the communication interface 1202, and the memory 1203 communicate with each other through the communication bus 1204;
[0198] The memory 1203 stores a computer program. When the program is executed by the processor 1201, the processor 1201 performs the following steps:
[0199] For data generated by any user interface to be transmitted to the processing layer, generate an identifier corresponding to the data and the user interface, and send the identifier and the data to the processing layer module, so that the processing layer module processes the data accordingly;
[0200] Receive the processing result of the data and the identifier sent by the processing layer module, and display them accordingly in the user interface according to the processing result.
[0201] In a possible implementation manner, the processor 1201 is specifically configured to:
[0202] If the processing result is a successful processing result, calling the execution completion resolve callback function in the created Promise object corresponding to the identifier, and displaying the corresponding first page in the user interface;
[0203] If the processing result is a processing result of execution failure, the execution failure reject callback function in the Promise object is called, and the corresponding second page is displayed in the user interface.
[0204] In a possible implementation, the processor 1201 is further configured to:
[0205] Delete the created Promise object corresponding to the specified identifier.
[0206] In a possible implementation, the processor 1201 is further configured to:
[0207] If the processing result corresponding to the identifier sent by the processing layer module is not received within the set time period, a prompt message indicating that the processing timeout has occurred for the user interface is output.
[0208] In a possible implementation manner, the processor 1201 is specifically configured to:
[0209] Based on at least one of the timestamp information when the data is generated and the generated random number, an identifier corresponding to the data and the user interface is generated.
[0210] In a possible implementation manner, the processor 1201 is specifically configured to:
[0211] Based on the CefMessageRouter interface of jcef, the identifier and the data are sent to the processing layer module.
[0212] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0213] The communication interface 1202 is used for communication between the above electronic device and other devices.
[0214] Based on the same technical concept, the present application also provides an electronic device, Fig.13 A schematic diagram of another electronic device structure provided in an embodiment of the present application is shown in FIG. Fig.13 As shown, it includes: a processor 1301, a communication interface 1302, a memory 1303 and a communication bus 1304, wherein the processor 1301, the communication interface 1302, and the memory 1303 communicate with each other through the communication bus 1304;
[0215] The memory 1303 stores a computer program. When the program is executed by the processor 1301, the processor 1301 performs the following steps:
[0216] Receiving an identifier and data sent by a user interface layer module, wherein the identifier corresponds to the data and a user interface generating the data;
[0217] The data is processed accordingly, and after the processing is completed, the processing result and the identifier are sent to the user interface layer module, so that the user interface layer module performs corresponding display in the user interface according to the processing result.
[0218] In a possible implementation manner, the processor 1301 is specifically configured to:
[0219] Based on the executeJavaScript function of jcef, the processing result and the identifier are sent to the user interface layer module.
[0220] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0221] The communication interface 1302 is used for communication between the above electronic device and other devices.
[0222] Please refer again Fig.12 and Fig.13 The memory in the electronic device may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0223] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; it can also be a digital signal processing processor (Digital Signal Processing, DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.
[0224] Embodiment 9:
[0225] Based on the same technical concept, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program that can be executed by an electronic device. When the program runs on the electronic device, the electronic device implements any of the above embodiments when executing.
[0226] The above-mentioned computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor in the electronic device, including but not limited to magnetic storage such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc., optical storage such as CD, DVD, BD, HVD, etc., and semiconductor storage such as ROM, EPROM, EEPROM, non-volatile memory (NANDFLASH), solid-state drive (SSD), etc.
[0227] Based on the same technical concept, the embodiment of the present application also provides a computer program product, which includes: computer program code, when the computer program code is run on a computer, the computer executes any of the above embodiments. Since the principle of solving the problem by the above computer program product is similar to that of the data transmission method, the implementation of the above computer program product can refer to the implementation of the method, and the repeated parts will not be repeated.
[0228] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0229] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0230] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0231] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0232] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A data transmission device, characterized in that: The device comprises: A user interface layer module, for generating, for data generated by any user interface to be transmitted to the processing layer, an identifier corresponding to the data and the user interface, and sending the identifier and the data to the processing layer module; The processing layer module is used for processing the data accordingly upon receiving the identifier and the data, and sending the processing result and the identifier to the user interface layer module after the processing is completed; The user interface layer module is further used to receive the identifier and the processing result, and to display the processing result accordingly in the user interface.
2. The device according to claim 1, characterized in that The user interface layer module is specifically used for: If the processing result is a successful processing result, calling the execution completion resolve callback function in the created Promise object corresponding to the identifier, and displaying the corresponding first page in the user interface; If the processing result is a processing result of execution failure, the execution failure reject callback function in the Promise object is called, and the corresponding second page is displayed in the user interface.
3. The device according to claim 2, characterized in that The user interface layer module is also used for: After corresponding display is performed in the user interface according to the processing result, the created Promise object corresponding to the identifier is deleted.
4. The device according to any one of claims 1 to 3, characterized in that: The user interface layer module is also used for: If the processing result corresponding to the identifier sent by the processing layer module is not received within the set time period, a prompt message indicating that the processing timeout has occurred for the user interface is output.
5. The device according to any one of claims 1 to 3, characterized in that: The user interface layer module is specifically used for: Based on at least one of the timestamp information when the data is generated and the generated random number, an identifier corresponding to the data and the user interface is generated.
6. The device according to any one of claims 1 to 3, characterized in that: The user interface layer module is specifically used for: Based on the CefMessageRouter interface of the java chromium embedded framework jcef, the identifier and the data are sent to the processing layer module.
7. The device according to any one of claims 1 to 3, characterized in that: The processing layer module is specifically used for: Based on the executeJavaScript function of jcef, the processing result and the identifier are sent to the user interface layer module.
8. A data transmission method, characterized in that: The method comprises: For data generated by any user interface to be transmitted to the processing layer, generate an identifier corresponding to the data and the user interface, and send the identifier and the data to the processing layer module, so that the processing layer module processes the data accordingly; Receive the processing result of the data and the identifier sent by the processing layer module, and display them accordingly in the user interface according to the processing result.
9. The method according to claim 8, characterized in that The corresponding display in the user interface according to the processing result includes: If the processing result is a successful processing result, calling the execution completion resolve callback function in the created Promise object corresponding to the identifier, and displaying the corresponding first page in the user interface; If the processing result is a processing result of execution failure, the execution failure reject callback function in the Promise object is called, and the corresponding second page is displayed in the user interface.
10. A data transmission method, characterized in that: The method comprises: Receiving an identifier and data sent by a user interface layer module, wherein the identifier corresponds to the data and a user interface generating the data; The data is processed accordingly, and after the processing is completed, the processing result and the identifier are sent to the user interface layer module, so that the user interface layer module performs corresponding display in the user interface according to the processing result.