CN113010237B - Data interaction method, system, electronic equipment and storage medium - Google Patents

Data interaction method, system, electronic equipment and storage medium

Info

Publication number
CN113010237B
CN113010237B CN202110307703.9A CN202110307703A CN113010237B CN 113010237 B CN113010237 B CN 113010237B CN 202110307703 A CN202110307703 A CN 202110307703A CN 113010237 B CN113010237 B CN 113010237B
Authority
CN
China
Prior art keywords
html
container
service
local
local resource
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110307703.9A
Other languages
Chinese (zh)
Other versions
CN113010237A (en
Inventor
许声志
林俊杰
沈仲侃
薛宏涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Servyou Software Group Co ltd
Original Assignee
Servyou Software Group Co ltd
Filing date
Publication date
Application filed by Servyou Software Group Co ltd filed Critical Servyou Software Group Co ltd
Priority to CN202110307703.9A priority Critical patent/CN113010237B/en
Publication of CN113010237A publication Critical patent/CN113010237A/en
Application granted granted Critical
Publication of CN113010237B publication Critical patent/CN113010237B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a data interaction method, which comprises the following steps: the HTML program generates a local resource acquisition request by utilizing a service interface provided by an HTML container, and sends the local resource acquisition request to a local service container through a container process of the HTML container; the local service container processes the received local resource acquisition request by utilizing the business service contained in the local service container to obtain corresponding local resource data, and sends the local resource data to the HTML container; the HTML container receives the local resource data and sends the local resource data to the HTML program; the HTML program in the method can directly use the HTML container and the local service container to acquire local resources, and can ensure that the HTML program gets rid of the constraint of HTTP service so that the HTML can be better applied in the local program; the invention also provides a data interaction system, electronic equipment and a storage medium, which have the beneficial effects.

Description

Data interaction method, system, electronic equipment and storage medium
Technical Field
The present invention relates to the field of HTML technologies, and in particular, to a data interaction method, system, electronic device, and storage medium.
Background
HTML, a mature man-machine interaction technology, has been applied in many applications. However, in the related art, the access of HTML to local resources is strictly limited by HTTP service, and if the device where the application program is located does not start HTTP service, the local resources cannot be obtained by using HTML, which brings inconvenience to the application of the HTML technology in the local program. Therefore, how to ensure that HTML programs efficiently acquire local resources is a technical problem that those skilled in the art need to face.
Disclosure of Invention
The invention aims to provide a data interaction method, a system, electronic equipment and a storage medium, which can provide an HTML container and a local service container for an HTML program so that the HTML program can directly use the HTML container and the local service container to acquire local resources without using HTTP service, and can ensure that the HTML program gets rid of the constraint of the HTTP service so that the HTML program can be better applied in the local program.
In order to solve the technical problems, the invention provides a data interaction method, which comprises the following steps:
The method comprises the steps that an HTML program generates a local resource acquisition request by utilizing a service interface provided by an HTML container, and sends the local resource acquisition request to a local service container through a container process of the HTML container;
The local service container processes the received local resource acquisition request by utilizing the business service contained in the local service container to obtain corresponding local resource data, and sends the local resource data to the HTML container;
The HTML container receives the local resource data and sends the local resource data to the HTML program.
Optionally, the sending, by the container process of the HTML container, the local resource acquisition request to a local service container includes:
the HTML program sends the local resource acquisition request to a Render process of the HTML container;
The Render process generates and saves the first context information of the local resource acquisition request, and sends the local resource acquisition request to a Browser process of the HTML container through an inter-process interface provided by the HTML container;
The Browser process generates and stores second context information of the local resource acquisition request, and sends the local resource acquisition request to the local service container.
Optionally, the HTML container receives the local resource data and sends the local resource data to the HTML program, including:
The Browser process receives the local resource data and sends the local resource data to the Render process according to the second context information;
and the Render process receives the local resource data and sends the local resource data to the HTML program according to the first context information.
Optionally, before the HTML program generates the local resource acquisition request using the service interface provided by the HTML container, the method further includes:
the initiator generates an identifier and sends the identifier to the HTML container and the local service container;
The local service container receives the identifier and creates a communication service end by using the identifier;
and the HTML container receives the identifier, and searches and connects with the corresponding communication server according to the identifier.
Optionally, after searching and connecting the corresponding communication service end according to the identifier, the method further comprises:
the initiator sends first information to a first process handle corresponding to the HTML container and sends second information to a second process handle corresponding to the local service container;
If the initiator receives the first receipt information returned by the first process handle and does not receive the second receipt information returned by the second process handle, restarting the local service container;
And if the initiator does not receive the first receipt information returned by the first process handle, closing the local service container.
Optionally, the method further comprises:
The local service container generates an HTML call request and sends the HTML call request to the HTML container;
The HTML container receives the HTML call request and inquires corresponding call service information in the service interface according to the HTML call request;
and when the HTML container inquires the corresponding calling service information, calling the HTML program by using the calling service information.
Optionally, the HTML container receives the HTML call request, and queries corresponding call service information in the service interface according to the HTML call request, including:
the Browser process of the HTML container receives the HTML call request;
And the Browser process inquires calling service information corresponding to the HTML calling request in a service interface provided by a Render process through an inter-process communication interface provided by the HTML container.
The invention also provides a data interaction system which comprises a device for executing the data interaction method.
The present invention also provides an electronic device including:
a memory for storing a computer program;
And a processor for implementing the data interaction method as described above when executing the computer program.
The present invention also provides a storage medium having stored therein computer executable instructions which, when loaded and executed by a processor, implement a data interaction method as described above.
The invention provides a data interaction method, which comprises the following steps: the method comprises the steps that an HTML program generates a local resource acquisition request by utilizing a service interface provided by an HTML container, and sends the local resource acquisition request to a local service container through a container process of the HTML container; the local service container receives the local resource acquisition request, inquires local resource data by utilizing the local resource acquisition request, and sends the local resource data to the HTML container; the HTML container receives the local resource data and sends the local resource data to the HTML program.
It can be seen that in the method, the HTML program can perform local resource acquisition through the HTML container and the local service container. In the related art, since HTML is strictly limited by HTTP service, if the device where the HTML program is located does not start the HTTP service, the HTML cannot be used to acquire local resources. In the method, the HTML program can generate a local resource acquisition request by utilizing a service interface of the HTML container, the local resource acquisition request is sent to the local service container by utilizing a container process of the HTML container, and then the local service container is used for inquiring local resources, so that the HTML container and the local service container can be directly used for acquiring the local resources, HTTP service is not required to be used in the whole process, and further, the HTTP service is not required to be started by equipment where an application program is located, the HTML program can be finally ensured to get rid of the constraint of the HTTP service, and the application in the local program can be better realized. The invention also provides a data interaction system, electronic equipment and a storage medium, which have the beneficial effects.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present invention, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a data interaction method according to an embodiment of the present invention;
FIG. 2 is a flowchart of another data interaction method according to an embodiment of the present invention;
FIG. 3a is a block diagram illustrating a data interaction system according to an embodiment of the present invention;
FIG. 3b is a block diagram illustrating an HTML procedure according to an embodiment of the present invention;
FIG. 3c is a block diagram illustrating an HTML container according to an embodiment of the present invention;
FIG. 3d is a block diagram illustrating a local service container according to an embodiment of the present invention;
FIG. 3e is a block diagram illustrating another data interaction system according to an embodiment of the present invention;
fig. 3f is a block diagram of a starter according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In the related art, the acquisition and access of local resources such as text, audio, images and the like by an HTML program are strictly limited by HTTP service, and if the device where the program is located does not open HTTP service, the program cannot acquire and access with the local resources. The limitations of HTTP services to HTML programs prevent HTML technology from being used in local applications, which can be inconvenient for developers. In view of the above, the present invention provides a data interaction method, which can provide an HTML container and a local service container for an HTML program, so that the HTML program can directly use the HTML container and the local service container to obtain local resources, and can ensure that the HTML program gets rid of the constraint of the HTTP service without using the HTTP service, so that the HTML program can be better applied in the local program. Referring to fig. 1, fig. 1 is a flowchart of a data interaction method according to an embodiment of the present invention, where the method may include:
s101, the HTML program generates a local resource acquisition request by utilizing a service interface provided by an HTML container, and sends the local resource acquisition request to a local service container through a container process of the HTML container.
In the related art, in the link of sending the local resource acquisition request, the HTML program is strictly limited by the HTTP service, and if the device where the program is located does not open the HTTP service, the HTML program cannot send the local resource acquisition request. In the embodiment of the invention, the HTML program can complete the generation and transmission tasks of the local resource acquisition request through the HTML container, and the program can firstly call a service interface provided by the HTML container and used for generating the local resource acquisition request, wherein the service interface is used for realizing the service function of the local resource acquisition link; after generating the request, the program may further send the local resource acquisition request to the local service container through a container process provided by the HTML container, where the container process is used for sending the local resource acquisition request, and the local service container performs query and sending of the local resource. Therefore, the HTML program can directly complete generation and transmission of the local resource acquisition request through the HTML container, HTTP service is not required to be used, and further the equipment where the program is located is not required to start the HTTP service, so that the HTML program can be ensured to get rid of the constraint of the HTTP service in the transmission link of the local resource acquisition request.
It should be noted that, the embodiment of the present invention is not limited to the HTML version that can be supported by the HTML program and the HTML container, and may be, for example, HTML5, HTML4, or other versions of HTML. Considering that HTML5 is the latest HTML version and provides rich man-machine interaction functions, in the embodiment of the present invention, the HTML version that can be supported by the HTML program and the HTML container is HTML5.
Further, the embodiment of the invention is not limited to a development framework based on an HTML container, and the development framework can be any embedded browser framework, for example, a CEF framework or an Electron framework, wherein the CEF (Chromium Embedded Framework, embedded chrome framework) is an open source Web browser control based on a google chrome project, and the Electron framework is a light front-end development framework, which can be used for developing a desktop project. Considering the broader application of the Chromium kernel and CEF framework, in embodiments of the present invention, the HTML container may be developed based on the CEF framework.
Further, it will be understood that the service interface in the HTML container may perform some or several service functions in the local resource acquisition link, and in order to perform these service functions, the service interface may have any form and may include any content, and the user may develop the service interface according to the actual application requirements. It should be noted that, the embodiment of the present invention is not limited to the development manner of the service interface, and the service interface may be fully and autonomously developed, or may be extended based on a JavaScript running environment provided by a development framework, for example, when the development framework is a CEF, the service interface may be extended based on a V8 engine provided by the CEF, where the V8 engine is the JavaScript running environment provided by the CEF, and a Render process located in the CEF. Considering that the JavaScript running environment provided by the development framework can ensure good running of JavaScript codes, and can provide rich API functions at the same time, development is convenient for developers, in the embodiment of the invention, the JavaScript running environment provided by the development framework can be expanded, and in particular, the V8 engine provided by CEF can be expanded.
Further, the embodiment of the present invention is not limited to a specific container process for sending a local resource obtaining request in an HTML container, as long as the container process can implement the function of sending the local resource obtaining request to a local service container, for example, the container process for sending the local resource obtaining request may be specially developed for the HTML container, and may, of course, be a container process for performing secondary development based on a process provided by a development framework. In consideration of the fact that the process provided by the development framework can keep good fusion with the development framework, meanwhile, development period can be saved, and therefore the container process can be developed secondarily by utilizing the process provided by the development framework. Considering that the HTML container in the embodiment of the present invention is developed based on the CEF framework, and the Browser process in the CEF may be used to implement the sending function of the local resource acquisition request, and considering that the service interface of the HTML container is developed based on the renderer process, the container process in the embodiment of the present invention may generate the local resource acquisition request for the renderer process and the Browser process, that is, the HTML program calls the service interface, and sends the request to the renderer process, and the renderer process receives the request and forwards the request to the Browser process, and finally the Browser process sends the request to the local service container. It should be noted that, the embodiment of the present invention is not limited to the communication manner between the Render process and the Browser process, and the user may refer to the CEF framework and related technologies of inter-process communication. It will be appreciated that, in order to facilitate the return of local resource data, the above processes all need to record the context information in the process of sending the local resource acquisition request, so as to return the local resource data according to the context information later. It should be noted that, the embodiment of the present invention is not limited to the specific form of the context information, and the user may refer to the call chain and the related technology of the context information.
In one possible scenario, the process of the HTML program sending the local resource acquisition request to the local service container through the container process of the HTML container may include:
step 11: the HTML program sends a local resource acquisition request to a Render process of the HTML container;
Step 12: the Render process generates and stores first context information of a local resource acquisition request, and sends the local resource acquisition request to a Browser process of the HTML container through an inter-process interface provided by the HTML container;
Step 13: the Browser process generates and saves the second context information of the local resource acquisition request, and sends the local resource acquisition request to the local service container.
It should be noted that, the embodiments of the present invention are not limited to the specific form of the inter-process interface, and the user may refer to the related technology of the inter-process communication.
Finally, the embodiment of the invention is not limited to the communication mode between the HTML container and the local service container, and the communication mode may be any inter-process communication mode, for example, data communication by using a pipeline, data communication by using a message queue, or data communication by using a shared memory. In view of the ease of implementation of the pipeline, a pipeline may be employed in embodiments of the present invention as a means of communication between the HTML container and the local service container. The embodiment of the invention is not limited to specific pipeline types, and can be an anonymous pipeline or a named pipeline. In the embodiment of the invention, the naming pipelines can be adopted for data communication between the HTML container and the local service container, so that the naming pipelines can be flexibly applied, and the one-to-one correspondence between the data sending end and the data receiving end can be ensured.
S102, the local service container processes the received local resource acquisition request by utilizing the business service contained in the local service container to obtain corresponding local resource data, and sends the local resource data to the HTML container.
In the embodiment of the invention, the local service container is used for completing the receiving and analyzing of the local resource acquisition request, processing the local resource acquisition request by utilizing the service to obtain corresponding local resource data, and finally, transmitting the local resource data obtained by the query back to the HTML container. The embodiment of the invention is not limited to the specific form and content of the local service container, and users can develop according to the actual application requirements; the embodiment of the invention is not limited to specific business service, as long as the business service can obtain corresponding local resource data according to the local resource acquisition request. Because the query and return work of the local resource is completed by the local service container and the HTML container, and meanwhile, the generation and the transmission of the local resource acquisition request are completed by the HTML container, in the embodiment of the invention, the interaction between the HTML program and the local resource does not need to use HTTP service, and furthermore, the equipment where the program is located does not need to start the HTTP service, so that the HTML program can be ensured to get rid of the limitation of the HTTP service, and the convenience of the HTML technology in the development of the local application program is finally improved.
S103, the HTML container receives the local resource data and sends the local resource data to the HTML program.
It will be appreciated that, in order to ensure that the local resource acquisition request corresponds to the local resource data and that the local resource data is correctly returned to the HTML program, after the HTML container receives the local resource data, the local resource data should be returned in the original path according to the data transmission path used when the local resource acquisition request is sent. Therefore, in this step, the container process and the data transmission path used by the HTML container in the link of sending the local resource data to the HTML program are consistent with the container process and the data transmission path used by the HTML container in the link of sending the local resource acquisition request to the local service container, and only the application links of the data transmission direction and the context information are different, that is, in the link of sending the local resource data to the HTML program by the HTML container, the data transmission direction is the local service container to the HTML program, and the application mode of the context information is that the local resource data is returned according to the context information; in the step of transmitting the local resource acquisition request to the local service container, the data transmission direction is from the HTML program to the local service container, and the application mode of the context information is that the context information is generated according to the transmission process of the local resource acquisition request. The description about the container process and the data transmission path used in step S103 is identical to that in step S101, and will not be repeated here. In one possible scenario, the HTML container uses the Render process and the Browser process to send the local resource acquisition request, so in this scenario, the HTML container receives the local resource data and sends the local resource data to the HTML program, which may include:
step 21: the Browser process receives the local resource data and sends the local resource data to the Render process according to the second context information;
step 22: the Render process receives the local resource data and sends the local resource data to the HTML program according to the first context information.
Finally, it will be appreciated that the HTML container is used to carry the HTML program, i.e., the HTML program and the HTML container need to be in the same device. The embodiment of the invention does not limit whether the HTML container and the local service container are positioned in the same equipment, and the two containers can be positioned in different equipment or the same equipment, and can be set by a user according to actual application requirements.
Based on the above embodiment, in the method, the HTML program can perform local resource acquisition through the HTML container and the local service container. In the related art, since HTML is strictly limited by HTTP service, if the device where the HTML program is located does not start the HTTP service, the HTML cannot be used to acquire local resources. In the method, the HTML program can generate a local resource acquisition request by utilizing a service interface of the HTML container, the local resource acquisition request is sent to the local service container by utilizing a container process of the HTML container, and then the local service container is used for inquiring local resources, so that the HTML container and the local service container can be directly used for acquiring the local resources, HTTP service is not required to be used in the whole process, and further, the HTTP service is not required to be started by equipment where an application program is located, the HTML program can be finally ensured to get rid of the constraint of the HTTP service, and the application in the local program can be better realized.
Based on the above embodiment, since the interaction between the HTML program and the local service in the related art is limited by the HTTP service, and the working mode of the HTTP service is simplex communication, the communication between the HTML program and the local service can only be initiated by the HTML program, and the local service returns the local resource content of the response according to the request content, and can not realize the call of the local service to the HTML program, so the HTTP service prevents the bidirectional call between the HTML program and the local resource. In view of this, the present invention also provides another data interaction method, which can use the HTML container and the local service container to provide a way to call the HTML program for the local service. To solve the above-mentioned problem, please refer to fig. 2, in a possible case, fig. 2 is a flowchart of another data interaction method according to an embodiment of the present invention, which may include:
S201, the local service container generates an HTML call request and sends the HTML call request to the HTML container.
It should be noted that, the HTML call request in the embodiment of the present invention is used to provide call information for the HTML container, so that the HTML container queries specific call service information according to the call information, and executes a call operation on the HTML program according to the call service information. The embodiment of the invention is not limited to the specific content and form of the HTML call request, the request is related to the service function provided by the HTML program and the service interface form corresponding to the service function, and the user can set the specific HTML call request according to the actual application requirement.
S202, the HTML container receives an HTML call request and inquires corresponding call service information in the service interface according to the HTML call request.
In the embodiment of the invention, the calling task of the HTML program is completed by the HTML container. The HTML container inquires corresponding calling service information in the service interface according to the received HTML calling request; when the HTML container inquires the calling service information, the service information is utilized to complete the calling operation of the HTML program, so that the local resource can be ensured to call the HTML program, and the problem of bidirectional calling between the HTML program and the local resource is finally solved.
It should be noted that, the embodiment of the present invention is not limited to the object for receiving the HTML call request in the HTML container, and the object may be a completely self-developed container process dedicated to receiving the HTML call request, or may be a container process secondarily developed based on a process provided by the development framework. Because the process provided by the development framework has higher fusion with the development framework, and the development period can be saved, in the embodiment of the invention, the object receiving the HTML call request can be a container process for secondary development based on the process provided by the development framework. It should be noted that, the embodiment of the present invention is not limited to the development framework process specifically used in this step, and the user may refer to the related technology according to the development framework specifically selected. In one possible case, the Browser process in the CEF framework may be used for secondary development to achieve the functional effect of receiving the HTML call request, that is, the Browser process in the HTML container receives the HTML call request, and the Browser process queries corresponding call service information in the service interface according to the HTML call request.
Further, the embodiment of the invention is not limited to whether the service interface is a universal service interface or a service registration interface based on secondary development of the universal service interface, wherein the universal service interface comprises all service functions which can be called by the HTML container, and the service registration interface comprises all service functions which can be called by the local service container. When the HTML container has fewer service functions available for calling, the service interface can be a general service interface without distinguishing the service functions available for calling by the HTML program from the functions available for calling by the local service container; the service interface may also be a service registration interface when it is desired to differentiate the two service functions. Considering that the HTML container can provide more service functions, for convenience of management, in the embodiment of the present invention, the service interface may be a service registration interface. When the service interface is a service registration interface, the HTML program is required to call the service registration interface in order to ensure that the HTML program can receive call information from the local service container; meanwhile, in order to enable the HTML program to generate response information according to the calling condition in the calling process of the local service container to the HTML program, the event registration interface can be obtained through secondary development based on the general service interface in the HTML container, and when the HTML program calls the event registration interface, the HTML program can respond to various events in a calling link to generate the response information.
Finally, it should be noted that the embodiment of the present invention does not limit the development modes of the service registration interface and the generic service interface, and the limited description of the development modes is identical to the limited description of the development modes of the service interface in step S101, which is not repeated here.
In one possible scenario, the process of the HTML container receiving the HTML call request and querying the service interface for the corresponding call service information according to the HTML call request may include:
step 31: the Browser process of the HTML container receives an HTML call request;
step 32: and the Browser process inquires calling service information corresponding to the HTML calling request in a service interface provided by the Render process through an inter-process communication interface provided by the HTML container.
S203, when the HTML container inquires the corresponding calling service information, calling operation is carried out on the HTML program by using the calling service information.
It should be noted that, the embodiment of the present invention is not limited to specific call service information, and the user may write and develop according to the actual application requirement.
Based on the above embodiment, the local service container in the method can send the HTML call request to the HTML container, then the HTML container inquires the corresponding call service information according to the request, and finally the HTML program is called according to the call service information, so that the call function of the local service to the HTML program can be realized.
Based on the above embodiments, the manner in which data communication between the HTML container and the local service container is established will be described below. In one possible scenario, before the HTML program generates the local resource acquisition request using the service interface provided by the HTML container, the method further comprises:
s301, the initiator generates an identifier and sends the identifier to the HTML container and the local service container.
It should be noted that the identifier is a unique identifier for inter-process communication, and the function of the initiator may first generate an identifier and send the identifier to the HTML container and the local service container, so that the two containers establish data communication according to the identifier. It should be noted that, the embodiments of the present invention are not limited to the specific form and the generation method of the identifier, and the user may refer to the related technology of the inter-process communication. The embodiment of the invention also does not limit the time for transmitting the identifier by the initiator, for example, the identifier can be transmitted after the initiator determines that the HTML container and the local service container are both started, the identifier can be stored into the starting parameter, the starting parameter is transmitted to the HTML container and the local service container respectively, the containers are started after receiving the starting parameter, and the data communication between the containers is established according to the identifier in the starting parameter. In order to improve the efficiency of establishing data communication between the HTML container and the local service container, in the embodiment of the present invention, the initiator may save the identifier to the initiation parameter, so that after the container receives the initiation parameter and initiates the initiation, the initiator establishes data communication according to the identifier in the initiation parameter.
Further, in the embodiment of the present invention, the limitation description of the data communication manner between the HTML container and the local service container is consistent with the limitation description in step S101, and will not be repeated here. In one possible scenario, the data communication between the HTML container and the native service container may be a named pipe. It should be noted that, the embodiment of the present invention is not limited to a specific process of establishing a naming pipe between an HTML container and a local service container by using an identifier, and a user may refer to a related technology of naming pipe establishment.
S302, the local service container receives the identifier and creates a communication service end by using the identifier.
S303, the HTML container receives the identifier, and searches and connects the corresponding communication server according to the identifier.
Finally, in order to ensure that the initiator can effectively start the HTML container and the local service container, the initiator, the HTML container, and the local service container need to be provided in the same device. Based on the embodiment, the method can automatically establish the data communication between the HTML container and the local service container by using the starter, does not need manual operation, and can improve the communication establishment efficiency between the HTML container and the local service container.
Based on the above embodiment, since the acquisition and access of the local resource by the HTML program depend on the HTML container and the local service container, in order to ensure that the HTML container and the local service container are online at the same time, the host processes of the two containers need to be daemon. The following describes the daemon process of the container main process, and in one possible case, after searching and connecting the corresponding communication service end according to the identifier, the method may further include:
S401, the initiator sends first information to a first process handle corresponding to the HTML container, and sends second information to a second process handle corresponding to the local service container.
It should be noted that, the first process handle is a process handle of the HTML container main process, and the second process handle is a process handle of the local service container main process. The detection of the process handle can effectively judge whether the two containers are online. In the embodiment of the invention, the detection mode of the process handle is that information is sent to the process handle and receipt information returned by the handle is received. When receipt information returned by the handle can be received, the container can be determined to be online, and otherwise, the container can be determined to be offline. It should be noted that, the embodiment of the present invention is not limited to the specific form of the first information and the second information, and the user may refer to the related technology of sending information to the process.
Further, in the embodiment of the invention, the initiator also has a function of guarding the container main process. It should be noted that, in the embodiment of the present invention, the timing of sending information to the process handle by the initiator is not limited, for example, the initiator may send information to the process handle when the HTML container sends the local resource acquisition request, or may send information to the process handle periodically. In order to effectively ensure that two containers are online at the same time, in an embodiment of the present invention, the initiator may periodically send information to the process handle. The embodiment of the invention is not limited to specific period values, and a user can determine according to actual application requirements.
S402, if the initiator receives the first receipt information returned by the first process handle and does not receive the second receipt information returned by the second process handle, restarting the local service container.
It should be noted that, the embodiment of the present invention is not limited to the specific form and content of the first receipt information and the second receipt information, and the user may refer to the related technology of the process receipt information.
It will be appreciated that when the initiator receives the first receipt information but does not receive the second receipt information, it may be determined that the local service container is offline, at which time a restart of the local service container is required to ensure that the HTML program properly obtains the local resources.
It should be noted that, the embodiment of the present invention does not limit whether the initiator needs to receive the receipt information within a preset time period after sending the information, and determines that the container is online, and when the thread handle of the main thread of the container can quickly reply to the receipt information, the initiator does not need to execute the determination of the container online within the preset time period; when the container main thread is possibly blocked and further cannot quickly reply to the receipt information, and the HTML program cannot efficiently acquire the local resources, the starter can also execute the online judgment of the container in a preset time period. In order to improve the judging efficiency and ensure that the HTML program can efficiently acquire the local resource, the initiator may be required to judge whether the container is online within a preset time period, that is, the initiator needs to receive receipt information within the preset time period after sending the information, so as to judge that the container is online. The embodiment of the invention is not limited to specific numerical values of the preset time period, and a user can set the numerical values according to actual application requirements.
S403, if the starter does not receive the first receipt information returned by the first process handle, closing the local service container.
It will be appreciated that when the initiator does not receive the first receipt information, it may be determined that the HTML container is offline. Since the HTML program is located in the HTML container, the HTML program also exits when the HTML container is offline, so the local service container can be closed to save device operating resources.
Finally, it should be noted that, considering that the initiator in the embodiment of the present invention also needs to detect the process handles of the HTML container and the local service container, the initiator, the HTML container and the local service container need to be set in the same device at this time, so that the initiator can be ensured to effectively detect the process handles.
Based on the above embodiment, the initiator in the method can also daemon the main processes of the HTML container and the local service container, so as to ensure that the HTML container and the local service container are online at the same time, and further ensure that the HTML program can interact with the local resource with high efficiency.
The following describes a data interaction system, an electronic device, and a storage medium provided by the embodiments of the present invention, where the data interaction system, the electronic device, and the storage medium described below may be referred to correspondingly with the data interaction method described above.
Referring to fig. 3a, fig. 3a is a block diagram illustrating a data interaction system according to an embodiment of the present invention, where the system may include an HTML program 310, an HTML container 320, and a local service container 330.
Referring to fig. 3b, fig. 3b is a block diagram of an HTML program according to an embodiment of the present invention, and the HTML program 310 includes:
A first request sending module 311, configured to generate a local resource obtaining request by using a service interface provided by the HTML container 320, and send the local resource obtaining request to the local service container 330 through a container process of the HTML container 320;
A first local resource receiving module 312, configured to receive local resource data sent by the HTML container 320;
referring to fig. 3c, fig. 3c is a block diagram of an HTML container according to an embodiment of the present invention, where the HTML container 320 may include:
A container process module 321, configured to send a local resource acquisition request of the HTML program 301 to the local service container 303;
the second local resource receiving module 322 is configured to receive the local resource data and send the local resource data to the HTML program.
Referring to fig. 3d, fig. 3d is a block diagram of a local service container according to an embodiment of the present invention, where the local service container 330 may include:
The local resource obtaining module 331 is configured to process the received local resource obtaining request by using the service included in the local service container 330 to obtain corresponding local resource data, and send the local resource data to the HTML container 320;
Alternatively, the first request transmitting module 311 may include:
a request generation sub-module, configured to generate a local resource acquisition request using a service interface provided by the HTML container 320;
A request sending sub-module, configured to send a local resource acquisition request to a Render process of the HTML container 320;
The container process module 321 may include:
The first Render process module is used for generating and storing first context information of the local resource acquisition request, and sending the local resource acquisition request to the Browser process through an inter-process interface provided by the HTML container;
And the first Browser process module is used for generating and storing the second context information of the local resource acquisition request and sending the local resource acquisition request to the local service container.
Optionally, the local resource acquisition module 331 may include:
The second Browser process module is used for receiving the local resource data and sending the local resource data to the Render process according to the second context information;
and the second Render process module is used for receiving the local resource data and sending the local resource data to the HTML program according to the first context information.
Optionally, referring to fig. 3e, fig. 3e is a block diagram illustrating another data interaction system according to an embodiment of the present invention, where the system may further include an initiator 340;
referring to fig. 3f, fig. 3f is a block diagram of an initiator according to an embodiment of the present invention, wherein the initiator 340 may include:
An identifier sending module 341, configured to generate an identifier, and send the identifier to the HTML container and the local service container;
HTML container 320 may also include:
The first data communication establishing module is used for receiving the identifier and searching and connecting the corresponding communication server according to the identifier;
The local service container 330 may further include:
The second data communication establishing module is used for receiving the identifier and creating a communication server by using the identifier;
Optionally, the initiator may further include:
the information sending module is configured to send first information to a first process handle corresponding to the HTML container 320, and send second information to a second process handle corresponding to the local service container 330;
The first processing module is used for restarting the local service container when the starter receives the first receipt information returned by the first process handle and does not receive the second receipt information returned by the second process handle;
And the second processing module is used for closing the local service container when the initiator does not receive the first receipt information returned by the first process handle.
Optionally, the local service container 330 may further include:
A second request sending module, configured to generate an HTML call request, and send the HTML call request to the HTML container 320;
HTML container 320 may also include:
The request receiving module is used for receiving the HTML call request and inquiring corresponding call service information in the service interface according to the HTML call request;
And the calling module is used for calling the HTML program by using the calling service information when the corresponding calling service information is queried.
Optionally, the request receiving module may include:
The third Browser process module is used for receiving an HTML call request;
And a fourth Browser process module, configured to query, through an inter-process communication interface provided by the HTML container 320, call service information corresponding to the HTML call request in a service interface provided by the Render process.
The embodiment of the invention also provides electronic equipment, which comprises:
a memory for storing a computer program;
and a processor for implementing the steps of the data interaction method as described above when executing the computer program.
Since the embodiments of the electronic device portion and the embodiments of the data interaction method portion correspond to each other, the embodiments of the electronic device portion refer to the description of the embodiments of the data interaction method portion, which is not repeated herein.
The embodiment of the invention also provides a storage medium, and a computer program is stored on the storage medium, and when the computer program is executed by a processor, the steps of the data interaction method of any embodiment are realized.
Since the embodiments of the storage medium portion and the embodiments of the data interaction method portion correspond to each other, the embodiments of the storage medium portion are referred to for description of the embodiments of the data interaction method portion, and are not repeated herein.
In the description, each embodiment is described in a progressive manner, and each embodiment is mainly described by the differences from other embodiments, so that the same similar parts among the embodiments are mutually referred. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The data interaction method, the system, the electronic equipment and the storage medium provided by the invention are described in detail. The principles and embodiments of the present invention have been described herein with reference to specific examples, the description of which is intended only to facilitate an understanding of the method of the present invention and its core ideas. It should be noted that it will be apparent to those skilled in the art that various modifications and adaptations of the invention can be made without departing from the principles of the invention and these modifications and adaptations are intended to be within the scope of the invention as defined in the following claims.

Claims (9)

1. A method of data interaction, comprising:
The method comprises the steps that an HTML program generates a local resource acquisition request by utilizing a service interface provided by an HTML container, and sends the local resource acquisition request to a local service container through a container process of the HTML container;
The local service container processes the received local resource acquisition request by utilizing the business service contained in the local service container to obtain corresponding local resource data, and sends the local resource data to the HTML container;
the HTML container receives the local resource data and sends the local resource data to the HTML program;
The local service container generates an HTML call request and sends the HTML call request to the HTML container;
The HTML container receives the HTML call request by utilizing the container process, and inquires corresponding call service information in a service registration interface according to the HTML call request; wherein, the service registration interface comprises all service functions which can be called by a local service container, and the HTML program calls the service registration interface;
When the HTML container inquires the corresponding calling service information, calling operation is carried out on the HTML program by utilizing the calling service information;
And the HTML program generates response information for the event in the calling link by using an event registration interface provided by the HTML container, and sends the response information to the local service container through a container process of the HTML container.
2. The data interaction method according to claim 1, wherein the sending the local resource acquisition request to a local service container by a container process of the HTML container includes:
the HTML program sends the local resource acquisition request to a Render process of the HTML container;
The Render process generates and saves the first context information of the local resource acquisition request, and sends the local resource acquisition request to a Browser process of the HTML container through an inter-process interface provided by the HTML container;
The Browser process generates and stores second context information of the local resource acquisition request, and sends the local resource acquisition request to the local service container.
3. The data interaction method according to claim 2, wherein the HTML container receives the local resource data and transmits the local resource data to the HTML program, comprising:
The Browser process receives the local resource data and sends the local resource data to the Render process according to the second context information;
and the Render process receives the local resource data and sends the local resource data to the HTML program according to the first context information.
4. The data interaction method of claim 1, further comprising, before the HTML program generates the local resource acquisition request using a service interface provided by the HTML container:
the initiator generates an identifier and sends the identifier to the HTML container and the local service container;
The local service container receives the identifier and creates a communication service end by using the identifier;
and the HTML container receives the identifier, and searches and connects with the corresponding communication server according to the identifier.
5. The data interaction method according to claim 4, further comprising, after searching for and connecting to a corresponding communication server according to the identifier:
the initiator sends first information to a first process handle corresponding to the HTML container and sends second information to a second process handle corresponding to the local service container;
If the initiator receives the first receipt information returned by the first process handle and does not receive the second receipt information returned by the second process handle, restarting the local service container;
And if the initiator does not receive the first receipt information returned by the first process handle, closing the local service container.
6. The data interaction method according to claim 1, wherein the HTML container receives the HTML call request by using the container process, and queries a service registration interface for corresponding call service information according to the HTML call request, including:
the Browser process of the HTML container receives the HTML call request;
And the Browser process inquires calling service information corresponding to the HTML calling request in a service registration interface provided by a Render process through an inter-process communication interface provided by the HTML container.
7. A data interaction system comprising means for performing a data interaction method as claimed in any one of claims 1 to 6.
8. An electronic device, comprising:
a memory for storing a computer program;
a processor for implementing the data interaction method according to any of claims 1 to 6 when executing said computer program.
9. A storage medium having stored therein computer executable instructions which when loaded and executed by a processor implement the data interaction method of any one of claims 1 to 6.
CN202110307703.9A 2021-03-23 Data interaction method, system, electronic equipment and storage medium Active CN113010237B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110307703.9A CN113010237B (en) 2021-03-23 Data interaction method, system, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110307703.9A CN113010237B (en) 2021-03-23 Data interaction method, system, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113010237A CN113010237A (en) 2021-06-22
CN113010237B true CN113010237B (en) 2024-07-09

Family

ID=

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103927151A (en) * 2013-01-11 2014-07-16 联想(北京)有限公司 Method and device for implementing local operation on web page

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103927151A (en) * 2013-01-11 2014-07-16 联想(北京)有限公司 Method and device for implementing local operation on web page

Similar Documents

Publication Publication Date Title
EP2622484B1 (en) Debugger launch and attach on compute clusters
CN107203419B (en) Method, device and system for calling among modules in application program
CN109067890B (en) CDN node edge computing system based on docker container
US7784059B2 (en) Stateless asynchronous message transmission
US8848893B2 (en) Method and apparatus for callback processing in telecommunication capability opening
CN111258565B (en) Method, system, server and storage medium for generating applet
CN111143207B (en) Method for checking model training notice and training log at mobile terminal
US20110067007A1 (en) Automatic thread dumping
US8694956B2 (en) PowerShell cmdlets code generating tool for communicating to the web services
CN102567400B (en) Method for realizing Web visit and Web server
TW201413584A (en) Method and system for automatic detecting and resolving APIs
CN114880159B (en) Data processing method, device, equipment and storage medium
US8935402B2 (en) Resource launch from application within application container
CN110795141A (en) Training task submitting method, device, equipment and medium
US10025646B2 (en) Naming of nodes in NET framework
CN113010237B (en) Data interaction method, system, electronic equipment and storage medium
CN109739665A (en) Interface managerial method, device, server and storage medium
CN108228880B (en) Method, device, equipment and medium for database management system to call external function
CN113795001B (en) Method and device for sending system short message based on SPI
CN113010237A (en) Data interaction method, system, electronic equipment and storage medium
CN114297062A (en) Service testing method and device, electronic equipment and storage medium
CN112558950A (en) System interface generation method and device
CN114860468A (en) SDK calling method and device, computer equipment and storage medium
CN109871288B (en) Method, device, equipment and medium for executing Android system command
US8296780B2 (en) Reducing persistence commands

Legal Events

Date Code Title Description
PB01 Publication
SE01 Entry into force of request for substantive examination
GR01 Patent grant