A network data transmission method, device and system based on static library in iOS

Through the iOS static library-based network data transmission method, using singleton class objects and preset function mapping tables, efficient two-way communication between the iOS client and the server is realized, which solves the effectiveness and difficulty of the network request method in the existing technology. Maintenance difficulty issues improve system security and response speed.

CN113946614BActive Publication Date: 2024-10-11BEIJING LANGMA SHULIAN TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202111189866.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-12
Publication Date
2024-10-11
Estimated Expiration
2041-10-12

AI Technical Summary

Technical Problem

The existing network request methods of iOS clients, especially the http protocol and tcp protocol, have problems of insufficient effectiveness and high maintenance difficulty, and it is difficult to achieve two-way communication between the client and the server.

Method used

Adopt the iOS static library-based network data transmission method, use singleton class objects as the proxy of the static library, use sockets for network data transmission, and implement callback function processing through the preset function mapping table to achieve communication between the client and the server. Two-way communication.

Benefits of technology

It achieves efficient network data transmission and two-way communication, reduces the memory burden on the server, improves security and response speed, reduces the difficulty of early development and later maintenance, and adapts to flexible changes in business needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113946614B_ABST
    Figure CN113946614B_ABST
Patent Text Reader

Abstract

The present application provides an iOS network data transmission method, device and system based on a static library. The static library is provided with a corresponding singleton class object as the agent of the static library. The method is applied to the singleton class object, including: obtaining the call request sent by the iOS client and sending it to the static library uniformly, each call request is used to represent the iOS client to call the method in the static library through the interface exposed by the static library; receiving the network data called back by the static library, wherein the static library requests the server through the socket based on the call request to obtain the network data, and the network data includes the callback function corresponding to the target method that the iOS client wants to call; based on the network data, the method name corresponding to the callback function is determined from the preset function mapping table, and the corresponding target method is called to the iOS client based on the method name. This method not only solves the effectiveness of network data transmission, but also can realize the bidirectionality of communication between the client and the server.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data transmission, and in particular to an iOS network data transmission method, device and system based on a static library. Background Art

[0002] When developing iOS clients, you usually need to link some static libraries. When using static libraries, Xcode imports the framework and compiles it before using the static libraries. When using a developed static library, when there is a new business or problem modification, the library file needs to be modified, and the corresponding interface header file also needs to be modified. Therefore, it will take more time to compile the project using the static library.

[0003] When you need to add different functions or business requirements, you only need to change the parameters of the framework and application layers. Therefore, you can respond to application scenarios with flexible changes in business requirements without changing the static library. At this time, you need to make a unified manager at the client level. The data transmission between the application layer and the bottom layer can solve the corresponding problems by changing the parameters.

[0004] There are many traditional ways to handle network requests from iOS clients, such as http, tcp, udp, etc. These traditional transmission methods have certain defects for application development, such as the effectiveness and short links of http, and the difficulty for developers to use tcp and udp, and inconvenient maintenance. Summary of the invention

[0005] The purpose of the embodiments of the present application is to provide an iOS static library-based network data transmission method, device and system, so as to achieve bidirectional communication between the client and the server while ensuring the effectiveness of transmission through a transmission method of network request based on a static library.

[0006] In order to achieve the above purpose, the embodiments of the present application are implemented in the following manner:

[0007] In the first aspect, an embodiment of the present application provides an iOS network data transmission method based on a static library, wherein the static library is provided with a corresponding singleton class object as an agent of the static library, and the method is applied to the singleton class object, including: obtaining call requests sent by an iOS client and sending them uniformly to the static library, wherein each call request is used to represent that the iOS client intends to call a method in the static library through an interface exposed by the static library; receiving network data called back by the static library, wherein the static library requests the server through a socket based on the call request to obtain the network data, and the network data includes a callback function corresponding to a target method to be called by the iOS client; determining a method name corresponding to the callback function from a preset function mapping table based on the network data, and calling the corresponding target method to the iOS client based on the method name.

[0008] In the embodiment of the present application, a singleton class object is used as a proxy of a static library, between the client and the server, and the static library interface can be uniformly called, and a request is passed downward (to the static library). The static library can go to the server to modify or pull content, and the callback of the static library is received upward, and the distribution process is unified. Therefore, this method not only solves the effectiveness of network data transmission, but also can realize the bidirectionality of communication between the client and the server, which can be said to be a method that combines the advantages of the http protocol and the tcp protocol. And this method is lightweight and stateless, that is, the server does not retain any state when trading with the client, which greatly reduces the memory burden of the server, thereby maintaining a faster response speed. Compared with the traditional method of writing the tcp protocol locally with a socket, the connection is lightweight. The data transmission of the static library link network server has an encrypted state behavior, which can improve security, prevent network hackers from hijacking behavior, and prevent data from being tampered with. In addition, this method is convenient to call the interface, bidirectional transmission, and can realize timely communication functions compared to the one-way transmission of the http protocol. In addition, since the static library calls back to the iOS client, it is particularly important to process the callback content, especially when there are many interface callback data. If the corresponding callback processing code is configured for each callback interface, then the large amount of code will be extremely difficult for both early development and later maintenance. However, this solution targets static libraries and uses the framework to throw network data transmission to the application layer. The iOS client creates a proxy (singleton class object) to receive static library callbacks. A small amount of code can manage a large number of static library callbacks (can be achieved with a few lines of code), which can greatly reduce the difficulty of early development and later maintenance. In addition, this solution can adapt to application scenarios with flexible changes in business needs, because when business needs change, it will not affect the change of the interface name (similar to the domain name port of the http transmission protocol). The parameters can be changed by finding the corresponding file (can be achieved through a preset function mapping table) to change the specific business implementation, and it has strong maintainability and scalability.

[0009] In combination with the first aspect, in a first possible implementation method of the first aspect, the method of creating the singleton class object is: creating a singleton class PPCPMsgManager, PPCPMsgManager is the singleton class object; setting an agent in PPCPMsgManager, and generating a preset function mapping table containing multiple business management classes, wherein each of the business management classes is associated with at least one method name.

[0010] In this implementation, a singleton class object PPCPMsgManager is created. When a call request needs to be sent to a static library, this singleton class object can be called from anywhere. The static library request method can be called through the header file exposed by the framework. Setting up a proxy in PPCPMsgManager to generate a preset function mapping table containing multiple business management classes can facilitate the subsequent determination of the corresponding method name through this preset function mapping table in the callback processing process to call the corresponding method. There is no need to use the header file to call the method in the callback processing process, so it can adapt to the flexible and changeable application scenarios of business needs.

[0011] In combination with the first possible implementation method of the first aspect, in a second possible implementation method of the first aspect, a proxy is set in PPCPMsgManager to generate a preset function mapping table containing multiple business management classes, including: creating a singleton class PesRespondsManager as a proxy of PPCPMsgManager; obtaining multiple business management class callback function lists; for each business management class callback function list, looping the business management class callback function list to obtain the function SEL therein to obtain all functions in the business management class callback function list, then performing UTF-8 string processing on each function, and splitting the string into an array to split out the corresponding method name, and then registering the method name corresponding to the function plus parameters in the mapping relationship table, and releasing the function; after the registration of each business management class callback function list is completed, the preset function mapping table is obtained.

[0012] In this implementation, multiple business management class callback function lists are obtained; for each business management class callback function list, the business management class callback function list is processed in a loop, and the function SEL therein is obtained, so as to obtain all the functions in the business management class callback function list, and then each function is processed as a UTF-8 string, and the string is split into an array to split the corresponding method name, and then the method name corresponding to the function plus the parameter is registered in the mapping relationship table, and the function is released; after the registration of each business management class callback function list is completed, a preset function mapping table is obtained. In this way, the registration of functions can be realized, and a preset function mapping table can be obtained, so as to facilitate the implementation of the iOS network data transmission method based on the static library.

[0013] In combination with the first aspect, in a third possible implementation of the first aspect, the preset function mapping table includes multiple business management classes, each business management class is associated with at least one method name, and the method name corresponding to the callback function is determined from the preset function mapping table based on the network data, including: determining from the preset function mapping table a target business management class corresponding to the callback function in the network data; determining from the target business management class a method name that matches the callback function.

[0014] In this implementation, the method name matching the callback function can be determined simply and efficiently in this way.

[0015] In combination with the third possible implementation method of the first aspect, in a fourth possible implementation method of the first aspect, calling the corresponding target method to the iOS client based on the method name includes: based on the method name, determining the corresponding target method through the runtime characteristics of objective-C, and calling the target method to the iOS client.

[0016] In this implementation, the corresponding target method is determined through the runtime characteristics of objective-C, and the target method is called to the iOS client, so that the method in the business management class can be called without going through the header file.

[0017] In the second aspect, an embodiment of the present application provides an iOS network data transmission device based on a static library, wherein the static library is provided with a corresponding singleton class object as an agent of the static library, and the device is applied to the singleton class object, including: a call request unit, used to obtain the call request sent by the iOS client and send it to the static library uniformly, each call request is used to represent the iOS client's intention to call a method in the static library through an interface exposed by the static library; a data request unit, used to receive the network data called back by the static library, wherein the static library requests the server through a socket based on the call request to obtain the network data, and the network data includes the callback function corresponding to the target method that the iOS client wants to call; a method calling unit, used to determine the method name corresponding to the callback function from a preset function mapping table based on the network data, and call the corresponding target method to the iOS client based on the method name.

[0018] In the third aspect, an embodiment of the present application provides an iOS network data transmission system based on a static library, wherein the static library is provided with a corresponding singleton class object as an agent of the static library, and the system comprises: an iOS client, for calling the singleton class object to uniformly send a call request to the static library, in order to call the method in the static library through the interface exposed by the static library; the static library, for requesting network data from a server through a socket based on the call request, wherein the network data includes a callback function corresponding to a target method to be called by the iOS client; the singleton class object, for receiving the network data called back by the static library, determining the method name corresponding to the callback function from a preset function mapping table based on the network data, and calling the corresponding target method to the iOS client based on the method name.

[0019] In a fourth aspect, an embodiment of the present application provides a storage medium, which includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the iOS static library-based network data transmission method described in any one of the first aspect or possible implementation methods of the first aspect.

[0020] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory is used to store information including program instructions, and the processor is used to control the execution of the program instructions, and when the program instructions are loaded and executed by the processor, the iOS static library-based network data transmission method described in any one of the first aspect or the possible implementation methods of the first aspect is implemented.

[0021] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0023] Figure 1 A schematic diagram of an iOS static library-based network data transmission system provided in an embodiment of the present application.

[0024] Figure 2 A flowchart of an iOS static library-based network data transmission method provided in an embodiment of the present application.

[0025] Figure 3 Schematic diagram of the core processing solution for returning static library packets to iOS clients.

[0026] Figure 4 This is a structural block diagram of an iOS static library-based network data transmission device provided in an embodiment of the present application.

[0027] Figure 5 A structural block diagram of an electronic device provided in an embodiment of the present application.

[0028] Icons: 10-iOS network data transmission device based on static library; 11-call request unit; 12-data request unit; 13-method call unit; 20-electronic device; 21-memory; 22-communication module; 23-bus; 24-processor. DETAILED DESCRIPTION

[0029] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0030] See also Figure 1 , Figure 1 A schematic diagram of an iOS static library-based network data transmission system provided in an embodiment of the present application.

[0031] In this embodiment, the subjects (which may be entities or some virtual objects without entities, not limited here) in the iOS static library-based network data transmission system may include iOS clients, singleton class objects, static libraries and servers.

[0032] To facilitate the understanding of this solution, the basic situation of each subject in the iOS static library-based network data transmission system is first introduced here.

[0033] For iOS clients, you can use C++ to write the underlying processing code (including the network transmission protocol), compile it into a static library file, package the iOS client into the development tool, and compile and link the underlying static library.

[0034] The static library contains multiple methods that can be called by the client (callback functions are required for calling). After Xcode imports the framework and compiles it, the static library can be used (the header files of the static library that can be called are exposed through the framework).

[0035] For the server, the server stores callback functions corresponding to the methods in the static library, which can be returned to the static library in the form of network data. For the callback function, you can do callback processing similar to the http protocol, first use the int type result to represent the return result, and then use the json data structure to return the content.

[0036] The singleton class object corresponding to the static library, as the proxy of the static library, is located between the client and the server. It is mainly used to uniformly call the static library interface and pass requests downward (to the static library). The static library can go to the server to modify or pull content, receive callbacks from the static library upward, and distribute and process them uniformly.

[0037] Exemplarily, a singleton class PPCPMsgManager may be created, where PPCPMsgManager is the singleton class object, and then a proxy is set in PPCPMsgManager to generate a preset function mapping table containing multiple business management classes, wherein each business management class is associated with at least one method name.

[0038] Create a singleton class object PPCPMsgManager. When you need to send a call request to the static library, you can call this singleton class object from anywhere. Through the header file exposed by the framework, you can call the static library request method. Set up a proxy in PPCPMsgManager to generate a preset function mapping table containing multiple business management classes. This can facilitate the subsequent determination of the corresponding method name through this preset function mapping table in the callback processing process to call the corresponding method. There is no need to use the header file to call the method in the callback processing process, so it can adapt to the flexible and changeable application scenarios of business needs.

[0039] Specifically, a singleton class PesRespondsManager can be created as a proxy for PPCPMsgManager. Then, multiple business management class callback function lists can be obtained; for each business management class callback function list, the business management class callback function list can be looped to obtain the function SEL therein, thereby obtaining all the functions in the business management class callback function list. Then, each function is processed as a utf-8 string, and the string is split into an array to split out the corresponding method name, and then the method name corresponding to the function plus the parameters are registered in the mapping relationship table, and the function is released. After the registration of each business management class callback function list is completed, the preset function mapping table can be obtained.

[0040] In this way, function registration can be realized and a preset function mapping table can be obtained to facilitate the implementation of the iOS network data transmission method based on the static library.

[0041] For example, taking a specific example:

[0042] To process static library callbacks, we can use the proxy method to uniformly process the callback method, set the proxy in PPCPMsgManager, and generate multiple business management callbacks. The code is as follows:

[0043]

[0044] Create a singleton class PesRespondsManager, uniformly register the service management class callback function list, and create a serial queue to perform operations in the child thread to effectively shield the data disorder problem caused by multi-thread concurrency. The code is as follows:

[0045]

[0046]

[0047] Among them, line 1: Get the callback business management class function list; line 2: loop processing function table; line 3: get function SEL; line 4: get all functions in the business management class callback function list; line 5: perform UTF-8 string processing on the function; line 6: split the string into an array and split out the method name; line 7: register the function name plus parameters into the mapping relationship table; line 8: release the acquired function.

[0048] It should be noted that the creation process of the singleton class object is carried out when the client is started.

[0049] In this embodiment, the operation mode of the iOS network data transmission system based on the static library can be:

[0050] The iOS client can call the singleton class object to send a call request to the static library in a unified manner, in order to call the method in the static library through the interface exposed by the static library.

[0051] The static library can request network data from the server through the socket based on the call request, wherein the network data includes the callback function corresponding to the target that the iOS client wants to call.

[0052] The singleton class object can receive the network data of the static library callback, determine the method name corresponding to the callback function from the preset function mapping table based on the network data, and call the corresponding target method to the iOS client based on the method name.

[0053] Since the operation mode of the iOS static library-based network data transmission system in this solution corresponds to the execution process of the iOS static library-based network data transmission method to be introduced later, for the convenience of description, the iOS static library-based network data transmission method will be introduced in detail in the following text with the singleton class object (the singleton class object is also set in the electronic device where the client is located) as the execution subject, so as to realize the introduction of the iOS static library-based network data transmission system.

[0054] See also Figure 2 , Figure 2 A flowchart of a method for transmitting network data based on a static library in iOS provided in an embodiment of the present application. In this embodiment, the method for transmitting network data based on a static library in iOS may include step S10, step S20 and step S30.

[0055] In order to call the method in the static library, the iOS client can call the singleton class object to send a call request to the static library in a unified manner, in order to call the method in the static library through the interface exposed by the static library. At the same time, the singleton class object can perform step S10.

[0056] Step S10: Obtain the call requests sent by the iOS client and send them to the static library in a unified manner, wherein each call request is used to represent that the iOS client intends to call a method in the static library through an interface exposed by the static library.

[0057] In this embodiment, the singleton class object can obtain the call request sent by the iOS client and send it to the static library in a unified manner.

[0058] For example, it can be understood as follows: the iOS client initiates a call request, and the code is as follows:

[0059]

[0060] Then, the static library can request network data from the server through the socket based on the call request. This network data contains the callback function corresponding to the target that the iOS client wants to call. The server can then return the corresponding network data to the static library.

[0061] At this time, the singleton class object can execute step S20.

[0062] Step S20: receiving the network data called back by the static library, wherein the static library requests the server through a socket based on the calling request to obtain the network data, and the network data includes the callback function corresponding to the target method that the iOS client wants to call.

[0063] In this embodiment, the singleton class object can receive the network data (including the callback function corresponding to the target method) of the static library callback.

[0064] After receiving the network data, the singleton class object may execute step S30.

[0065] Step S30: determining a method name corresponding to the callback function from a preset function mapping table based on the network data, and calling a corresponding target method to the iOS client based on the method name.

[0066] In this embodiment, the singleton class object can determine the method name corresponding to the callback function from the preset function mapping table based on the network data, and call the corresponding target method to the iOS client based on the method name.

[0067] For example, the singleton class object can determine the target service management class corresponding to the callback function in the network data from the preset function mapping table, and then determine the method name matching the callback function from the target service management class. In this way, the method name matching the callback function can be determined simply and efficiently.

[0068] In addition, the singleton class object can determine the corresponding target method based on the method name through the runtime characteristics of objective-C, and call the target method to the iOS client. In this way, the method in the business management class can be called without going through the header file.

[0069] For example, the callback processing process can be: when receiving a static library callback, PesRespondsManager can find the corresponding business management class from the function mapping table, then search the dictionary in the business management class to find the corresponding method name, and find the corresponding method through the runtime characteristics of objective-C, so that the method in the business management class can be called without using header files. Figure 3 As shown, Figure 3This is a schematic diagram of the core processing solution for the static library to return packets to the iOS client. Among them, Responds represents the response network data (that is, the callback data packet that the static library wants to call back to the iOS client), and PesRespondsManager is a singleton class object that processes the network data and implements the call to the method.

[0070] In this embodiment, the processing operations of callback data packets (i.e., network data) can be put in a sub-thread to prevent time-consuming operations from blocking user operations in the main thread and affecting user experience. Putting them in a serial queue for queuing can prevent concurrency from affecting the timing of data processing.

[0071] As for the case where callback data packets (network data) are distributed in various file management classes, after data processing is completed, they can be called back to the business in the form of notification or proxy. After receiving and processing, the business will classify them. If the UI needs to be operated in the main thread, it will be thrown into the main thread for processing. If the UI does not need to be operated in the main thread, it can be processed in the current thread.

[0072] See also Figure 4 , Figure 4 This is a structural block diagram of an iOS static library-based network data transmission device 10 provided in an embodiment of the present application.

[0073] In this embodiment, the static library is provided with a corresponding singleton class object as a proxy of the static library, and the device is applied to the singleton class object. The iOS static library-based network data transmission device 10 may include:

[0074] The call request unit 11 is used to obtain the call requests sent by the iOS client and send them to the static library in a unified manner. Each call request is used to represent that the iOS client intends to call a method in the static library through an interface exposed by the static library.

[0075] The data request unit 12 is used to receive the network data called back by the static library, wherein the static library requests the server through a socket based on the call request to obtain the network data, and the network data includes the callback function corresponding to the target method that the iOS client wants to call.

[0076] The method calling unit 13 is used to determine the method name corresponding to the callback function from the preset function mapping table based on the network data, and call the corresponding target method to the iOS client based on the method name.

[0077] In this embodiment, the preset function mapping table includes multiple business management classes, each business management class is associated with at least one method name, and the method calling unit 13 is specifically used to determine the target business management class corresponding to the callback function in the network data from the preset function mapping table; determine the method name that matches the callback function from the target business management class.

[0078] In this embodiment, the method calling unit 13 is specifically configured to determine a corresponding target method based on the method name through the runtime characteristics of objective-C, and call the target method to the iOS client.

[0079] See also Figure 5 , Figure 5 This is a structural block diagram of an electronic device 20 provided in an embodiment of the present application.

[0080] In this embodiment, the electronic device 20 is a terminal with a built-in iOS client, such as a personal computer, a tablet computer, a smart phone, etc., which is not limited here.

[0081] Exemplarily, the electronic device 20 may include: a communication module 22 connected to the outside world through a network, one or more processors 24 for executing program instructions, a bus 23, and different forms of memory 21, such as a disk, ROM, or RAM, or any combination thereof. The memory 21, the communication module 22, and the processor 24 may be connected through the bus 23.

[0082] Exemplarily, programs are stored in the memory 21. The processor 24 can call and run these programs from the memory 21, so that the iOS network data transmission method based on the static library can be implemented by running the programs.

[0083] An embodiment of the present application provides a storage medium, which includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the iOS static library-based network data transmission method in this embodiment.

[0084] In summary, the embodiment of the present application provides an iOS network data transmission method, device and system based on a static library, using a singleton class object as a proxy for a static library, between a client and a server, and can uniformly call the static library interface, pass requests downward (to the static library), and the static library can go to the server to modify or pull content, and receive callbacks from the static library upward, and uniformly distribute and process. Therefore, this method not only solves the effectiveness of network data transmission, but also can realize the bidirectionality of communication between the client and the server, which can be said to be a method that combines the advantages of the http protocol and the tcp protocol. And this method is lightweight and stateless, that is, the server does not retain any state when trading with the client, which greatly reduces the memory burden of the server, thereby maintaining a faster response speed. Compared with the traditional method of writing the tcp protocol locally with a socket, the connection is lightweight. The data transmission of the static library link network server has an encrypted state behavior, which can improve security, prevent network hacker hijacking behavior, and prevent data from being tampered with. In addition, this method is convenient to call the interface, bidirectional transmission, and can realize timely communication functions compared to the one-way transmission of the http protocol. In addition, since the static library calls back to the iOS client, it is particularly important to process the callback content, especially when there are many interface callback data. If the corresponding callback processing code is configured for each callback interface, then the large amount of code will be extremely difficult for both early development and later maintenance. However, this solution targets static libraries and uses the framework to throw network data transmission to the application layer. The iOS client creates a proxy (singleton class object) to receive static library callbacks. A small amount of code can manage a large number of static library callbacks (can be achieved with a few lines of code), which can greatly reduce the difficulty of early development and later maintenance. In addition, this solution can adapt to application scenarios with flexible changes in business needs, because when business needs change, it will not affect the change of the interface name (similar to the domain name port of the http transmission protocol). The parameters can be changed by finding the corresponding file (can be achieved through a preset function mapping table) to change the specific business implementation, and it has strong maintainability and scalability.

[0085] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0086] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0087] Furthermore, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0088] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0089] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. An iOS network data transmission method based on static library, characterized in that: The static library is provided with a corresponding singleton class object as a proxy of the static library, and the method is applied to the singleton class object, including: Obtaining call requests sent by the iOS client and sending them uniformly to the static library, each call request is used to represent that the iOS client intends to call a method in the static library through an interface exposed by the static library; Receive network data called back by the static library, wherein the static library requests the server through a socket based on the call request to obtain the network data, and the network data includes a callback function corresponding to the target method that the iOS client wants to call; Determine a method name corresponding to the callback function from a preset function mapping table based on the network data, and call a corresponding target method to the iOS client based on the method name; The way to create the singleton class object is: Create a singleton class PPCPMsgManager, PPCPMsgManager is the singleton class object; Setting an agent in PPCPMsgManager to generate a preset function mapping table containing multiple business management classes, wherein each of the business management classes is associated with at least one method name; Set up the agent in PPCPMsgManager to generate a preset function mapping table containing multiple business management classes, including: Create a singleton class PesRespondsManager as the proxy of PPCPMsgManager; Get multiple business management callback function lists; For each business management class callback function list, loop through the business management class callback function list to obtain the function SEL therein, thereby obtaining all functions in the business management class callback function list, and then perform UTF-8 string processing on each function, and split the string into an array to split out the corresponding method name, and then register the method name corresponding to the function plus the parameters into the mapping relationship table, and release the function; After the registration of each service management class callback function list is completed, the preset function mapping table is obtained.

2. The iOS network data transmission method based on static library according to claim 1 is characterized in that: The preset function mapping table includes a plurality of service management classes, each service management class is associated with at least one method name, and the method name corresponding to the callback function is determined from the preset function mapping table based on the network data, including: Determining a target service management class corresponding to the callback function in the network data from the preset function mapping table; A method name matching the callback function is determined from the target business management class.

3. The iOS network data transmission method based on static library according to claim 2 is characterized in that: Calling a corresponding target method to the iOS client based on the method name includes: Based on the method name, a corresponding target method is determined through the runtime characteristics of objective-C, and the target method is called to the iOS client.

4. An iOS network data transmission device based on a static library, characterized in that: The static library is provided with a corresponding singleton class object as a proxy of the static library, and the device is applied to the singleton class object, including: A call request unit, used for acquiring the call requests sent by the iOS client and sending them uniformly to the static library, each call request is used for representing that the iOS client intends to call a method in the static library through an interface exposed by the static library; A data request unit, configured to receive network data called back by the static library, wherein the static library requests the server through a socket based on the call request to obtain the network data, and the network data includes a callback function corresponding to the target method to be called by the iOS client; A method calling unit, configured to determine a method name corresponding to a callback function from a preset function mapping table based on the network data, and call a corresponding target method to the iOS client based on the method name; The method of creating the singleton class object is as follows: Create a singleton class PPCPMsgManager, PPCPMsgManager is the singleton class object; set a proxy in PPCPMsgManager, generate a preset function mapping table containing multiple business management classes, wherein each of the business management classes is associated with at least one method name; Set up the agent in PPCPMsgManager to generate a preset function mapping table containing multiple business management classes, including: Create a singleton class PesRespondsManager as a proxy for PPCPMsgManager; obtain multiple business management class callback function lists; for each business management class callback function list, perform loop processing on the business management class callback function list, obtain the function SEL therein, so as to obtain all the functions in the business management class callback function list, and then perform UTF-8 string processing on each function, and split the string into an array to split out the corresponding method name, and then register the method name corresponding to the function plus the parameters into the mapping relationship table, and release the function; after the registration of each business management class callback function list is completed, the preset function mapping table is obtained.

5. An iOS network data transmission system based on static library, characterized in that: The static library is provided with a corresponding singleton class object as a proxy of the static library, and the system comprises: The iOS client is used to call the singleton class object to send a call request to the static library in a unified manner, so as to call a method in the static library through an interface exposed by the static library; The static library is used to request network data from the server through a socket based on the call request, wherein the network data includes a callback function corresponding to a target method that the iOS client wants to call; The singleton class object is used to receive the network data of the static library callback, determine the method name corresponding to the callback function from the preset function mapping table based on the network data, and call the corresponding target method to the iOS client based on the method name; The method of creating the singleton class object is as follows: Create a singleton class PPCPMsgManager, PPCPMsgManager is the singleton class object; set a proxy in PPCPMsgManager, generate a preset function mapping table containing multiple business management classes, wherein each of the business management classes is associated with at least one method name; Set up the agent in PPCPMsgManager to generate a preset function mapping table containing multiple business management classes, including: Create a singleton class PesRespondsManager as a proxy for PPCPMsgManager; obtain multiple business management class callback function lists; for each business management class callback function list, perform loop processing on the business management class callback function list, obtain the function SEL therein, so as to obtain all the functions in the business management class callback function list, and then perform UTF-8 string processing on each function, and split the string into an array to split out the corresponding method name, and then register the method name corresponding to the function plus the parameters into the mapping relationship table, and release the function; after the registration of each business management class callback function list is completed, the preset function mapping table is obtained.

6. A storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the iOS static library-based network data transmission method described in any one of claims 1 to 3.

7. An electronic device, characterized in that: The invention comprises a memory and a processor, wherein the memory is used to store information including program instructions, and the processor is used to control the execution of the program instructions, and when the program instructions are loaded and executed by the processor, the iOS static library-based network data transmission method described in any one of claims 1 to 3 is implemented.

Citation Information

Patent Citations

  • Componentization construction method of engineering project under IOS platform

    CN107729061A

  • Network performance parameter collection method, terminal device and memory medium

    CN108809763A

  • Cross-process callback execution method and device, equipment and storage medium

    CN111880866A

  • Method of dynamically appending a library to an actively running program

    US20040226031A1