CN112398870A - Cross-platform protocol generation method, device, system, equipment and storage medium - Google Patents

Cross-platform protocol generation method, device, system, equipment and storage medium Download PDF

Info

Publication number
CN112398870A
CN112398870A CN202011369974.9A CN202011369974A CN112398870A CN 112398870 A CN112398870 A CN 112398870A CN 202011369974 A CN202011369974 A CN 202011369974A CN 112398870 A CN112398870 A CN 112398870A
Authority
CN
China
Prior art keywords
cross
platform
service implementation
request information
service
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.)
Granted
Application number
CN202011369974.9A
Other languages
Chinese (zh)
Other versions
CN112398870B (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.)
Shenzhen Workec Technology Co ltd
Original Assignee
Shenzhen Workec 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 Shenzhen Workec Technology Co ltd filed Critical Shenzhen Workec Technology Co ltd
Priority to CN202011369974.9A priority Critical patent/CN112398870B/en
Publication of CN112398870A publication Critical patent/CN112398870A/en
Application granted granted Critical
Publication of CN112398870B publication Critical patent/CN112398870B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/03Protocol definition or specification 
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/26Special purpose or proprietary protocols or architectures

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computing Systems (AREA)
  • Telephonic Communication Services (AREA)
  • Communication Control (AREA)

Abstract

The invention is suitable for the technical field of communication, and provides a cross-platform protocol generation method, a device, a system, a terminal and a storage medium, wherein the protocol generation method comprises the steps of acquiring annotation information corresponding to request information, and calling a service implementation sending method to send the request information to a cross-platform when acquiring a corresponding service implementation sending method through the annotation information; and receiving a callback result after cross-platform logic processing, and then acquiring a corresponding service according to the callback result to realize a receiving method, thereby forming a one-to-one communication protocol between the request information sent by the mobile terminal and the callback after cross-platform logic processing. The invention does not need to define various cross-platform protocols, encapsulates the universal part of the cross-platform on the interface, dynamically obtains the universal part through the annotation form, unifies the communication modes of various cross-platform frames and the mobile terminal on the market, has concise and clear codes, is convenient for later service expansion and later service maintenance, and can realize seamless docking when the cross-platform is replaced.

Description

Cross-platform protocol generation method, device, system, equipment and storage medium
Technical Field
The invention belongs to the technical field of communication, and particularly relates to a cross-platform protocol generation method, a device, a system, equipment and a storage medium.
Background
At present, with the rapid development of the mobile internet, hidden dangers and extra burdens brought by application development aiming at different platforms of a mobile terminal become more and more difficult problems to be solved by mobile terminal developers. In recent years, cross-platform solutions such as PhoneGap/Cordova, Xanarin, React Native and the like are diversified, and more companies use the cross-platform solutions to improve development efficiency and reduce development and maintenance costs.
Currently, when the cross-platform development app is used, cross-platform languages (H5, ReactNative, Weex, Flutter) and Native communication protocols are various, and the definition protocol is too complex and not beneficial to later maintenance. Some of the prior art adopts manual definition protocol command words, parameters and return values; too many protocol command words over time can make finding a protocol cumbersome.
In addition, the method provided by the SDK is used for realizing cross-platform language and Native communication at present, if no middle layer is used for management, the cross-platform framework is replaced in the later period, the coupling is serious, the protocol SDK method is replaced together, and the workload is huge.
In order to solve the above problems, it is necessary to provide a method for generating a mobile-end cross-platform protocol.
Disclosure of Invention
The embodiment of the invention provides a cross-platform protocol generation method, a cross-platform protocol generation device, a cross-platform protocol generation system, cross-platform protocol generation equipment and a storage medium, and aims to solve the problems that when an APP is developed on the existing cross-platform, the definition protocol is too complex to be beneficial to later maintenance and the workload is large when the cross-platform is replaced in the later period.
The embodiment of the invention provides a cross-platform protocol generation method, which comprises the following steps:
obtaining annotation information corresponding to the request information;
judging whether a corresponding service realization sending method can be obtained in a predefined general interface according to the annotation information;
if so, calling the service implementation sending method to send the request information to a cross-platform;
receiving a logic processing result of the cross-platform callback aiming at the request information;
and acquiring a corresponding service according to the logic processing result to realize the receiving method, thereby forming a one-to-one communication protocol between the request information sending end and the cross-platform.
Furthermore, before the obtaining of the annotation information corresponding to the request information, a general interface is defined, and a control, a parameter, and a callback parameter of the general interface are defined.
Furthermore, after the defining of the generic interface, defining a service implementation class in the generic interface, and defining a service implementation method, a callback method and a definition annotation of the service implementation class; the service implementation method comprises a service implementation sending method and a service implementation receiving method.
Furthermore, the definition annotation comprises definition Hashmap, wherein the Hashmap comprises two parameters of K and V, K is a command word, and each request message corresponds to a unique command word; and V is a public interface class which comprises a control, a parameter and a callback method.
Further, the determining whether the corresponding service implementation sending method can be found in the predefined universal interface according to the annotation information further includes, when the determination result is negative, automatically initializing a service implementation class corresponding to the request information, and defining a service implementation method, a callback function, and a definition annotation corresponding to the service implementation class.
An embodiment of the present invention further provides a cross-platform protocol generation apparatus, where the apparatus includes:
the obtaining unit is used for obtaining annotation information corresponding to the request information;
the judging unit is used for judging whether a corresponding service realization sending method can be obtained in a predefined general interface according to the annotation information;
the calling unit is used for calling the service implementation sending method to send the request information to a cross-platform;
the receiving unit is used for receiving the logic processing result of the cross-platform callback;
and the processing unit is used for acquiring the corresponding service according to the logic processing result to realize the receiving method, so that a one-to-one communication protocol is formed between the request information sending end and the cross-platform.
Furthermore, the system further comprises an initialization unit, configured to initialize the service implementation class corresponding to the annotation information, and add the service implementation method, the callback function, and the definition annotation corresponding to the service implementation class, when the determination result is negative.
The embodiment of the invention also provides a cross-platform protocol generation system, which comprises,
the mobile terminal is used for acquiring annotation information corresponding to the request information; the method is used for judging whether a corresponding service realization sending method can be obtained in a predefined general interface according to the annotation information; the service realization sending method is used for calling the service realization sending method to send the request information to a cross-platform; the logic processing result is used for receiving the cross-platform callback; the method is used for acquiring a corresponding service according to a logic processing result to realize the receiving method, so that a one-to-one communication protocol is formed between the mobile terminal and the cross platform;
and the cross-platform is used for carrying out logic processing on the received request information and calling back a logic processing result to the mobile terminal by using a call-back method of the corresponding service implementation class.
The embodiment of the invention also provides terminal equipment, which comprises a memory, a storage and a processing unit, wherein the memory is used for storing the computer program; and the processor is used for realizing the steps of the cross-platform protocol generation method when executing the computer program.
An embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the steps of the cross-platform protocol generation method are implemented.
According to the method, annotation information corresponding to request information is obtained, and when a corresponding business implementation sending method is obtained through the annotation information, the business implementation sending method is called to send the request information to the cross-platform; and receiving the callback result after the cross-platform logic processing, and then acquiring a corresponding service according to the callback result to realize the receiving method, thereby forming a one-to-one communication protocol between the request information sending end and the cross-platform. The invention does not need to define various cross-platform protocols, encapsulates the universal part of the cross-platform on the interface, dynamically obtains the universal part through the annotation form, unifies the communication modes of various cross-platform frames and the mobile terminal on the market, has concise and clear codes, is convenient for later service expansion and later service maintenance, and can realize seamless docking when the cross-platform is replaced.
Drawings
Fig. 1 is a flowchart of a cross-platform protocol generation method according to an embodiment of the present invention;
fig. 2 is a flowchart of a cross-platform protocol generation method according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of a cross-platform protocol generation apparatus according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of a cross-platform protocol generation apparatus according to a fourth embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The invention provides a cross-platform protocol generation method, which comprises the steps of acquiring annotation information corresponding to request information, and calling a service implementation sending method to send the request information to a cross-platform when acquiring a corresponding service implementation sending method through the annotation information; and receiving a callback result after cross-platform logic processing, and then acquiring a corresponding service according to the callback result to realize a receiving method, thereby forming a one-to-one communication protocol between the request information sending end and the cross-platform. The invention does not need to define various cross-platform protocols, encapsulates the universal part of the cross-platform on the interface, dynamically obtains the universal part through the annotation form, unifies the communication modes of various cross-platform frames and the mobile terminal on the market, has concise and clear codes, is convenient for later service expansion and later service maintenance, and can realize seamless docking when the cross-platform is replaced.
Example one
Fig. 1 shows a cross-platform protocol generation method provided in an embodiment of the present invention, which includes the following steps:
step S101: and obtaining annotation information corresponding to the request information.
In the embodiment of the invention, the mobile terminal comprises an intelligent terminal, a tablet, an all-in-one machine, a split machine and the like, and the cross-platform protocol generation method is specifically applied to various APP programs of the mobile terminal.
In the embodiment of the invention, the annotation information is defined in a predefined general interface, and the cross-platform related general request information has corresponding annotation information.
The request information is various command information of the mobile terminal APP. For example, various service instruction information such as login, registration, drawing, and photographing.
Step S102: and judging whether the annotation information can acquire a corresponding service realization sending method in a predefined general interface.
In the embodiment of the present invention, before obtaining the annotation information corresponding to the request information, a general interface is defined, and a control, a parameter, and a callback of the general interface are defined at the mobile terminal, where the control, the parameter, and the callback are three parameters that are common across platforms.
Further, after the definition of the universal interface, defining a service implementation class on the universal interface, and defining a service implementation method, a callback method and a definition annotation in the service implementation class. The service implementation method comprises a service implementation sending method and a service implementation receiving method. That is, it refers to the sending and receiving method of each service, and different service instruction information corresponds to different service implementing methods, callback methods and definition annotations. The callback method is a method for calling back a result after cross-platform processing to a cross-platform.
Further, defining annotation includes defining Hashmap, where Hashmap is a map interface based on a hash table, and Hashmap includes two parameters, K is a command word and each request message corresponds to a unique command word; v is a public interface class which comprises controls, parameters and callback methods. In the embodiment of the present invention, the command word requesting information is the corresponding annotation information. There is a one-to-one mapping between command words and request information. In this embodiment, the corresponding service implementation class, the corresponding service implementation sending method, and the corresponding callback method are found by sending the command word of the request information by the mobile terminal APP.
In other embodiments, KV key values are defined by a LinkHashMap, which is a hash table and linked list implementation of a Map interface. In a further embodiment, the KV key value is defined by NSDirectional (dictionary class structure).
Step S103: and when the judgment result is yes, calling a service implementation sending method to send the request information to the cross-platform.
In the embodiment of the invention, when the corresponding service implementation sending method is acquired in the predefined general interface according to the annotation information, the service implementation sending method is called to send the request information to the cross-platform for processing, and the global mode is adopted at the moment.
Specifically, a service implementation class common across platforms is defined on a common interface. The service implementation class comprises various service implementation classes commonly used across platforms at present, and the service implementation class comprises a commonly used service implementation method, a callback method and a definition annotation. Each request message has corresponding annotation information, wherein the annotation information is a K value, namely a unique command word, and a service corresponding to the request message is found in a defined universal interface through the unique command word to realize the sending method. Therefore, the corresponding service implementation class can be found through the command word annotation corresponding to the request information, and the service sending method of the service implementation class is called to send the request information to the cross-platform.
If the corresponding service implementation class is not found in the defined generic interface, the protocol generation method ends. The service implementation class corresponding to the request information needs to be added and stored in the cache, so that the next call is facilitated.
Step S104: and receiving a logic processing result of the cross-platform callback aiming at the request information.
In the embodiment of the invention, after the cross-platform performs logic processing on the received request information, the logic processing result is called back to the mobile terminal APP according to the call-back method corresponding to the service implementation class, so that a one-to-one communication protocol is formed by the mobile terminal APP sending the request information and the call-back after the cross-platform is processed.
Step S105: and acquiring a corresponding service according to the logic processing result to realize the receiving method, thereby forming a one-to-one communication protocol between the request information sending end and the cross platform.
In this embodiment, the logic processing result is the corresponding V value, and V is a common interface class including a control, a parameter, and a callback method. The embodiment of the invention determines the service realization receiving method according to the control, the parameter and the callback method corresponding to the logic processing result.
In the embodiment of the invention, after the corresponding service implementation sending method is obtained through the annotation information, the service implementation sending method is called to transmit the request information to the cross-platform, and the request information is in a global mode at the moment, namely all the cross-platforms receive the request information. Specifically, the receiving cross-platform performs logic processing on the request information, then the logic processing result is called back to the mobile terminal by using a call-back method, and a corresponding service realization receiving method is obtained according to the called-back logic processing result, so that a one-to-one communication protocol is formed by sending command word annotation information at the mobile terminal and calling back after cross-platform processing.
Further, the cross-platform protocol generation method is defined in a middle layer class, and the middle layer does not contain any api of the third-party SDK and related keywords. The middle layer is responsible for converting the parameters called back from the cross-platform into the format of the method args of the mobile terminal and converting the parameters sent by the mobile terminal into data received by the cross-platform. Specifically, the method responsible for calling the cross-platform SDK is placed in a transition layer, and the middle layer is mainly isolated, so that the cross-platform implementation can be isolated, and the dependence on the cross-platform is avoided.
For example: the method comprises the steps that a mobile terminal APP sends a login system instruction, a service implementation class corresponding to the login system instruction is found according to a K value corresponding to the login system instruction, a corresponding service sending method exists in the service implementation class, the service sending method is called to send the login system instruction to a cross-platform, a logic processing result is generated after the cross-platform is subjected to logic processing, the logic processing result is called back to the mobile terminal APP through a call-back method in the service implementation class, the mobile terminal APP obtains a corresponding service receiving method according to a V value of the logic processing result, and therefore a one-to-one communication protocol is formed by sending command words through the mobile terminal APP and calling back after the cross-platform is processed.
For another example: and the mobile terminal APP sends a drawing instruction, acquires a corresponding service implementation class in a corresponding general interface according to a corresponding K value, and if the judgment result is negative, that is, if the drawing instruction does not have a corresponding service class, a definition class needs to be added to the drawing instruction, defines a service implementation method, a callback method and a definition annotation corresponding to the service implementation class, and stores the definition annotation in a cache so as to facilitate next calling.
The cross-platform protocol generation method of the embodiment acquires annotation information corresponding to request information, and calls a service implementation sending method to send the request information to a cross-platform when acquiring a corresponding service implementation sending method through the annotation information; and receiving a callback result after cross-platform logic processing, and then acquiring a corresponding service according to the callback result to realize a receiving method, thereby forming a one-to-one communication protocol between a request information sending end and cross-platform processing. According to the embodiment, various cross-platform protocols are not required to be defined, the cross-platform universal part is packaged on the interface and is dynamically acquired through the annotation form, various cross-platform frames on the market and the communication mode of the mobile terminal are unified, the codes are concise and clear, the later service expansion and the later service maintenance are facilitated, and seamless butt joint can be realized when the cross-platform is replaced.
Example two
Fig. 2 shows a cross-platform protocol generation method provided in the second embodiment of the present invention, steps S101 to S105 are the same as those in the first embodiment, which are not described again in this embodiment, and the cross-platform protocol generation method further includes,
in step S201: and when the judgment result is negative, automatically initializing the corresponding service implementation class, and defining a service implementation method, a callback function and a definition annotation corresponding to the service implementation class.
For example: the method comprises the steps that a mobile terminal APP sends a drawing information instruction, according to a K value corresponding to the drawing information instruction, a corresponding service implementation class is not found in a preset universal interface, the corresponding service implementation class is initialized automatically, the service implementation class corresponding to the drawing information is added to a database of the service implementation classes in the universal interface, a service implementation method, a call-back method and a definition annotation of the service implementation class are defined, and the service implementation method, the call-back method and the definition annotation are stored in a cache. When the instruction of the drawing information is clicked again next time, the service implementation class can be found in the general interface, and a one-to-one communication protocol is formed by sending command words and callback after cross-platform processing at the mobile terminal APP through an annotation method.
The cross-platform protocol generation method of the embodiment acquires annotation information corresponding to request information, and calls a service implementation sending method to send the request information to a cross-platform when acquiring a corresponding service implementation sending method through the annotation information; and receiving a callback result after cross-platform logic processing, and then acquiring a corresponding service according to the callback result to realize a receiving method, thereby forming a one-to-one communication protocol between the request information sending end and the cross-platform. According to the embodiment, a plurality of cross-platform protocols are not required to be defined, the cross-platform universal part is packaged on the interface and is dynamically acquired through the annotation form, a plurality of cross-platform frames on the market and the communication mode of the mobile terminal are unified, the codes are concise and clear, and seamless docking can be realized when the cross-platform is replaced. And when the corresponding service implementation class is not acquired through the annotation information, the service implementation class corresponding to the request information needs to be defined and stored in the cache for the next call, so that the later service expansion and the later service maintenance are facilitated.
EXAMPLE III
Fig. 3 shows a cross-platform protocol generation apparatus provided in the third embodiment of the present invention, where the protocol generation apparatus 300 includes:
the obtaining unit 310 is configured to obtain annotation information corresponding to the request information.
In the embodiment of the invention, the mobile terminal comprises an intelligent terminal, a tablet, an all-in-one machine, a split machine and the like, and the cross-platform protocol generation method is specifically applied to various APP programs of the mobile terminal.
In the embodiment of the invention, the annotation information is defined in a predefined general interface, and the cross-platform related general request information has corresponding annotation information.
The request information is various command information of the mobile terminal APP. For example, various service instruction information such as login, registration, drawing, and photographing.
The judging unit 320 is configured to judge whether a corresponding service implementation sending method can be obtained in a predefined general interface according to the annotation information.
In the embodiment of the invention, the annotation information is utilized to search the corresponding service implementation class in the predefined general interface, and the corresponding service implementation sending method is found in the corresponding service implementation class.
Further, in this embodiment of the present invention, the cross-platform protocol generating apparatus further includes a first defining unit, configured to define a general interface at the mobile terminal, define the general interface before obtaining the annotation information corresponding to the request information, define the general interface at the mobile terminal, and define a control, a parameter, and a callback of the general interface, where the control, the parameter, and the callback are three parameters that are common across platforms.
Further, the cross-platform protocol generation apparatus further includes a second definition unit, configured to define a service implementation class on the generic interface, and define a service implementation method, a callback method, and a definition annotation in the service implementation class. The service implementation method comprises a service implementation sending method and a service implementation receiving method. That is, it refers to the sending and receiving method of each service, and different service instruction information corresponds to different service implementing methods, callback methods and definition annotations. The callback method is a method for calling back a result after cross-platform processing to a cross-platform.
Further, defining annotation includes defining Hashmap, where Hashmap is a map interface based on a hash table, and Hashmap includes two parameters, K is a command word and each request message corresponds to a unique command word; v is a public interface class which comprises controls, parameters and callback methods. In the embodiment of the present invention, the command word requesting information is the corresponding annotation information. There is a one-to-one mapping communication protocol between command words and request information. In this embodiment, the corresponding service implementation class, the corresponding service implementation sending method, and the corresponding callback method are found by sending the command word of the request information by the mobile terminal APP.
In other embodiments, KV key values are defined by a LinkHashMap, which is a hash table and linked list implementation of a Map interface. In a further embodiment, the KV key value is defined by NSDirectional (dictionary class structure).
And the invoking unit 340 is configured to invoke the service implementation sending method to send the request information to the cross-platform.
In the embodiment of the invention, when the corresponding service implementation sending method is acquired in the predefined general interface according to the annotation information, the service implementation sending method is called to send the request information to the cross-platform for processing, and the global mode is adopted at the moment.
Specifically, a service implementation class common across platforms is defined on a common interface. The service implementation class comprises various service implementation classes commonly used across platforms at present, and the service implementation class comprises a commonly used service implementation method, a callback method and a definition annotation. Each request message has corresponding annotation information, wherein the annotation information is a K value, namely a unique command word, and a service corresponding to the request message is found in a defined universal interface through the unique command word to realize the sending method. Therefore, the corresponding service implementation class can be found through the command word annotation corresponding to the request information, and the service sending method of the service implementation class is called to send the request information to the cross-platform.
If the corresponding service implementation class is not found in the defined generic interface, the protocol generation method ends. The service implementation class corresponding to the request information needs to be added and stored in the cache, so that the next call is facilitated.
The receiving unit 350 is configured to receive a logic processing result of the cross-platform callback, so as to form a one-to-one communication protocol between the request information sending end and the cross-platform.
In the embodiment of the invention, after the cross-platform performs logic processing on the received request information, the logic processing result is called back to the mobile terminal APP according to the call-back method corresponding to the service implementation class, so that a one-to-one communication protocol is formed by the mobile terminal APP sending the request information and the call-back after the cross-platform is processed. And the processing unit is used for acquiring the corresponding service according to the logic processing result to realize the receiving method, so that a one-to-one communication protocol is formed between the sending request information and the call-back after the cross-platform processing.
In this embodiment, the logic processing result is the corresponding V value, and V is a common interface class including a control, a parameter, and a callback method. The embodiment of the invention determines the service realization receiving method according to the control, the parameter and the callback method corresponding to the logic processing result.
In the embodiment of the invention, after the corresponding service implementation sending method is obtained through the annotation information, the service implementation sending method is called to transmit the information to be requested to the cross-platform, and at the moment, the information to be requested is in a global mode, namely all cross-platforms receive the information to be requested. Specifically, the receiving cross-platform performs logic processing on the information to be requested, then the logic processing result is called back to the mobile terminal by using a call-back method, and a corresponding service realization receiving method is obtained according to the called-back logic processing result, so that a one-to-one communication protocol is formed by sending command word annotation information at the mobile terminal and calling back after cross-platform processing.
Further, the cross-platform protocol generation method is defined in a middle layer class, and the middle layer does not contain any api of the third-party SDK and related keywords. The middle layer is responsible for converting the parameters called back from the cross-platform into the format of the method args of the mobile terminal and converting the parameters sent by the mobile terminal into data received by the cross-platform. Specifically, the method responsible for calling the cross-platform SDK is placed in a transition layer, and the middle layer is mainly isolated, so that the cross-platform implementation can be isolated, and the dependence on the cross-platform is avoided.
For example: the method comprises the steps that a mobile terminal APP sends a login system instruction, a service implementation class corresponding to the login system instruction is found according to a K value corresponding to the login system instruction, a corresponding service sending method exists in the service implementation class, the service sending method is called to send the login system instruction to a cross-platform, a logic processing result is generated after the cross-platform is subjected to logic processing, the logic processing result is called back to the mobile terminal APP through a call-back method in the service implementation class, the mobile terminal APP obtains a corresponding service receiving method according to a V value of the logic processing result, and therefore a one-to-one communication protocol is formed by sending command words through the mobile terminal APP and calling back after the cross-platform is processed.
For another example: and the mobile terminal APP sends a drawing instruction, acquires a corresponding service implementation class in a corresponding general interface according to a corresponding K value, and if the judgment result is negative, that is, if the drawing instruction does not have a corresponding service class, a definition class needs to be added to the drawing instruction, defines a service implementation method, a callback method and a definition annotation corresponding to the service implementation class, and stores the definition annotation in a cache so as to facilitate next calling.
The cross-platform protocol generation device of the embodiment acquires annotation information corresponding to request information, and calls a service implementation sending method to send the request information to a cross-platform when acquiring a corresponding service implementation sending method through the annotation information; and receiving a callback result after cross-platform logic processing, and then acquiring a corresponding service according to the callback result to realize a receiving method, thereby forming a one-to-one communication protocol between the request information sending end and the cross-platform. According to the embodiment, various cross-platform protocols are not required to be defined, the cross-platform universal part is packaged on the interface and is dynamically acquired through the annotation form, various cross-platform frames on the market and the communication mode of the mobile terminal are unified, the codes are concise and clear, the later service expansion and the later service maintenance are facilitated, and seamless butt joint can be realized when the cross-platform is replaced.
Example four
Fig. 4 shows a cross-platform protocol generation apparatus provided in the fourth embodiment of the present invention, and on the basis of the third embodiment, the cross-platform protocol generation apparatus 400 of this embodiment further includes,
and an initializing unit 410, configured to, when the determination result is negative, automatically initialize the corresponding service implementation class, and add a service implementation method, a callback function, and a definition annotation corresponding to the service implementation class.
For example: the method comprises the steps that a mobile terminal APP sends a drawing information instruction, according to a K value corresponding to the drawing information instruction, a corresponding service implementation class is not found in a preset universal interface, the corresponding service implementation class is initialized automatically, the service implementation class corresponding to the drawing information is added to a database of the service implementation classes in the universal interface, a service implementation method, a call-back method and a definition annotation of the service implementation class are defined, and the service implementation method, the call-back method and the definition annotation are stored in a cache. When the instruction of the drawing information is clicked again next time, the service implementation class can be found in the general interface, and a one-to-one communication protocol is formed by sending command words and callback after cross-platform processing at the mobile terminal APP through an annotation method.
The cross-platform protocol generation device of the embodiment acquires annotation information corresponding to request information, and calls a service implementation sending method to send the request information to a cross-platform when acquiring a corresponding service implementation sending method through the annotation information; and receiving a callback result after cross-platform logic processing, and then acquiring a corresponding service according to the callback result to realize a receiving method, thereby forming a one-to-one communication protocol between the request information sending end and the cross-platform. According to the embodiment, a plurality of cross-platform protocols are not required to be defined, the cross-platform universal part is packaged on the interface and is dynamically acquired through the annotation form, a plurality of cross-platform frames on the market and the communication mode of the mobile terminal are unified, the codes are concise and clear, and seamless docking can be realized when the cross-platform is replaced. And when the corresponding service implementation class is not acquired through the annotation information, the service implementation class corresponding to the request information needs to be defined and stored in the cache for the next call, so that the later service expansion and the later service maintenance are facilitated.
EXAMPLE five
The embodiment of the invention provides a cross-platform protocol generation system, which comprises
A mobile terminal; the annotation information is used for acquiring annotation information corresponding to the request information; the method is used for judging whether a corresponding service realization sending method can be obtained in a predefined general interface according to the annotation information; the cross-platform information sending method is used for calling a service implementation sending method to send request information to a cross-platform; the logic processing result is used for receiving the cross-platform callback; the method is used for acquiring a corresponding service according to a logic processing result to realize a receiving method, so that a one-to-one communication protocol is formed between the sending request information and the call-back after cross-platform processing;
and the cross-platform is used for carrying out logic processing on the received request information and calling back a logic processing result to the mobile terminal by using a call-back method of the corresponding service implementation class.
EXAMPLE six
An embodiment of the present invention provides a terminal, including: a processor, a memory, and a computer program, such as a cross-platform protocol generation program, stored in the memory and executable on the processor. The steps in the above-described cross-platform protocol generation method embodiments are implemented when the processor executes the computer program.
Illustratively, a computer program can be partitioned into one or more modules, which are stored in memory and executed by a processor to implement the present invention. One or more of the modules may be a series of computer program instruction segments capable of performing certain functions, which are used to describe the execution of the computer program in the terminal.
Those skilled in the art will appreciate that the above description of the terminal is by way of example only and is not intended to be limiting, and that the terminal may include more or less components than those described, or some components may be combined, or different components may include, for example, input and output devices, network access devices, buses, etc.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like, the processor being the control center of the terminal, and various interfaces and lines connecting the various parts of the overall terminal.
The memory may be used to store computer programs and/or modules, and the processor may implement various functions of the terminal by operating or executing the computer programs and/or modules stored in the memory and calling data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. In addition, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
EXAMPLE seven
On the basis of the sixth embodiment, the embodiment of the present invention provides a computer-readable storage medium, and the terminal-integrated module/unit may be stored in the computer-readable storage medium if it is implemented in the form of a software functional unit and sold or used as an independent product. Based on such understanding, all or part of the functions of the units in the system according to the above embodiments may be implemented by a computer program, which is stored in a computer readable storage medium and used for instructing related hardware to implement the functions of the steps of the above method embodiments when being executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying computer program code, recording medium, U.S. disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution media, and the like.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents and improvements made within the spirit and principle of the present invention are intended to be included within the scope of the present invention.

Claims (10)

1. A method for generating a cross-platform protocol, the method comprising the steps of:
obtaining annotation information corresponding to the request information;
judging whether a corresponding service realization sending method can be obtained in a predefined general interface according to the annotation information;
if so, calling the service implementation sending method to send the request information to a cross-platform;
receiving a logic processing result of the cross-platform callback aiming at the request information;
and acquiring a corresponding service according to the logic processing result to realize the receiving method, thereby forming a one-to-one communication protocol between the request information sending end and the cross-platform.
2. The method for generating a cross-platform protocol according to claim 1, wherein the obtaining of the annotation information corresponding to the request information further comprises defining a generic interface, and defining a control, a parameter, and a callback parameter of the generic interface.
3. The cross-platform protocol generation method of claim 2,
defining a service implementation class in the universal interface, and defining a service implementation method, a callback method and a definition annotation of the service implementation class;
the service implementation method comprises a service implementation sending method and a service implementation receiving method.
4. The cross-platform protocol generation method of claim 3,
the definition annotation comprises definition Hashmap, wherein the Hashmap comprises two parameters of K and V, wherein K is a command word, and each request message corresponds to a unique command word; and V is a public interface class which comprises a control, a parameter and a callback method.
5. The method for generating a cross-platform protocol according to claim 1, wherein the determining whether the corresponding service implementation sending method can be found in the predefined common interface according to the annotation information further comprises,
and when the judgment result is negative, automatically initializing the service implementation class corresponding to the request information, and defining a service implementation method, a callback function and a definition annotation corresponding to the service implementation class.
6. A cross-platform protocol generation apparatus, comprising:
the obtaining unit is used for obtaining annotation information corresponding to the request information;
the judging unit is used for judging whether a corresponding service realization sending method can be obtained in a predefined general interface according to the annotation information;
the calling unit is used for calling the service implementation sending method to send the request information to a cross-platform;
the receiving unit is used for receiving the logic processing result of the cross-platform callback;
and the processing unit is used for acquiring the corresponding service according to the logic processing result to realize the receiving method, so that a one-to-one communication protocol is formed between the request information sending end and the cross-platform.
7. The cross-platform protocol generation apparatus of claim 6, further comprising,
and the initialization unit is used for initializing the service implementation class corresponding to the annotation information and adding the service implementation method, the callback function and the definition annotation corresponding to the service implementation class when the judgment result is negative.
8. A cross-platform protocol generation system, comprising:
the mobile terminal is used for acquiring annotation information corresponding to the request information; the method is used for judging whether a corresponding service realization sending method can be obtained in a predefined general interface according to the annotation information; the service realization sending method is used for calling the service realization sending method to send the request information to a cross-platform; the logic processing result is used for receiving the cross-platform callback; the method is used for acquiring a corresponding service according to a logic processing result to realize the receiving method, so that a one-to-one communication protocol is formed between the mobile terminal and the cross platform;
and the cross-platform is used for carrying out logic processing on the received request information and calling back a logic processing result to the mobile terminal by using a call-back method of the corresponding service implementation class.
9. A terminal device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the cross-platform protocol generation method of any one of claims 1-5 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that,
the computer program realizing the steps of the method according to any of claims 1-5 when executed by a processor.
CN202011369974.9A 2020-11-30 2020-11-30 Cross-platform protocol generation method, device, system, equipment and storage medium Active CN112398870B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011369974.9A CN112398870B (en) 2020-11-30 2020-11-30 Cross-platform protocol generation method, device, system, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011369974.9A CN112398870B (en) 2020-11-30 2020-11-30 Cross-platform protocol generation method, device, system, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112398870A true CN112398870A (en) 2021-02-23
CN112398870B CN112398870B (en) 2022-09-13

Family

ID=74605565

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011369974.9A Active CN112398870B (en) 2020-11-30 2020-11-30 Cross-platform protocol generation method, device, system, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112398870B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117201577A (en) * 2023-11-07 2023-12-08 中电长城(长沙)信息技术有限公司 Communication method and system of cross-platform API and SPI based on PISA

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017041657A1 (en) * 2015-09-09 2017-03-16 阿里巴巴集团控股有限公司 Application interface management method and device
CN110381135A (en) * 2019-07-18 2019-10-25 北京奇艺世纪科技有限公司 Interface creation method, service request method, device, computer equipment and medium
CN111400070A (en) * 2020-03-24 2020-07-10 广州华多网络科技有限公司 Terminal equipment and cross-process interface calling implementation and execution method thereof

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017041657A1 (en) * 2015-09-09 2017-03-16 阿里巴巴集团控股有限公司 Application interface management method and device
CN110381135A (en) * 2019-07-18 2019-10-25 北京奇艺世纪科技有限公司 Interface creation method, service request method, device, computer equipment and medium
CN111400070A (en) * 2020-03-24 2020-07-10 广州华多网络科技有限公司 Terminal equipment and cross-process interface calling implementation and execution method thereof

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117201577A (en) * 2023-11-07 2023-12-08 中电长城(长沙)信息技术有限公司 Communication method and system of cross-platform API and SPI based on PISA
CN117201577B (en) * 2023-11-07 2024-02-13 中电长城(长沙)信息技术有限公司 Communication method and system of cross-platform API and SPI based on PISA

Also Published As

Publication number Publication date
CN112398870B (en) 2022-09-13

Similar Documents

Publication Publication Date Title
CN108021710B (en) Dynamic interface conversion method, device, terminal equipment and storage medium
CN104754536A (en) Method and system for realizing communication between different languages
CN113641700A (en) Data processing method and device based on Spring boot frame
CN104714942A (en) Method and system for usablility of content to natural language processing tasks.
CN112398870B (en) Cross-platform protocol generation method, device, system, equipment and storage medium
CN110674205B (en) Single table query method, device, terminal and readable storage medium
CN115437808A (en) Intercommunication method, device, equipment, medium and product between federal learning platforms
CN110221840B (en) Function implementation method and device of application program, equipment and storage medium
US20200286012A1 (en) Model application method, management method, system and server
CN111369237A (en) Data processing method and device and computer storage medium
CN112732468B (en) Data processing method, data interaction system and computing equipment
CN114040189A (en) Multimedia test method, device, storage medium and electronic equipment
CN113760318A (en) Information processing method, information processing apparatus, server, and storage medium
CN110633162B (en) Remote call implementation method and device, computer equipment and storage medium
CN111522536A (en) Method for calling programming language and related equipment thereof
CN108595160B (en) Method and storage medium for calling native object by JS
WO2023083071A1 (en) View interaction method and apparatus, electronic device, and computer readable medium
CN105320499A (en) Adaptive method and related device of application program
CN116561202A (en) Method and device for serializing object
CN116263690A (en) Method and device for virtual machine to read data from external system and relevant written data
CN114385174A (en) Compiling method, device, equipment and storage medium of functional module
CN112948129A (en) Data transmission optimization method and device based on federal learning and readable storage medium
CN113779018A (en) Data processing method and device
CN113791777A (en) Picture display method and device, computer readable storage medium and electronic equipment
CN114978786B (en) Method and device for converting third party interface into system standard interface

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