CN112925527B - Calling method, calling device, storage medium and electronic equipment - Google Patents

Calling method, calling device, storage medium and electronic equipment Download PDF

Info

Publication number
CN112925527B
CN112925527B CN202110168077.XA CN202110168077A CN112925527B CN 112925527 B CN112925527 B CN 112925527B CN 202110168077 A CN202110168077 A CN 202110168077A CN 112925527 B CN112925527 B CN 112925527B
Authority
CN
China
Prior art keywords
bridge
code
web
native
identifier
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
CN202110168077.XA
Other languages
Chinese (zh)
Other versions
CN112925527A (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.)
Beijing Sankuai Online Technology Co Ltd
Original Assignee
Beijing Sankuai Online Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Sankuai Online Technology Co Ltd filed Critical Beijing Sankuai Online Technology Co Ltd
Priority to CN202110168077.XA priority Critical patent/CN112925527B/en
Publication of CN112925527A publication Critical patent/CN112925527A/en
Application granted granted Critical
Publication of CN112925527B publication Critical patent/CN112925527B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/51Source to source
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural

Abstract

The embodiment of the specification adds a callback method containing a callback RN bridge into web codes when the RN codes are converted into the web codes, enables a native communication thread to acquire and call the RN bridge called by the callback method through communication between the web communication thread and the native communication thread when the callback method contained in the web codes is executed, so as to obtain an execution result of the RN bridge, and then returns the execution result to the web communication thread, and the web communication thread takes the execution result as the execution result of the callback method. By the method, even if the web bridge is not created, the native code packaged by the RN bridge can be called through the communication among the threads, and the execution result is obtained, so that the manpower consumed by creating the web bridge is saved, and the code development efficiency is improved.

Description

Calling method, calling device, storage medium and electronic equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a calling method, a calling apparatus, a storage medium, and an electronic device.
Background
Currently, the fact-Native technology (hereinafter referred to as RN) is increasingly adopted as a preferred technical solution as a cross-platform and dynamic technical framework widely adopted by a mobile terminal.
Although RN code can be directly run in various system environments such as Android, iOS and the like, RN code cannot be directly run in a web container, and therefore, in practical applications, it is necessary to convert RN code into web code such as hypertext Markup Language 5 (H5) code and then run the converted web code in the web container.
However, for RN code, the RN code itself often needs to call many Native codes of the mobile end (i.e. Native-side method), but the RN code and the Native code of the mobile end do not usually belong to the same technology stack, so that it needs to implement the call of the RN code to the Native code through the RN bridge, as shown in fig. 1.
In fig. 1, the RN code calls the native code corresponding to the RN bridge a through the RN bridge a, and calls the native code corresponding to the RN bridge B through the RN bridge B. That is, the RN bridge is used to encapsulate the native code of the mobile terminal into an object that the RN code can directly call, so as to be called by the RN code. It should be noted that, with one RN bridge, the RN code can only call the native code encapsulated by the RN bridge (i.e. the native code corresponding to the RN bridge), but cannot call the native code not encapsulated by the RN bridge.
However, when the RN code is converted into the web code, the RN bridge cannot be correspondingly converted into the web bridge, and only the corresponding web bridge (similar to the RN bridge in function, for enabling the web code to directly call the corresponding native code) is manually created according to the converted web code and the RN bridge, as shown in fig. 1.
In fig. 1, although RN code can be directly converted into web code, RN bridge a and RN bridge B cannot be directly converted into corresponding web bridges, and therefore, the converted web code cannot directly call native code, and only corresponding web bridge a (functionally equivalent to RN bridge a) and web bridge B (functionally equivalent to RN bridge B) can be created manually, which undoubtedly reduces code development efficiency and also increases code development cost.
Disclosure of Invention
Embodiments of the present specification provide a calling method, a calling apparatus, a storage medium, and an electronic device, so as to partially solve the problems in the prior art.
The embodiment of the specification adopts the following technical scheme:
the calling method provided by the specification comprises the following steps:
when a preset condition is met, determining an RN bridge corresponding to the RN code;
converting the RN code into a web code according to the identifier of the RN bridge; the web code obtained by conversion comprises a callback method for calling back the RN bridge;
when the callback method contained in the web code is executed, transmitting the identifier of the RN bridge to a preset native communication thread through a preset web communication thread;
searching and calling a pre-recorded RN bridge corresponding to the identifier of the RN bridge through the native communication thread to obtain an execution result of the searched RN bridge, and returning the execution result to the web communication thread;
and acquiring the execution result received by the web communication thread as a callback result of executing the callback method.
Optionally, the identifying of the RN bridge includes: a bridge identifier corresponding to the RN bridge and a code identifier corresponding to a native code to be called in each native code packaged by the RN bridge;
converting the RN code into a web code according to the identifier of the RN bridge, which specifically comprises the following steps:
and converting the RN code into a web code according to the bridge identifier corresponding to the RN bridge, the code identifier corresponding to the native code required to be called in each native code packaged by the RN bridge and the parameter required by the native code required to be called during execution.
Optionally, transmitting the identifier of the RN bridge to a preset native communication thread through a preset web communication thread, specifically including:
and generating a callback identifier corresponding to the callback method based on the bridge identifier, the code identifier and the parameter through a preset web communication thread, generating a Uniform Resource Locator (URL) containing the bridge identifier, the code identifier, the parameter and the callback identifier, and transmitting the URL to a preset native communication thread.
Optionally, transmitting the URL to a preset native communication thread specifically includes:
and loading the URL through a preset web communication thread so as to transmit the URL to a preset native communication thread.
Optionally, searching and calling a pre-recorded RN bridge corresponding to the identifier of the RN bridge through the native communication thread, specifically including:
analyzing the URL through the native communication thread to obtain the bridge identifier, the code identifier, the parameter and the callback identifier contained in the URL;
according to the obtained bridge identification, searching an RN bridge corresponding to the bridge identification in each prerecorded RN bridge;
and searching the native code corresponding to the code identifier in all the found native codes packaged by the RN bridge according to the obtained code identifier.
Optionally, obtaining the execution result of the found RN bridge specifically includes:
executing the searched native code through the native communication thread based on the parameter to obtain an execution result of the searched native code.
Optionally, returning the execution result to the web communication thread specifically includes:
generating a JS code based on the execution result and the callback identification through the native communication thread, wherein the loading result of the JS code is the execution result and the callback identification;
and loading the JS codes by adopting a web container so that the web communication thread acquires the loading result of the JS codes.
Optionally, the obtaining the execution result received by the web communication thread as a callback result of executing the callback method specifically includes:
and determining a callback method corresponding to the callback identifier contained in the loading result through the web communication thread, and taking the execution result contained in the loading result as the callback result of the determined callback method.
This specification provides a calling device, includes:
the determining module is used for determining the RN bridge corresponding to the RN code when the preset condition is met;
the conversion module is used for converting the RN code into a web code according to the identifier of the RN bridge; the web code obtained by conversion comprises a callback method for calling back the RN bridge;
the identification transmission module is used for transmitting the identification of the RN bridge to a preset native communication thread through a preset web communication thread when the callback method contained in the web code is executed;
the result transmission module is used for searching and calling the pre-recorded RN bridge corresponding to the identifier of the RN bridge through the native communication thread so as to obtain the execution result of the searched RN bridge, and returning the execution result to the web communication thread;
and the callback module is used for acquiring the execution result received by the web communication thread as a callback result for executing the callback method.
The present specification provides a computer-readable storage medium storing a computer program which, when executed by a processor, implements the above-described calling method.
The present specification provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the processor implements the above-mentioned calling method.
The embodiment of the specification adopts at least one technical scheme which can achieve the following beneficial effects:
when the RN code is converted into the web code, the callback method containing the callback RN bridge is added into the web code, when the callback method contained in the web code is executed, the native communication thread acquires the RN bridge called by the callback method and calls the RN bridge through communication between the web communication thread and the native communication thread so as to obtain an execution result of the RN bridge, and then the execution result is returned to the web communication thread, and the web communication thread takes the execution result as the execution result of the callback method. By the method, even if the web bridge is not created, the native code packaged by the RN bridge can be called through the communication among the threads, and the execution result is obtained, so that the manpower consumed by creating the web bridge is saved, and the code development efficiency is improved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the specification and are incorporated in and constitute a part of this specification, illustrate embodiments of the specification and together with the description serve to explain the specification and not to limit the specification in a non-limiting sense. In the drawings:
fig. 1 is a diagram illustrating a method for calling an RN bridge in the prior art;
FIG. 2 is a diagram illustrating a calling method provided in an embodiment of the present specification;
FIG. 3 is a diagram illustrating inter-thread communication and a process for obtaining callback results according to an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of a calling device provided in an embodiment of the present specification;
fig. 5 is a schematic structural diagram of an electronic device provided in an embodiment of this specification.
Detailed Description
Whatever the code, certain environments are needed for support during running, for example, RN code needs to run in the RN environment, web code needs to run in the web environment (i.e. web container), and native code needs to run in the native environment. The RN bridge described in this specification actually encapsulates native code that should be run in a native environment into code that can be run in an RN environment, so that the RN code can directly call the RN bridge, that is, call the native code encapsulated by the RN bridge, and run in the RN environment.
Because the RN bridge cannot be directly converted into the web bridge when the RN code is converted into the web code in the prior art, the corresponding web bridge can only be created manually, but the method and the device aim to bypass the packaging of the bridge, enable the thread in the native environment to acquire the native code required to be called by the web code through the communication among the threads, directly execute the native code in the native environment to obtain an execution result, and transmit the execution result back to the web environment through the communication among the threads, thereby realizing the callback of the execution result of the native code by the web code. In this way, the web code may invoke the native code even if the web bridge is not created.
In order to make the objects, technical solutions and advantages of the present disclosure more clear, the technical solutions of the present disclosure will be clearly and completely described below with reference to the specific embodiments of the present disclosure and the accompanying drawings. It is to be understood that the embodiments described are only a few embodiments of the present disclosure, and not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present specification without any creative effort belong to the protection scope of the present specification.
The technical solutions provided by the embodiments of the present description are described in detail below with reference to the accompanying drawings.
Fig. 2 is a schematic diagram of a calling method provided in an embodiment of the present specification, including:
s200: and when the preset condition is met, determining the RN bridge corresponding to the RN code.
In the embodiment of the present specification, the client may convert the RN code into the web code and execute the calling method as shown in fig. 2 when the preset condition is satisfied.
Specifically, since the RN code generally needs to run a specified Software Development Kit (SDK) to provide environmental support, that is, a specified SDK needs to be included in a client running the RN code to be able to run, but not all clients necessarily contain the specified SDK, and even if a client contains the specified SDK, if the specified SDK is abnormal, the RN code is usually run differently. Therefore, the preset conditions may include: the client terminal running the RN code does not comprise the specified SDK, or the specified SDK contained in the client terminal running the RN code is abnormal.
That is, when the client does not include the specified SDK, or the specified SDK is abnormal, the client needs to convert the RN code into the web code to run, and implement the call of the web code to the native code in the manner shown in fig. 2.
It should be noted that, although the corresponding functions can be realized through the RN code and the converted web code, when the corresponding functions are realized by using the RN code, the user may have better use experience than the web code in terms of operation fluency, interface beauty and the like. And when the client does not comprise the specified SDK or the executed SDK is abnormal, although the corresponding function cannot be realized by running the RN code, the corresponding function can be realized by the web code at the expense of the user experience.
S202: and converting the RN code into a web code according to the identifier of the RN bridge.
In this embodiment, the identification of the RN bridge may include: a bridge identifier corresponding to the RN bridge, and a code identifier corresponding to a native code to be called in each native code encapsulated by the RN bridge.
When the RN code is converted into the web code, for a calling code of the RN bridge corresponding to the RN code in the web code, a callback method for calling back the RN bridge can be generated by utilizing the identifier of the RN bridge, and the callback method is adopted to replace the calling code. And for other codes in the web codes, the conversion can be directly carried out through a conversion method in the prior art.
Specifically, when the callback method for calling back the RN bridge is generated, the callback method may be generated according to a bridge identifier corresponding to the RN bridge, a code identifier corresponding to a native code to be called in each native code encapsulated by the RN bridge, and a parameter required when the native code to be called is executed.
Thus, the web code obtained by conversion includes a callback method for calling back the RN bridge.
S204: and when the callback method contained in the web code is executed, transmitting the identifier of the RN bridge to a preset native communication thread through a preset web communication thread.
Whatever the code, runtime needs to run through the created thread, which is created in the environment where the code is running. In the embodiment of the specification, the web communication thread is created in a web environment and is used for running web code. The native communication thread is created in the native environment to run native code.
It should be noted that although one thread can only be created in one environment, threads in different environments can communicate.
Embodiments of the present description make use of an inter-thread communication mechanism, and when a web communication thread executes a callback method included in web code, an identifier of an RN bridge included in the callback method is transmitted to a native communication thread.
S206: and searching and calling a pre-recorded RN bridge corresponding to the identifier of the RN bridge through the native communication thread to obtain an execution result of the searched RN bridge, and returning the execution result to the web communication thread.
In this embodiment of the present specification, all RN bridges and their corresponding identifiers may be recorded in advance, and when a native communication thread receives an identifier sent by a web communication thread, a native code encapsulated in the RN bridge corresponding to the received identifier may be searched and called in the above record, so as to obtain an execution result of the native code. The native communication thread then returns the execution results to the web communication thread, again using inter-thread communication mechanisms.
S208: and acquiring the execution result received by the web communication thread as a callback result of executing the callback method.
when the web communication thread receives the execution result of the native code encapsulated in the RN bridge, the execution result can be used as a callback result of a callback method contained in the web code, and the callback result is continued to continue executing subsequent web codes.
In this way, although the web code does not actually call the RN bridge nor the native code encapsulated in the RN bridge, the execution result of the native code encapsulated in the RN bridge is called back through the callback method, which is equivalent to directly calling the RN bridge (or directly calling the web bridge corresponding to the RN bridge) in effect, so that the execution result of the native code encapsulated by the RN bridge can be obtained through inter-thread communication even if the web bridge corresponding to the RN bridge is not created, thereby saving the manpower consumed by creating the web bridge, and improving the code development efficiency.
Further, the inter-thread communication and the process of obtaining the callback result in steps S204 to S208 shown in fig. 2 are shown in fig. 3.
In a web environment, when a web communication thread executes a callback method included in web code, since the callback method includes a bridge identifier corresponding to an RN bridge, a code identifier corresponding to a native code to be called in each native code encapsulated by the RN bridge, and a parameter required by the native code to be called when executed, the web communication thread may generate a callback identifier corresponding to the callback method based on the bridge identifier, the code identifier, and the parameter, generate a Uniform Resource Locator (URL) including the bridge identifier, the code identifier, the parameter, and the callback identifier, and transmit the URL to the native communication thread.
When the URL is transmitted to the native communication thread, the web communication thread may load the URL, and since the URL includes the code identifier of the native code to be called, after the URL is loaded, the native communication thread created in the native environment may parse the URL, so that the native communication thread acquires the bridge identifier, the code identifier, the parameter, and the callback identifier included in the URL.
In the native environment, the native communication thread may search, in each pre-recorded RN bridge, for an RN bridge corresponding to the bridge identifier included in the URL according to the obtained bridge identifier, and then search, in each found native code encapsulated by the RN bridge, for a native code corresponding to the code identifier included in the URL according to the obtained code identifier. And finally, the native communication thread executes the searched native code based on the parameters contained in the URL so as to obtain the execution result of the searched native code.
When the execution result is returned to the web communication thread, the native communication thread may generate a JS code whose loading result is the execution result and the callback identifier based on the execution result and the callback identifier included in the URL, and load the JS code using the web container. Since the JS code is loaded by using the web container, based on a communication mechanism between the web environment and the native environment, the web communication thread can acquire the loading result of the JS code, that is, the execution result and the callback identifier.
Returning to the web environment, after the web communication thread acquires the execution result and the callback identifier, the execution result can be used as the callback result of the callback method corresponding to the callback identifier, so that the callback method contained in the web code returns the execution result of the native code to be called.
Subsequently, the web communication thread may continue to execute subsequent web code based on the callback result of the callback method.
Based on the same idea, the present specification further provides a corresponding apparatus, a storage medium, and an electronic device.
Fig. 4 is a schematic structural diagram of an invoking device provided in an embodiment of the present specification, where the invoking device includes:
a determining module 401, configured to determine, when a preset condition is met, an RN bridge corresponding to an RN code;
a conversion module 402, configured to convert the RN code into a web code according to the identifier of the RN bridge; the web code obtained by conversion comprises a callback method for calling back the RN bridge;
an identifier transmission module 403, configured to transmit, through a preset web communication thread, an identifier of the RN bridge to a preset native communication thread when the callback method included in the web code is executed;
a result transmission module 404, configured to search and call a pre-recorded RN bridge corresponding to the RN bridge identifier through the native communication thread, to obtain an execution result of the found RN bridge, and return the execution result to the web communication thread;
a callback module 405, configured to obtain the execution result received by the web communication thread, as a callback result for executing the callback method.
Optionally, the identifying of the RN bridge includes: a bridge identifier corresponding to the RN bridge and a code identifier corresponding to a native code to be called in each native code packaged by the RN bridge;
the conversion module 402 is specifically configured to convert the RN code into a web code according to a bridge identifier corresponding to the RN bridge, a code identifier corresponding to a native code to be called in each native code encapsulated by the RN bridge, and a parameter required when the native code to be called is executed.
Optionally, the identifier transmitting module 403 is specifically configured to generate, by a preset web communication thread, a callback identifier corresponding to the callback method based on the bridge identifier, the code identifier, and the parameter, generate a uniform resource locator URL including the bridge identifier, the code identifier, the parameter, and the callback identifier, and transmit the URL to a preset native communication thread.
Optionally, the identifier transmitting module 403 is specifically configured to load the URL through a preset web communication thread, so as to transmit the URL to a preset native communication thread.
Optionally, the result transmission module 404 is specifically configured to parse the URL through the native communication thread to obtain the bridge identifier, the code identifier, the parameter, and the callback identifier included in the URL; according to the obtained bridge identification, searching an RN bridge corresponding to the bridge identification in each prerecorded RN bridge; and searching the native code corresponding to the code identifier in all the found native codes packaged by the RN bridge according to the obtained code identifier.
Optionally, the result transmission module 404 is specifically configured to execute, by the native communication thread, the found native code based on the parameter, so as to obtain an execution result of the found native code.
Optionally, the result transmission module 404 is specifically configured to generate, by the native communication thread, a JS code based on the execution result and the callback identifier, where a loading result of the JS code is the execution result and the callback identifier; and loading the JS codes by adopting a web container so that the web communication thread acquires the loading result of the JS codes.
Optionally, the callback module 405 is specifically configured to determine, through the web communication thread, a callback method corresponding to the callback identifier included in the loading result, and use the execution result included in the loading result as a callback result of the determined callback method.
The present specification also provides a computer readable storage medium storing a computer program which, when executed by a processor, is operable to perform the calling method provided in fig. 2 above.
Based on the calling method shown in fig. 2, an embodiment of the present specification further provides a schematic structural diagram of the electronic device shown in fig. 5. As shown in fig. 5, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, but may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs the computer program to implement the calling method described above with reference to fig. 2.
Of course, besides the software implementation, the present specification does not exclude other implementations, such as logic devices or a combination of software and hardware, and the like, that is, the execution subject of the following processing flow is not limited to each logic unit, and may be hardware or logic devices.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually making an Integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Hardware Description Language), traffic, pl (core universal Programming Language), HDCal (jhdware Description Language), lang, Lola, HDL, laspam, hardward Description Language (vhr Description Language), vhal (Hardware Description Language), and vhigh-Language, which are currently used in most common. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functions of the various elements may be implemented in the same one or more software and/or hardware implementations of the present description.
As will be appreciated by one skilled in the art, embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The description has been presented with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the description. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
This description may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only an example of the present specification, and is not intended to limit the present specification. Various modifications and alterations to this description will become apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification should be included in the scope of the claims of the present specification.

Claims (10)

1. A calling method, comprising:
when a preset condition is met, determining an RN bridge corresponding to the RN code;
converting the RN code into a web code according to the identifier of the RN bridge; the web code obtained by conversion comprises a callback method for calling back the RN bridge;
when the callback method contained in the web code is executed, transmitting the identifier of the RN bridge to a preset native communication thread through a preset web communication thread by using a communication mechanism among threads;
searching and calling a pre-recorded RN bridge corresponding to the identifier of the RN bridge through the native communication thread to obtain an execution result of the searched RN bridge, and returning the execution result to the web communication thread;
acquiring the execution result received by the web communication thread as a callback result of executing the callback method;
the identification of the RN bridge comprises: a bridge identifier corresponding to the RN bridge and a code identifier corresponding to a native code to be called in each native code packaged by the RN bridge;
converting the RN code into a web code according to the identifier of the RN bridge, which specifically comprises the following steps:
and converting the RN code into a web code according to the bridge identifier corresponding to the RN bridge, the code identifier corresponding to the native code required to be called in each native code packaged by the RN bridge and the parameter required by the native code required to be called during execution.
2. The method according to claim 1, wherein transmitting the identifier of the RN bridge to a preset native communication thread through a preset web communication thread specifically comprises:
and generating a callback identifier corresponding to the callback method based on the bridge identifier, the code identifier and the parameter through a preset web communication thread, generating a Uniform Resource Locator (URL) containing the bridge identifier, the code identifier, the parameter and the callback identifier, and transmitting the URL to a preset native communication thread.
3. The method of claim 2, wherein transmitting the URL to a predetermined native communication thread comprises:
and loading the URL through a preset web communication thread so as to transmit the URL to a preset native communication thread.
4. The method according to claim 2, wherein the finding and invoking of the pre-recorded RN bridge corresponding to the RN bridge identifier through the native communication thread specifically includes:
analyzing the URL through the native communication thread to obtain the bridge identifier, the code identifier, the parameter and the callback identifier contained in the URL;
according to the obtained bridge identification, searching an RN bridge corresponding to the bridge identification in each prerecorded RN bridge;
and searching the native code corresponding to the code identifier in all the found native codes packaged by the RN bridge according to the obtained code identifier.
5. The method according to claim 4, wherein obtaining the execution result of the found RN bridge specifically comprises:
executing the searched native code through the native communication thread based on the parameter to obtain an execution result of the searched native code.
6. The method of claim 4 or 5, wherein returning the execution result to the web communication thread specifically comprises:
generating a JS code based on the execution result and the callback identification through the native communication thread, wherein the loading result of the JS code is the execution result and the callback identification;
and loading the JS codes by adopting a web container so that the web communication thread acquires the loading result of the JS codes.
7. The method of claim 6, wherein obtaining the execution result received by the web communication thread as a callback result for executing the callback method specifically comprises:
and determining a callback method corresponding to the callback identifier contained in the loading result through the web communication thread, and taking the execution result contained in the loading result as the callback result of the determined callback method.
8. An invoking device, comprising:
the determining module is used for determining the RN bridge corresponding to the RN code when the preset condition is met;
the conversion module is used for converting the RN code into a web code according to the identifier of the RN bridge; the web code obtained by conversion comprises a callback method for calling back the RN bridge;
the identification transmission module is used for transmitting the identification of the RN bridge to a preset native communication thread through a preset web communication thread by utilizing a communication mechanism among threads when the callback method contained in the web code is executed;
the result transmission module is used for searching and calling the pre-recorded RN bridge corresponding to the identifier of the RN bridge through the native communication thread so as to obtain the execution result of the searched RN bridge, and returning the execution result to the web communication thread;
the callback module is used for acquiring the execution result received by the web communication thread as a callback result of executing the callback method;
the identification of the RN bridge comprises: a bridge identifier corresponding to the RN bridge and a code identifier corresponding to a native code to be called in each native code packaged by the RN bridge;
the conversion module is specifically configured to convert the RN code into a web code according to a bridge identifier corresponding to the RN bridge, a code identifier corresponding to a native code to be called in each native code encapsulated by the RN bridge, and a parameter required by the native code to be called when executed.
9. A computer-readable storage medium, characterized in that the storage medium stores a computer program which, when executed by a processor, implements the method of any of the preceding claims 1-7.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any of claims 1-7 when executing the program.
CN202110168077.XA 2021-02-07 2021-02-07 Calling method, calling device, storage medium and electronic equipment Active CN112925527B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110168077.XA CN112925527B (en) 2021-02-07 2021-02-07 Calling method, calling device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110168077.XA CN112925527B (en) 2021-02-07 2021-02-07 Calling method, calling device, storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN112925527A CN112925527A (en) 2021-06-08
CN112925527B true CN112925527B (en) 2022-03-08

Family

ID=76171034

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110168077.XA Active CN112925527B (en) 2021-02-07 2021-02-07 Calling method, calling device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN112925527B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1554060A (en) * 2001-07-12 2004-12-08 ��Ѷ�о����޹�˾ System and method for providing remote data access and transcoding for a mobile communication device
CN109240697A (en) * 2017-05-22 2019-01-18 腾讯科技(深圳)有限公司 Calling processing method and device, storage medium
CN111176626A (en) * 2019-08-05 2020-05-19 腾讯科技(深圳)有限公司 Cross-programming-language code calling method and device, medium and equipment
CN112100561A (en) * 2020-11-03 2020-12-18 南京研利科技有限公司 Method, electronic device and storage medium for calling local function by webpage

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8863152B2 (en) * 2009-07-13 2014-10-14 Hewlett-Packard Development Company, L.P. Communication bridge
US9390172B2 (en) * 2009-12-03 2016-07-12 Microsoft Technology Licensing, Llc Communication channel between web application and process outside browser
CN103399735A (en) * 2013-07-12 2013-11-20 浙江吉利汽车研究院有限公司杭州分公司 Method for developing intermediate layer of remote function call interface
US10678606B2 (en) * 2018-05-02 2020-06-09 Vmware, Inc. Peer-to-peer data communication between different applications

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1554060A (en) * 2001-07-12 2004-12-08 ��Ѷ�о����޹�˾ System and method for providing remote data access and transcoding for a mobile communication device
CN109240697A (en) * 2017-05-22 2019-01-18 腾讯科技(深圳)有限公司 Calling processing method and device, storage medium
CN111176626A (en) * 2019-08-05 2020-05-19 腾讯科技(深圳)有限公司 Cross-programming-language code calling method and device, medium and equipment
CN112100561A (en) * 2020-11-03 2020-12-18 南京研利科技有限公司 Method, electronic device and storage medium for calling local function by webpage

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
React Native转web方案:react-native-web;weixin_34397291;《CSDN https://blog.csdn.net/weixin_34397291/article/details/88031303》;20180819;第1-7页 *
WebView组件与HTML页面通信机制(React-Native);举世武双;《csdn https://blog.csdn.net/qq_33721382/article/details/89016568》;20190404;第1-5页 *

Also Published As

Publication number Publication date
CN112925527A (en) 2021-06-08

Similar Documents

Publication Publication Date Title
CN109002362B (en) Service method, device and system and electronic equipment
CN107092475B (en) Calling method and device of interactive control
CN107045438B (en) Application top view processing method, device and component
CN111835864B (en) Method and system for starting application
CN107786630B (en) Web application package processing method, device and equipment
CN108268289B (en) Parameter configuration method, device and system for web application
CN108595246B (en) Method, device and equipment for running application
CN107479868B (en) Interface loading method, device and equipment
CN109947643B (en) A/B test-based experimental scheme configuration method, device and equipment
CN107038058B (en) Code processing method and device
CN114547024A (en) SQL statement risk detection method, device, equipment and medium
CN112685030A (en) Method, device, storage medium and electronic equipment for generating service code
CN107391529B (en) Method and device for realizing Object Relation Mapping (ORM)
CN108170430B (en) Interface display method and system
CN112559934A (en) Page popup display method and device
CN110046052B (en) Service calling method and device
CN114546639A (en) Service call processing method and device
CN111459573B (en) Method and device for starting intelligent contract execution environment
CN110941443B (en) Method and device for modifying file name in SDK (software development kit) and electronic equipment
CN107301097B (en) Method and device for storing calling java object and reference address information of java object
CN112925527B (en) Calling method, calling device, storage medium and electronic equipment
CN113556260A (en) Flow monitoring method and device, storage medium and electronic equipment
CN111078435A (en) Service processing method and device and electronic equipment
CN108769152B (en) Service refresh policy registration method, service refresh request method, device and equipment
CN113672470A (en) Interface monitoring method, device, equipment and medium

Legal Events

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