Streaming request response method and device based on application development framework, equipment and storage medium
By building an SSE plug-in adapted to the Uni-App framework and calling the operating system native request plug-in, the problem that the Uni-App framework cannot support streaming data requests is solved, and cross-platform streaming data support and high flexibility development are achieved.
Patent Information
- Application Number
- CN202411522656.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-02-11
AI Technical Summary
The existing Uni-App request API cannot support streaming data requests, causing developers to encounter compatibility issues and development complexity when implementing real-time data push scenarios.
Build an SSE plug-in that is adapted to the Uni-App interface in the application development framework, and handle streaming requests by calling native request plug-ins from different operating systems, ensuring cross-platform development features and avoiding compatibility issues.
It realizes seamless support for streaming data requests under the Uni-App framework, reducing development costs and complexity, and ensuring cross-platform compatibility and high flexibility.
Smart Images

Figure CN119415177A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of mobile application development technology, and in particular to a streaming request response method, device, equipment and storage medium based on an application development framework. Background Art
[0002] Uni-App is a widely used cross-platform application development framework that allows developers to generate applications for multiple platforms such as Android, iOS, Web, and HarmonyOS through a set of code. However, the existing Application Programming Interface (API) requested by Uni-App cannot support streaming data requests. In actual development, streaming data is widely used in real-time data push scenarios, such as artificial intelligence (AI) chat question and answer applications, notification systems, and real-time updates.
[0003] Although there are some plug-ins on the market that can provide streaming data support, the APIs of most plug-ins cannot be adapted to Uni-App, which brings certain complexity to development. Summary of the invention
[0004] The present application provides a streaming request response method, apparatus, device and storage medium based on an application development framework, which can avoid compatibility issues between different operating systems, allow developers to freely use or modify plug-in codes, achieve high flexibility and reduce development costs.
[0005] In a first aspect, the present application provides a streaming request response method based on an application development framework, the method being applied to a streaming request SSE plug-in in the application development framework, the method comprising:
[0006] Receiving a streaming request initiated by the application development framework;
[0007] Calling a native request plug-in of a target operating system in the application development framework, so that the native request plug-in sends the streaming request to a server;
[0008] Receive streaming data determined by the server based on the streaming request, and display the streaming data in a display interface of the application development framework.
[0009] Furthermore, the application development framework is a Uni-App framework applicable to multiple operating systems, and the operating systems include at least Android system, iOS system and HarmonyOS system.
[0010] Furthermore, when the target operating system is an Android system, a native request plug-in of the target operating system in the application development framework is called so that the native request plug-in sends the streaming request to the server, including: establishing an http long connection for the streaming request by calling the Java standard library in the Android system to obtain the configured streaming request; and forwarding the configured streaming request to the server.
[0011] Furthermore, when the target operating system is an iOS system, a native request plug-in of the target operating system in the application development framework is called so that the native request plug-in sends the streaming request to the server, including: configuring a request header for the streaming request by calling an address request class method in the iOS system to obtain a configured streaming request; and forwarding the configured streaming request to the server by calling a network request class method in the iOS system.
[0012] Furthermore, when the target operating system is a HarmonyOS system, the native request plug-in of the target operating system in the application development framework is called so that the native request plug-in sends the streaming request to the server, including: forwarding the streaming request to the server by calling the network request tool library in the HarmonyOS system.
[0013] Furthermore, before receiving the streaming data determined by the server based on the streaming request, the method further includes: when the server fails to respond to the streaming request, processing the request exception data sent by the server through an asynchronous callback function.
[0014] Furthermore, the SSE plug-in is constructed in the following manner: a UTS plug-in is created based on the definition structure of the application development framework; functional logic corresponding to streaming requests of different operating systems is written for the UTS plug-in to obtain an intermediate plug-in; input parameters and return values of the API interface are designed for the intermediate plug-in to obtain the SSE plug-in, and the input parameters and return values of the API interface are consistent with the input parameters and return values of the uni.request method in the application development framework.
[0015] In a second aspect, the present application provides a streaming request response device based on an application development framework, wherein the device is integrated into a streaming request SSE plug-in in the application development framework, and the device includes:
[0016] A request receiving module, used for receiving a streaming request initiated by the application development framework;
[0017] A plug-in calling module, used to call a native request plug-in of a target operating system in the application development framework, so that the native request plug-in sends the streaming request to the server;
[0018] The data display module is used to receive the streaming data determined by the server based on the streaming request, and display the streaming data in the display interface of the application development framework.
[0019] In a third aspect, the present application provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the streaming request response method based on the application development framework described in any embodiment of the present application.
[0020] In a fourth aspect, the present application provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a processor to implement the streaming request response method based on the application development framework described in any embodiment of the present application when executed.
[0021] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the streaming request response method based on the application development framework described in any embodiment of the present application.
[0022] In order to solve the defects of the prior art in the background technology, an embodiment of the present application provides a streaming request response method based on an application development framework. Execution of the method can bring the following beneficial effects: the present application constructs an SSE plug-in adapted to the Uni-App interface in the application development framework. Developers can send streaming requests in a universal manner without having to learn new interfaces or tools, thereby reducing development costs; the present application initiates a streaming request on the application development framework through an SSE plug-in reception, and calls the native request plug-ins corresponding to different operating systems to process the streaming request, thereby ensuring the cross-platform development feature of Uni-App and avoiding compatibility issues between different operating systems. Developers can freely use or modify the plug-in code to achieve high flexibility and reduce development costs.
[0023] It should be noted that the above-mentioned computer instructions may be stored in whole or in part on a computer-readable storage medium. The computer-readable storage medium may be packaged together with the processor of the streaming request response device based on the application development framework, or may be packaged separately with the processor of the streaming request response device based on the application development framework, and this application does not limit this.
[0024] The description of the second, third, ..., and fifth aspects in this application can refer to the detailed description of the first aspect; and the beneficial effects of the description of the second, third, ..., and fifth aspects can refer to the beneficial effect analysis of the first aspect, which will not be repeated here.
[0025] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description.
[0026] It is understandable that before using the technical solutions disclosed in the embodiments of this application, the type, scope of use, and usage scenarios of the personal information involved in this application should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0028] Figure 1 A flowchart of a streaming request response method based on an application development framework provided in an embodiment of the present application;
[0029] Figure 2 A schematic diagram of the interaction process between the parties in the streaming request response process provided in an embodiment of the present application;
[0030] Figure 3 A schematic diagram of the structure of a streaming request response device based on an application development framework provided in an embodiment of the present application;
[0031] Figure 4 It is a block diagram of an electronic device used to implement a streaming request response method based on an application development framework in an embodiment of the present application. DETAILED DESCRIPTION
[0032] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.
[0033] It should be noted that the terms "first", "second", "target", and "original" in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including", "having", and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
[0034] Figure 1 A flow chart of a streaming request response method based on an application development framework provided in an embodiment of the present application, this embodiment is applicable to the case where a streaming request is initiated through a Uni-App request API. A streaming request response method based on an application development framework provided in this embodiment can be executed by a streaming request response device based on an application development framework provided in an embodiment of the present application, which can be implemented by software and / or hardware and integrated in an electronic device that executes the method. This method is applied to a streaming request (Server Sent Events, SSE) plug-in in an application development framework. Preferably, the electronic device in the embodiment of the present application can be an SSE plug-in.
[0035] See also Figure 1 The method of this embodiment includes but is not limited to the following steps:
[0036] S110: Receive a streaming request initiated by an application development framework.
[0037] Among them, the application development framework is the Uni-App framework applicable to multiple operating systems. Uni-App is a widely used cross-platform application development framework that allows developers to generate applications that adapt to multiple operating systems through a set of codes. The operating systems include at least Android, iOS and HarmonyOS.
[0038] This application builds an SSE plug-in that is compatible with the Uni-App interface in the application development framework, and executes a streaming request response method based on the application development framework through the SSE plug-in. The application development framework can meet the needs of real-time data push through the SSE plug-in, which is suitable for application scenarios such as chat, notification, and big data block push, thereby improving the real-time and interactivity of the application.
[0039] In the embodiment of the present application, the developer initiates a streaming request through the sse.request method set by the application development framework, and the request parameters are consistent with uni.request. The application development framework is configured with an SSE plug-in, and the streaming request can be received through the SSE plug-in.
[0040] S120: Calling a native request plug-in of the target operating system in the application development framework, so that the native request plug-in sends a streaming request to the server.
[0041] In the embodiment of the present application, Uni-App has a cross-platform (i.e., operating system) development feature. In order to solve the compatibility problem between developers and different operating systems, considering that different operating systems have some differences in the processing of streaming requests, this step uses the SSE plug-in as a bridge between the application development framework and different operating systems, and uses the native request plug-in of each operating system to support streaming data. The native request plug-in corresponding to the target operating system is called by the SSE plug-in to forward the streaming request, so that SSE streaming data requests can be supported on Android, iOS, and HarmonyOS platforms. The target operating system is at least one of the multiple operating systems.
[0042] Specifically, when the target operating system is an Android system, a native request plug-in of the target operating system in an application development framework is called so that the native request plug-in sends a streaming request to a server, including: establishing an http long connection for the streaming request by calling a Java standard library in a platform application development layer of the Android system to obtain a configured streaming request; and forwarding the configured streaming request to the server.
[0043] Among them, the method classes of the Java standard library used in the process of establishing an http long connection for a streaming request and initiating a request based on http may include the java.net.URL class, the java.net.HttpURLConnection class, the java.io.BufferedReader class, and the java.io.InputStreamReader class.
[0044] Optionally, you can use a third-party Java library (such as OkHttp, Retrofit, etc.) to establish an http persistent connection for streaming requests and communicate streaming data based on the http persistent connection.
[0045] Specifically, when the target operating system is an iOS system, the native request plug-in of the target operating system in the application development framework is called so that the native request plug-in sends a streaming request to the server, including: configuring a request header for the streaming request by calling an address request class method in the iOS system to obtain the configured streaming request; and forwarding the configured streaming request to the server by calling a network request class method in the iOS system. The address request class method may be an NSMutableURLRequest method; and the network request class method may be a URLSession method.
[0046] Optionally, the SSE plug-in in the iOS system can also use the Objective-C-based AFNetworking library or the Swift-based Alamofire library to send streaming requests to the server.
[0047] Specifically, when the target operating system is a HarmonyOS system, calling the native request plug-in of the target operating system in the application development framework so that the native request plug-in sends a streaming request to the server includes: forwarding the streaming request to the server by calling a network request tool library in the HarmonyOS system. The network request tool library may be an @ohos.net.http library.
[0048] Optionally, in Java SDK mode, most Java standard libraries and third-party libraries can be used; even in ArkTS mode, Web APIs such as Fetch API and JavaScript third-party libraries such as Axios can be used to implement streaming http requests.
[0049] S130 , receiving streaming data determined by the server based on the streaming request, and displaying the streaming data in a display interface of the application development framework.
[0050] Furthermore, before receiving the streaming data determined by the server based on the streaming request, it also includes: when the server fails to respond to the streaming request (such as network error, server response exception, etc.), the request exception data sent by the server is processed through an asynchronous callback function, thereby ensuring the real-time nature of the data and the stability of the request.
[0051] In an embodiment of the present application, when the server responds to the streaming request successfully, the SSE plug-in receives the streaming data determined by the server based on the streaming request, and displays the streaming data in the display interface of the application development framework through a callback function.
[0052] The technical solution provided in this embodiment receives a streaming request initiated through an application development framework; calls the native request plug-in of the target operating system in the application development framework so that the native request plug-in sends a streaming request to the server; receives the streaming data determined by the server based on the streaming request, and displays the streaming data in the display interface of the application development framework. This application constructs an SSE plug-in adapted to the Uni-App interface in the application development framework. Developers can send streaming requests in a universal way without having to learn new interfaces or tools, which reduces development costs; this application initiates a streaming request on the application development framework through the SSE plug-in, and calls the native request plug-in corresponding to different operating systems to process the streaming request, which ensures the cross-platform development characteristics of Uni-App and avoids compatibility issues between different operating systems. Developers can freely use or modify the plug-in code to achieve high flexibility and reduce development costs.
[0053] In an optional embodiment, the SSE plug-in is constructed in the following manner: First, based on the definition result of the application development framework, the UTS plug-in is written in the uni type script language, such as: in the Uni-App project, the UTS plug-in can be introduced by importing sse from "@ / uni_modules / uts-sse". Second, according to the plug-in language uts defined by uni-App, the functional logic corresponding to the streaming requests of different operating systems (such as android, ios, harmony, etc.) is written for the UTS plug-in to obtain an intermediate plug-in. Third, the input parameters and return values of the API interface are designed for the intermediate plug-in, and the SSE plug-in is obtained after packaging and publishing; wherein the input parameters and return values of the API interface are consistent with the input parameters and return values of the uni.request method in the application development framework, and support parameters such as url, headers, success, fail, and complete, so that the SSE plug-in interface is adapted to the Uni-App interface.
[0054] like Figure 2 The figure shows the interaction process of all parties in the streaming request response process. The figure shows that uni-App Vue can initiate a streaming request through the sse.request method, the SSE plug-in receives the streaming request, and calls the native request plug-in corresponding to the target operating system to forward the streaming request ( Figure 2 This step is not shown in the figure), the server determines the streaming data based on the streaming request and returns the streaming data to the SSE plug-in. The SSE plug-in displays the streaming data in the display interface of the application development framework. In addition, uni-App Vue can also cancel an ongoing task through the task.abort method. The SSE plug-in terminates the streaming request by calling the native plug-in corresponding to the target operating system.
[0055] This application is based on the SSE plug-in developed by the UTS plug-in, which is used to implement support for streaming data requests, avoiding dependence on third-party paid plug-ins and improving the flexibility and autonomy of the project. Through an API design consistent with uni.request, developers do not need to learn complex interfaces additionally, lowering the development threshold. The plug-in can implement cross-platform streaming requests on Android, iOS, and HarmonyOS platforms, ensuring cross-platform compatibility. Streaming data is pushed to the front end in real time in the form of SSE, which meets application scenarios that require real-time updates, and is particularly suitable for scenarios such as message push and event streams. Developers can initiate SSE requests on multiple platforms through a unified interface, greatly improving development efficiency.
[0056] Figure 3 A structural diagram of a streaming request response device based on an application development framework provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, the device is integrated into a streaming request SSE plug-in in an application development framework, and the device 300 may include:
[0057] A request receiving module 310, for receiving a streaming request initiated by the application development framework;
[0058] A plug-in calling module 320, configured to call a native request plug-in of a target operating system in the application development framework, so that the native request plug-in sends the streaming request to the server;
[0059] The data display module 330 is used to receive the streaming data determined by the server based on the streaming request, and display the streaming data in the display interface of the application development framework.
[0060] In one embodiment, the application development framework is a Uni-App framework applicable to multiple operating systems, and the operating systems include at least Android system, iOS system and HarmonyOS system.
[0061] Furthermore, the above-mentioned plug-in calling module 320 can be specifically used for: when the target operating system is the Android system, establishing an http long connection for the streaming request by calling the Java standard library in the Android system to obtain the configured streaming request; and forwarding the configured streaming request to the server.
[0062] Furthermore, the above-mentioned plug-in calling module 320 can also be specifically used for: when the target operating system is an iOS system, configuring a request header for the streaming request by calling an address request class method in the iOS system to obtain a configured streaming request; and forwarding the configured streaming request to the server by calling a network request class method in the iOS system.
[0063] Furthermore, the plug-in calling module 320 may also be specifically used for: when the target operating system is a HarmonyOS system, forwarding the streaming request to the server by calling a network request tool library in the HarmonyOS system.
[0064] Furthermore, the above-mentioned streaming request response device based on the application development framework may also include: an exception handling module;
[0065] The exception processing module is used to process the request exception data sent by the server through an asynchronous callback function when the server fails to respond to the streaming request before receiving the streaming data determined by the server based on the streaming request.
[0066] In one embodiment, the SSE plug-in is constructed in the following manner: a UTS plug-in is created based on the definition structure of the application development framework; functional logic corresponding to streaming requests of different operating systems is written for the UTS plug-in to obtain an intermediate plug-in; input parameters and return values of an API interface are designed for the intermediate plug-in to obtain the SSE plug-in, and the input parameters and return values of the API interface are consistent with the input parameters and return values of the uni.request method in the application development framework.
[0067] The streaming request response device based on the application development framework provided in this embodiment can be applied to the streaming request response method based on the application development framework provided in any of the above embodiments, and has corresponding functions and beneficial effects.
[0068] Figure 4 It is a block diagram of an electronic device for implementing a streaming request response method based on an application development framework in an embodiment of the present application. Electronic device 10 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.
[0069] like Figure 4 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0070] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0071] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a streaming request response method based on an application development framework.
[0072] In some embodiments, the streaming request response method based on the application development framework may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the streaming request response method based on the application development framework described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the streaming request response method based on the application development framework in any other appropriate manner (e.g., by means of firmware).
[0073] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0074] The computer programs for implementing the methods of the present application may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer programs are executed by the processor, the functions / operations specified in the flow charts and / or block diagrams are implemented. The computer programs may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0075] In the context of the present application, a computer readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. Alternatively, a computer readable storage medium may be a machine readable signal medium. A more specific example of a machine readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0076] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0077] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server) or a computing system that includes middleware components (e.g., an application server) or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein) or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0078] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0079] Note that the above are only preferred embodiments of the present application and the technical principles used. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present application. For example, those skilled in the art can use the various forms of processes shown above to reorder, add, or delete steps; the steps recorded in the present application can be performed in parallel, sequentially, or in different orders, as long as the desired results of the technical solution of the present application can be achieved, and this document does not limit them here.
[0080] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.
Claims
1. A streaming request response method based on an application development framework, characterized in that: The method is applied to a streaming request SSE plug-in in an application development framework, and the method comprises: Receiving a streaming request initiated by the application development framework; Calling a native request plug-in of a target operating system in the application development framework, so that the native request plug-in sends the streaming request to a server; Receive streaming data determined by the server based on the streaming request, and display the streaming data in a display interface of the application development framework.
2. The streaming request response method based on the application development framework according to claim 1 is characterized in that: The application development framework is a Uni-App framework applicable to multiple operating systems, and the operating systems include at least Android system, iOS system and HarmonyOS system.
3. The streaming request response method based on the application development framework according to claim 1 is characterized in that: When the target operating system is an Android system, calling a native request plug-in of the target operating system in the application development framework so that the native request plug-in sends the streaming request to the server includes: By calling the Java standard library in the Android system, an http persistent connection is established for the streaming request to obtain the configured streaming request; The configured streaming request is forwarded to the server.
4. The streaming request response method based on the application development framework according to claim 1 is characterized in that: When the target operating system is an iOS system, calling a native request plug-in of the target operating system in the application development framework so that the native request plug-in sends the streaming request to the server includes: By calling the address request class method in the iOS system, a request header is configured for the streaming request to obtain a configured streaming request; The configured streaming request is forwarded to the server by calling the network request class method in the iOS system.
5. The streaming request response method based on the application development framework according to claim 1 is characterized in that: When the target operating system is a HarmonyOS system, calling a native request plug-in of the target operating system in the application development framework so that the native request plug-in sends the streaming request to the server includes: The streaming request is forwarded to the server by calling the network request tool library in the HarmonyOS system.
6. The streaming request response method based on the application development framework according to claim 1 is characterized in that: Before receiving the streaming data determined by the server based on the streaming request, the method further includes: When the server fails to respond to the streaming request, the request exception data sent by the server is processed through an asynchronous callback function.
7. The streaming request response method based on the application development framework according to claim 1 is characterized in that: Build the SSE plugin as follows: Create a UTS plug-in based on the defined structure of the application development framework; Writing functional logic corresponding to streaming requests of different operating systems for the UTS plug-in to obtain an intermediate plug-in; The input parameters and return values of the API interface are designed for the intermediate plug-in to obtain the SSE plug-in, wherein the input parameters and return values of the API interface are consistent with the input parameters and return values of the uni.request method in the application development framework.
8. A streaming request response device based on an application development framework, characterized in that: The device is integrated into a streaming request SSE plug-in in an application development framework, and the device includes: A request receiving module, used for receiving a streaming request initiated by the application development framework; A plug-in calling module, used to call a native request plug-in of a target operating system in the application development framework, so that the native request plug-in sends the streaming request to the server; The data display module is used to receive the streaming data determined by the server based on the streaming request, and display the streaming data in the display interface of the application development framework.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively coupled to the at least one processor; The memory stores a computer program executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the streaming request response method based on the application development framework described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the streaming request response method based on an application development framework according to any one of claims 1 to 7 when executed.