Protocol chain construction method, device, equipment and storage medium
By introducing the MVVM framework into the MVC framework, setting the logic layer as the proxy of the view element layer, and constructing a protocol chain, the problems of bloated Controller and inconvenient maintenance are solved, and the effect of simplifying controller work and improving code reusability is achieved.
Patent Information
- Application Number
- CN202310854817.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-12
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2043-07-12
AI Technical Summary
In the MVC framework, when the Controller acts as the core controller to manage numerous logics, it becomes increasingly bloated and the forwarding link becomes long, causing inconvenience to system maintenance.
Introduce the two-way binding framework (MVVM), set the logic layer as the proxy of the view element layer, manage event processing by constructing a protocol chain, reduce the burden on the Controller, and use a chain structure instead of a tree structure for message transmission.
It simplifies the controller's workflow, reduces code coupling, improves code reusability, and facilitates system maintenance.
Smart Images

Figure CN116708595B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data communication technology, and in particular to a method, apparatus, device and storage medium for constructing a protocol chain. Background Art
[0002] The most commonly used design model in software communication development is the Model-View-Controller (MVC) framework. This allows for code separation between the data and view components, allowing the same program to use different presentation formats. However, in the MVC model, using the controller as the core controller to manage numerous logic functions results in the controller storing numerous proxy methods and requiring long forwarding links for each proxy method. This results in the controller becoming increasingly bloated. Furthermore, the long forwarding links involved in the controller create inconveniences in system maintenance. Summary of the Invention
[0003] The main purpose of the embodiments of the present application is to propose a construction method, apparatus, device and storage medium for a protocol chain, aiming to simplify the work of the controller and facilitate maintenance of the system.
[0004] To achieve the above objectives, a first aspect of an embodiment of the present application proposes a method for constructing a protocol chain, which is applied to a two-way binding framework. The two-way binding framework includes a data model layer, a view element layer, and a logic layer. The logic layer is set as a proxy for the view element layer. The method includes:
[0005] receiving a first instruction sent by a user terminal, and specifying a first protocol according to a first business scenario corresponding to the first instruction, wherein the first protocol is used to define an event type transmitted by the view element layer in the first business scenario;
[0006] Setting a first response object at the logic layer according to the first protocol, wherein the first response object is bound to the first protocol;
[0007] The first response object is linked to a second response object according to the first business scenario to obtain a first protocol chain.
[0008] In some embodiments, linking the first response object to the second response object according to the first business scenario further includes:
[0009] An acquisition method of the first protocol is specified, and the acquisition method is distributed to the second response object, so that the second response object responds to the acquisition method to perform an information acquisition operation.
[0010] In some embodiments, linking the first response object to the second response object according to the first business scenario further includes:
[0011] According to the first business scenario, a new response object is added to the second response object link at the end of the current protocol chain; the verification method of the first protocol is specified, and the verification method is distributed to the newly added response object, so that the newly added response object responds to the verification method to perform a verification operation; until all operations included in the first business scenario are completed.
[0012] In some embodiments, linking the first response object to the second response object according to the first business scenario to obtain a first protocol chain includes:
[0013] The close operation instruction is called to make the response object at the end of the current protocol chain stop linking to other response objects, thereby obtaining the first protocol chain.
[0014] In some embodiments, the method further comprises:
[0015] Notifying the data model layer to perform an update operation according to the first protocol chain, and causing the data model layer to feedback completion information after completing the update operation;
[0016] The view element layer is notified according to the completion information to perform an interface update operation.
[0017] In some embodiments, the method further comprises:
[0018] When the user terminal sends the second instruction, specifying the second protocol according to the second business scenario corresponding to the second instruction;
[0019] Setting a third response object within the logic layer according to the second protocol, and binding the third response object to the second protocol;
[0020] According to the second business scenario, response objects are linked to the third response object one by one until all operations included in the second business scenario are executed, thereby obtaining a second protocol chain.
[0021] In some embodiments, the method further comprises:
[0022] The asynchronous callback instruction is declared in combination with the specified protocol, so that the logic layer can realize information transmission in all business scenarios through function pointer calls.
[0023] To achieve the above objectives, a second aspect of an embodiment of the present application proposes a protocol chain construction device, which introduces a two-way binding framework. The two-way binding framework includes a data model layer, a view element layer, and a logic layer. The logic layer is set as a proxy for the view element layer. The device includes:
[0024] a control module, configured to receive a first instruction sent by a user terminal, and specify a first protocol according to a first business scenario corresponding to the first instruction, wherein the first protocol is used to define an event type transmitted by the view element layer in the first business scenario;
[0025] a binding module, configured to set a first response object at the logic layer according to the first protocol, wherein the first response object is bound to the first protocol;
[0026] A linking module is used to link the first response object to the second response object according to the first business scenario to obtain a first protocol chain.
[0027] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, the memory stores a computer program, and the processor implements the protocol chain construction method described in the first aspect when executing the computer program.
[0028] To achieve the above-mentioned objectives, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the protocol chain construction method described in the first aspect above.
[0029] The protocol chain construction method, apparatus, device and storage medium proposed in this application are based on a two-way binding framework, and the logic layer is set as a proxy of the view element layer, thereby reducing the burden on the control layer. At the same time, on this basis, this application can receive the first instruction sent by the user and gradually construct the first protocol chain according to the first instruction, so that each node can achieve rapid communication through the first protocol chain, without the need to construct a layer-by-layer forwarding link with the controller as the central node, thereby simplifying the work of the controller and facilitating the maintenance of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The accompanying drawings are used to provide a further understanding of the technical solution of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the technical solution of the present invention and do not constitute a limitation to the technical solution of the present invention.
[0031] Figure 1 This is the main flow chart of the protocol chain construction method provided in the embodiment of the present application;
[0032] Figure 2 This is another sub-flowchart of the protocol chain construction method provided in an embodiment of the present application;
[0033] Figure 3 This is another sub-flowchart of the protocol chain construction method provided in an embodiment of the present application;
[0034] Figure 4 This is a schematic diagram of the structure of the two-way binding framework provided by the embodiment of the present application;
[0035] Figure 5 Schematic diagram of the structure of the protocol chain construction device provided in an embodiment of the present application;
[0036] Figure 6 This is a schematic diagram of the hardware structure of the electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0038] It should be noted that although the device schematics illustrate functional module divisions and the flowcharts illustrate logical sequences, in certain circumstances, the steps shown or described may be performed in a sequence that differs from the module divisions in the device or the sequence in the flowcharts. The terms "first," "second," and so on, in the specification, claims, and drawings, are used to distinguish similar items and are not necessarily used to describe a specific sequence or precedence.
[0039] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.
[0040] First, let’s analyze some of the terms used in this application:
[0041] The Model-View-Controller (MVC) framework consists of a data model layer 401. The Model layer 401 handles the most processing tasks among the three components of MVC. The data returned by the data model layer 401 is format-neutral, allowing it to provide data for multiple views. This reduces code duplication, as the code for the data model layer 401 only needs to be written once and reused across multiple views. The View layer 402 is the interface that users see and interact with, such as a web page composed of HTML elements or a software client interface. One of the benefits of MVC is that it can handle many different View layers 402 for an application. No actual processing occurs within the View layer 402; it simply serves as a way to output data and allow user interaction. The Controller layer accepts user input and calls the Model and View to fulfill user requests. The Controller itself does not output anything or perform any processing. It simply receives the request and decides which model component to call to handle the request, and then determines which view to use to display the returned data.
[0042] The two-way binding framework (Model-View-ViewModel, MVVM) is essentially an improvement on MVC. MVVM abstracts the state and behavior of the view element layer 402, separating the view UI from the business logic. Furthermore, MVVM can retrieve data from the data model layer 401 while also handling the business logic required to display content in the view element layer 402. WPF software introduces new technologies such as Silverlight, audio, video, 3D, and animation, resulting in more detailed and customizable UI layers. Furthermore, WPF also introduces new technical features such as Binding, Dependency Property, Routed Events, Commands, DataTemplates, and ControlTemplates. The MVVM framework evolved from the integration of the Model-View-Presenter (MVP) pattern with WPF. It builds on the existing MVP framework and incorporates new WPF features to meet increasingly complex customer needs. Under the MVVM architecture, view element layer 402 and data model layer 401 have no direct connection. Instead, data exchange occurs through logic layer 403. The interaction between data model layer 401 and logic layer 403 is bidirectional, so changes in data in view element layer 402 are synchronized to data model layer 401, and changes in data model layer 401 are immediately reflected in view element layer 402. Logic layer 403 connects view element layer 402 and data model layer 401 through bidirectional data binding. Synchronization between view element layer 402 and data model layer 401 is fully automatic, requiring no human intervention. Therefore, developers only need to focus on business logic, without having to manually manipulate the DOM or worry about data state synchronization. Maintenance of complex data states is completely managed by MVVM.
[0043] Asynchronous callback block, block is a closure that can capture context. The implementation of the block and the call itself can be separated. The block is implemented inside the view element layer 402, and the block is called in any business code of the logic layer 403. This reduces the use of notifications and allows messages to be passed directly from the logic layer 403 to the view element layer 402.
[0044] A communication protocol refers to the rules and agreements that two entities must follow to complete communication or services. For multiple geographically dispersed data communication systems, interconnected through communication channels and devices, to work together to exchange information and share resources, they must share a common language. What, how, and when to communicate must adhere to mutually accepted rules. These rules are the communication protocol. The protocol defines the format used for data units, the information and meaning contained in information units, the connection method, and the timing of information transmission and reception, thereby ensuring that data on the network is smoothly transmitted to the intended destination. In computer communications, communication protocols are used to implement standard connections between computers and networks. Without a unified communication protocol, information transmitted between computers cannot be recognized.
[0045] Based on this, the embodiments of the present application provide a construction method, apparatus, device and storage medium for a protocol chain, which are specifically illustrated by the following embodiments. First, the construction method in the embodiments of the present application is described.
[0046] The embodiment of the present application can obtain and process relevant data based on MVVM technology. Among them, the view element layer 402 and the data model layer 401 in MVVM have no direct connection, but data interaction is carried out through the logic layer 403. The interaction between the data model layer 401 and the logic layer 403 is bidirectional, so the changes in the data of the view element layer 402 will be synchronized to the data model layer 401, and the changes in the data of the data model layer 401 will also be immediately reflected on the view element layer 402. The logic layer 403 connects the view element layer 402 and the data model layer 401 through bidirectional data binding, and the synchronization between the view element layer 402 and the data model layer 401 is completely automatic and does not require human intervention. Therefore, developers only need to focus on business logic, do not need to manually operate Dom, and do not need to pay attention to the synchronization problem of data status. The maintenance of complex data status is completely managed by MVVM.
[0047] MVVM's controllers are clear and concise, and the logic layer 403 separates most of the controller code, making it clearer and easier to maintain. MVVM also facilitates testing, and most bugs in development come from logic processing. Because the logic layer 403 separates a lot of logic, it can be unit tested for the logic layer 403. MVVM is widely used in iOS front-end development.
[0048] The construction method of the protocol chain provided in the embodiment of the present application relates to the field of data communication technology. The construction method of the protocol chain provided in the embodiment of the present application can be applied to the terminal, can also be applied to the server side, and can also be software running in the terminal or the server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or can be configured as a server cluster or distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the construction method of the protocol chain, etc., but is not limited to the above forms.
[0049] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and the like. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments in which tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.
[0050] It should be noted that in each specific embodiment of the present application, when it comes to the need to perform relevant processing based on data related to the user's identity or characteristics, such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of such data will comply with the relevant laws, regulations, and standards of the relevant countries and regions. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.
[0051] Figure 1This is the main flow chart of the protocol chain construction method provided by the embodiment of the present application. In some embodiments, the protocol chain construction method of the present application is applied to a two-way binding framework, which includes a data model layer 401, a view element layer 402, and a logic layer 403. The logic layer 403 is set as a proxy for the view element layer 402. Figure 1 The method may include but is not limited to steps S110 to S130.
[0052] Step S110: receiving a first instruction sent by the user terminal, and specifying a first protocol according to a first business scenario corresponding to the first instruction, wherein the first protocol is used to define an event type transmitted by the view element layer 402 in the first business scenario;
[0053] Step S120: setting a first response object in the logic layer 403 according to the first protocol, and binding the first response object to the first protocol;
[0054] Step S130: Link the first response object to the second response object according to the first business scenario to obtain a first protocol chain.
[0055] In steps S110 to S130 shown in the embodiment of the present application, the logic layer 403 is set as the agent of the view element layer 402 through a two-way binding framework, thereby reducing the burden on the view element layer 402 and the control layer. At the same time, the present application can receive the first instruction sent by the user and gradually construct the first protocol chain according to the first instruction on this basis, so that each node can achieve fast communication through the first protocol chain, without the need to construct a layer-by-layer forwarding link with the controller as the central node, thereby simplifying the work of the controller and facilitating the maintenance of the system.
[0056] It should be noted that the MVC framework is the most commonly used in the software communication development process. However, in the MVC model, using the Controller as the core controller to manage numerous logics will cause the Controller to store numerous proxy methods and require constructing longer forwarding links for different proxy methods. This makes the Controller gradually bloated. Moreover, because the forwarding links involved in the Controller are long, it causes inconvenience to system maintenance.
[0057] Therefore, to address the shortcomings of the MVC framework, operators introduced the MVVM framework, also known as a two-way binding framework. The most common MVVM solution in iOS development is to integrate the Rac and RxSwift frameworks. If Rac and RxSwift frameworks lack support, they can only explore the source code and resolve it accordingly. Furthermore, when a program crashes in an imported third-party library, operators are forced to spend a considerable amount of time researching the source code, resulting in a high learning curve. Everyone has a different understanding of MVVM and MVC. When handing over someone else's code, one needs to familiarize themselves with their development practices and understand their thinking patterns. This learning process requires considerable trial and error.
[0058] Please refer to Figure 4 , Figure 4 This is a schematic diagram of the structure of the two-way binding framework provided by an embodiment of the present application, wherein the data model layer 401 refers to the data transmitted by the backend, the view element layer 402 refers to presenting the data to the user in some manner, and the logic layer 403 is a bridge connecting the view element layer 402 and the data model layer 401. Generally, the logic layer 403 is used to receive backend data sent by the data model layer 401 and convert the backend data into frontend pages and send them to the view element layer 402. The logic layer 403 is also used to receive frontend pages sent by the view element layer 402, parse the frontend pages, convert them into backend data, and send them to the data model layer 401.
[0059] This application is based on a two-way binding framework and sets the logic layer 403 as a proxy of the view element layer 402, so that the logic layer 403 proxies the view element layer 402 to handle related events, thereby reducing the burden on the Controller.
[0060] According to an embodiment of the present application, there is no connection between different protocol chains. Each protocol chain represents a series of processing logic corresponding to a specific operation. The active state of the protocol chain indicates that there is message forwarding in the current protocol chain, and the forwarding of messages is a dynamic process that requires the user to click on the operation page. Therefore, it is necessary to construct a protocol chain before communication. Specifically, when the user clicks the login button in the login interface, the protocol chain involved may contain nodes such as: verifying whether the information entered by the user (mobile phone number, password and verification code, etc.) is accurate, calling the login interface, prompting the loading box, recording the number of logins, etc.
[0061] More specifically, when an operator needs to develop a view page, he or she first needs to construct a protocol chain corresponding to the view page. In the actual development process, the operator first needs to send a first instruction to the core controller Controller of the protocol chain in combination with the business scenario currently being developed. The Controller receives the first instruction and specifies the first protocol according to the first business scenario corresponding to the first instruction. Among them, the first protocol is a technical solution provided by the system, which is used to define the event type transmitted by the view element layer 402 under the first business scenario. The protocol will define a series of methods for data interaction between different nodes. Therefore, it is necessary to specify the protocol in combination with the current business scenario. The protocol serves as a guide for the protocol chain to associate nodes that need to receive messages. In different business scenarios, the specified protocols and nodes are not exactly the same.
[0062] The user's events are transmitted from the view element layer 402. Since this application sets the logic layer 403 as the proxy of the view element layer 402, it is necessary to set up multiple response objects in the logic layer 403 to receive events transmitted by the view element layer 402. After the Controller specifies the first protocol according to the first business scenario, it is also necessary to set up the first response object in the logic layer 403 according to the first protocol, and the first response object is bound to the first protocol. The first response object bears the responsibility of the message receiver. Only when all methods in the specified protocol are implemented can the methods in the protocol be forwarded. If the first response object does not implement a method, the message of the method cannot be passed through the protocol chain. Therefore, the first response object must be able to respond to all methods in the first protocol. At the same time, the Controller, as the control center, can receive all messages. The first response object is also bound to the Controller to facilitate the Controller to find the response object and forward the message. Specifically, all events transmitted by the view element layer 402 are first received by the first response object.
[0063] According to one embodiment of the present application, the current business scenario corresponds to two response objects. After setting the first response object, it is necessary to link other response objects for the first response object according to the first business scenario. Therefore, it is also necessary to link the second response object for the first response object to obtain the first protocol chain. Specifically, the second response object does not need to respond to all methods in the first protocol like the first response object. The second response object only needs to respond to a specified method in the first protocol. During the communication process, the user end sends the first instruction, the first response object receives the event first, and then the second response object receives the event.
[0064] According to another embodiment of the present application, different operations on the view page correspond to different business scenarios, and the protocol chains involved in different business scenarios are not the same, and the specified protocols, the response objects involved, and the number of response objects are also different. The present application does not limit the specified protocols, the response objects involved, and the number of response objects. Specifically, if the current business scenario involves five response objects, then after linking the second response object to the first response object, it is necessary to link the fourth response object to the second response object, link the fifth response object to the fourth response object, and link the sixth response object to the fifth response object, until all response objects are linked, the protocol chain corresponding to the current business scenario can be constructed. Specifically, some complex view pages may include multiple business scenarios and also involve multiple protocol chains, that is, the Controller is bound to multiple protocol chains at the same time, but at the same time, only one protocol chain is active. When the user operates on the view page, it is inevitable that the message forwarding of the protocol chain is involved. The protocol chain that is processing the message forwarding is the active protocol chain.
[0065] It should be noted that, as the core controller in the business scenario, the Controller can obtain the data of any operation node and complete the binding of the view element layer 402 and the logic layer 403. This application sets the logic layer 403 as the agent of the view element layer 402, and sets a response object in the logic layer 403 to forward and process the information involved in the current business scenario, so that the specific business logic is completed in the logic layer 403, which reduces the work of the Controller and facilitates the operator to maintain the system.
[0066] On the other hand, the traditional communication framework is a tree structure. Message nodes at the same level in the tree structure cannot receive the same event. The Controller needs to forward the event layer by layer to the first response object, and then the first response object needs to pass it back to the Controller layer by layer. At this time, the Controller needs to forward the event layer by layer to the second response object again. Specifically, the communication methods of the tree structure include brother communication and grandson communication. In brother communication, the message needs to be passed to the common parent class, and then forwarded in the parent class. In grandson communication, the message needs to be passed back to the parent class, and then the parent class passes the message back to the parent class of the parent class, and forwarded layer by layer. More specifically, in the process of layer-by-layer data transmission in the tree structure, if the data model needs to be modified, all proxy nodes on the entire link need to be modified, which greatly damages the closedness of the code and increases the complexity.
[0067] Based on the traditional tree structure, this application improves the framework into a single linked list chain structure. As long as it is a message node on the protocol chain, it can directly receive the message without going through the process of forwarding the message layer by layer. In the tree structure, the first response object needs to go through multiple layer-by-layer return processes to forward the message to the second response object. When using a chain structure, it is only necessary to link the second response object to the first response object to realize the direct sending of the message from the first response object to the second response object. This not only simplifies the message transmission process, but also reduces the coupling of the code and improves the reusability of the code.
[0068] It can be understood that linking the second response object to the first response object according to the first business scenario also includes: specifying the acquisition method of the first protocol, distributing the acquisition method to the second response object, so that the second response object responds to the acquisition method to perform an information acquisition operation.
[0069] It should be noted that the first response object can respond to all methods in the protocol, while the second response object and other response objects subsequently linked to the first response object can only respond to methods specified in the protocol. Therefore, it is not necessary to distribute methods for the first response object. When linking the second response object to the first response object, it is also necessary to specify the acquisition method in the first protocol and distribute the acquisition method to the second response object so that the second response object can respond to the acquisition method and perform the information acquisition operation. Specifically, the distribution method operation and the link response object operation are performed simultaneously, and the response object can perform a fixed operation based on the distributed method.
[0070] According to one embodiment of the present application, when a user performs a login operation on a view page, the view element layer 402 transmits a first instruction to a first response object. The first response object bears the responsibility of a message receiver and forwards the information to a second response object. The second response object performs an information acquisition operation according to the acquisition method in the specified first protocol to obtain information such as the account password and verification code entered by the user, and forwards the current information to the next node that needs to perform related operations.
[0071] On the other hand, different business scenarios involve different protocols, and the methods contained in the protocols are also different. Because the first response object can implement all methods in the protocol, the operation performed by the first response object is not unique in the actual application scenario, that is, the first response object can perform a receiving operation according to the specified protocol, or perform a verification operation according to the specified protocol, or perform a calling operation according to the specified protocol. At the same time, the operation performed by the second response object in different protocols is not fixed. Even in different business scenarios but the same protocol, the operation performed by the second response object is not fixed. The second response object can perform an acquisition method according to the acquisition method distributed by the current protocol, or perform a verification operation according to the verification method distributed by the current protocol. This application does not make specific restrictions on the operations performed by the first response object, the second response object, and all response objects linked in the subsequent construction process.
[0072] It can be understood that linking the second response object to the first response object according to the first business scenario also includes: linking a new response object to the second response object at the end of the current protocol chain according to the first business scenario; specifying the verification method of the first protocol, and distributing the verification method to the newly added response object, so that the newly added response object responds to the verification method to perform the verification operation; until all operations included in the first business scenario are executed.
[0073] It should be noted that most business scenarios involve multiple message nodes, so it is necessary to link multiple response objects. After linking the second response object for the first response object, it is also necessary to link a new response object for the second response object at the end of the current protocol chain according to the first business scenario, and at the same time specify the verification method in the first protocol, distribute the verification method to the newly added response object, so that the newly added response object performs the verification operation according to the verification method. Specifically, this application does not make specific restrictions on the operations performed by the newly added response object. The newly added response object can perform a verification operation in response to the verification method specified in the specified protocol, or it can perform a call operation in response to the call method specified in the specified protocol.
[0074] According to one embodiment of the present application, the first business scenario includes multiple operations, that is, involves multiple message nodes and requires multiple response objects. Therefore, until all operations included in the first business scenario are executed, it is necessary to continuously link the response objects and distribute the corresponding methods. If the current business scenario involves five response objects, then after linking the second response object to the first response object, it is necessary to link the fourth response object to the second response object, link the fifth response object to the fourth response object, and link the sixth response object to the fifth response object, until all response objects are linked, the protocol chain corresponding to the current business scenario can be constructed.
[0075] It can be understood that linking the first response object to the second response object according to the first business scenario to obtain the first protocol chain includes: calling a close operation instruction so that the response object at the end of the current protocol chain stops linking other response objects to obtain the first protocol chain.
[0076] It should be noted that after all operations included in the first business scenario are executed, a close operation instruction needs to be called so that the response object at the end of the current protocol chain stops linking operations of other response objects, forming a complete protocol chain, namely the first protocol chain. Specifically, the construction of the protocol chain of this application belongs to the underlying implementation, and the user does not need to manually construct a chain structure. The user only needs to call the three instructions of bind, link, and close.
[0077] According to an embodiment of the present application, the present application first uses the view.delegate=viewModel instruction to set the logic layer 403 as the agent of the view element layer 402. The events belonging to the view element layer 402 will be passed to the logic layer 403 for processing, which reduces the burden on the Controller; secondly, the first response object is set through the bind(Protocol,viewModel1) instruction, and the first response object is bound to the first protocol, where viewModel1 is the first response object of this protocol chain, and all events issued by View are received by viewModel1 first; then the second response object is linked to the first response object through link(Selector1,viewModel2), where viewModel2 represents the second response object. This instruction indicates that viewModel2 can receive the specific event Selector1 in the protocol Protocol. When the view element layer 402 issues an event Se lector1, ViewModel1 receives the event first, and then ViewModel2 receives the event; then the fourth response object is linked through the link(Selector1,viewModel4) instruction, where viewModel4 represents the fourth response object. This instruction indicates that viewModel4 can receive the specific event Selector1 in the protocol Protocol. When the view element layer 402 sends the event Selector1, ViewModel1 receives the event first, and then ViewModel2 receives the event, followed by viewModel4 receiving the event. In this way, more objects can be linked, and events can be sent to any object under the Controller; finally, after linking all the response objects required by the current business scenario, the close() instruction needs to be called to close the protocol chain structure to indicate that the response chain construction is completed, and no operations can be performed after close.
[0078] Please refer to Figure 2 , Figure 2 This is another sub-flowchart of the protocol chain construction method provided in the embodiment of the present application. Figure 2 The method may include but is not limited to steps S210 to S220.
[0079] Step S210: Notify the data model layer 401 to perform an update operation according to the first protocol chain, and enable the data model layer 401 to feedback completion information after completing the update operation;
[0080] Step S220 : Notifying the view element layer 402 to perform an interface update operation according to the completion information.
[0081] According to one embodiment of the present application, the view element layer 402 passes the user's click event to the logic layer 403. After the logic layer 403 completes the construction of the protocol chain according to the click event, it also needs to send the relevant data to the data model layer 401 to notify the data model layer 401 to perform the data update operation. When the data model layer 401 completes the data update operation, it will feedback the completion information to the logic layer 403, so that the logic layer 403 obtains the information that the data model layer 401 has completed the update. After obtaining the completion information, the logic layer 403 will notify the view element layer 402 to perform the page update operation, so that the view element layer 402 completes the interface refresh according to the updated data. In this process, the logic layer 403 plays the role of an agent.
[0082] According to another embodiment of the present application, a conventional login module includes a login interface, a registration interface, and a password modification interface. The present application uses the data flow and event flow in the login interface to illustrate the login process. A common login interface includes elements such as an account input box, a password input box, a verification code input box, a verification code acquisition button, and a login button. At this point, the protocol chain has been constructed. When the user clicks on a button on the login interface, the view element layer 402 first transmits the user's click event to the logic layer 403. The logic layer 403 will notify the data model layer 401 so that the data model layer 401 completes the data update. After the data model layer 401 completes the data update, it will feed back the completion information to the logic layer 403, so that the logic layer 403 notifies the view element layer 402 to execute the refresh of the current login interface after receiving the feedback information.
[0083] According to another embodiment of the present application, the login interface is divided into three parts: the first view element is an input box view, the second view element is a button view, and the third view element is a prompt view. Because the logic layer 403 in the present application is a proxy of the view element layer 402, each view element in the view element layer 402 corresponds to a response object in the logic layer 403. In an actual scenario, the user enters an account number in the login interface. At this time, the protocol chain contains a first response object and a fourth response object. The first response object corresponds to the first view element, and the fourth response object corresponds to the third view element. The first response object is linked to the fourth response object. The first response object performs a storage operation to store the account information entered by the user in the memory through the protocol. The fourth response object performs a verification operation to locally verify the legitimacy of the input, such as a specific prefix of the mobile phone number, pure data, or 11-digit related verification. If the data entered by the user is incorrect, the fourth response object will send an error message, causing the third view element to prompt the user with the corresponding account error information.
[0084] When the user enters a password in the login interface, the first response object performs a storage operation, and stores the password information entered by the user in the memory through the protocol. The fourth response object performs a verification operation, and locally verifies whether the password corresponding to the account is correct. If the password entered by the user is incorrect, the fourth response object will send an error message, so that the third view element prompts the user with the corresponding password error information.
[0085] When the user clicks to obtain the verification code, the protocol chain includes a second response object. The second response object corresponds to the second view element. When the user clicks to obtain the verification code, the second response object will notify the network layer to initiate a request to obtain the verification code, and send the verification code to the mobile phone number entered by the user through the terminal background. At the same time, the second response object will notify the second view element to remain unclickable within 60 seconds.
[0086] When the user enters the verification code, the protocol chain includes the first response object and the fourth response object. The first response object and the fourth response object are linked. The first response object performs a storage operation to store the verification code information entered by the user in the memory through the protocol. The fourth response object performs a verification operation to locally verify whether the verification code sent by the background is correct. If the verification code entered by the user is incorrect, the fourth response object will send an error message, so that the third view element prompts the user with the corresponding verification code error information.
[0087] When a user clicks "Login," the protocol chain includes the first, second, and fourth response objects. If the user enters the correct account, password, and verification code, the second response object notifies the network layer to initiate a login request. The fourth response object, linked to the second response object, sends a prompt message to the third view element, prompting the user to wait for login. After the user successfully logs in, the first response object, linked to the fourth response object, stores and clears the data in the input box. At the same time, the fourth response object sends a login success message to the third view element, prompting the user to log in successfully. If the user fails to log in, the fourth response object sends specific information about the user's login failure to the third view element, prompting the user to be notified.
[0088] Please refer to Figure 3 , Figure 3 This is another sub-flowchart of the protocol chain construction method provided in the embodiment of the present application. Figure 3 The method may include but is not limited to steps S310 to S330.
[0089] Step S310: When the user terminal sends a second instruction, specify a second protocol according to a second business scenario corresponding to the second instruction;
[0090] Step S320: setting a third response object within the logic layer 403 according to the second protocol, and binding the third response object to the second protocol;
[0091] Step S330: Link response objects to the third response object one by one according to the second business scenario until all operations included in the second business scenario are executed, thereby obtaining a second protocol chain.
[0092] It should be noted that the construction method of the protocol chain of the present application can be applied to multiple different business scenarios. Operators need to construct different protocol chains for different business scenarios. When operators need to develop for the second business scenario, they first need to send a second instruction to the core controller Controller of the protocol chain in combination with the second business scenario. The Controller receives the second instruction and specifies the second protocol according to the second business scenario corresponding to the second instruction. After the Controller specifies the second protocol according to the second business scenario, it is also necessary to set a third response object in the logic layer 403 according to the second protocol, and the third response object is bound to the second protocol. The third response object can implement all methods in the second protocol. The current second business scenario corresponds to multiple response objects. After setting the third response object, it is also necessary to link other response objects to the third response object according to the second business scenario. Therefore, it is also necessary to link multiple response objects to the third response object in sequence until all operations included in the second business scenario are executed and the second protocol chain is obtained.
[0093] It can be understood that the construction method of the protocol chain of the present application also includes: declaring asynchronous callback instructions in combination with the specified protocol, so that the logic layer 403 can realize information transmission in all business scenarios through function pointer calls.
[0094] It should be noted that the view element layer 402, as an object, also needs to update the view. This application can also link the view element layer 402 to the protocol chain to respond to other view element layer 402 operations. The protocol chain itself has nothing to do with the asynchronous callback instruction block, but the asynchronous callback instruction block can be declared in the protocol specified by the protocol chain. Block is another technical means provided by the system. It does not transmit information through the message forwarding mechanism, but transmits information through function pointer calls. Specifically, block is a closure that can capture context. The implementation of the block and the call itself can be separated. The implementation of the block can be inside the view element layer 402, allowing the call of the block to be in any business code of the logic layer 403, reducing the use of notifications and allowing messages to be passed directly from the logic layer 403 to the view element layer 402.
[0095] Please refer to Figure 5 , Figure 54 is a schematic diagram of the structure of the protocol chain construction device provided by an embodiment of the present application. The above-mentioned protocol chain construction method can be implemented by introducing a two-way binding framework. The two-way binding framework includes a data model layer 401, a view element layer 402, and a logic layer 403. The logic layer 403 is set as a proxy of the view element layer 402. The protocol chain construction device of the present application includes:
[0096] The control module 501 is configured to receive a first instruction sent by a user terminal and specify a first protocol according to a first business scenario corresponding to the first instruction, wherein the first protocol is used to define an event type transmitted by the view element layer 402 in the first business scenario;
[0097] A binding module 502 is configured to set a first response object in the logic layer 403 according to the first protocol, and the first response object is bound to the first protocol;
[0098] The linking module 503 is configured to link the first response object to the second response object according to the first business scenario to obtain a first protocol chain.
[0099] According to one embodiment of the present application, the apparatus for constructing a protocol chain includes a control module 501, a binding module 502, and a linking module 503. During the actual development process, the operator first needs to send a first instruction to the protocol chain control module 501 based on the business scenario being developed. The control module 501 receives the first instruction and specifies a first protocol based on the first business scenario corresponding to the first instruction. User events are transmitted from the view element layer 402. Because the present application sets the logic layer 403 as a proxy for the view element layer 402, multiple response objects need to be set up within the logic layer 403 to receive events transmitted by the view element layer 402. After the control module 501 specifies the first protocol based on the first business scenario, the binding module 502 sets a first response object in the logic layer 403 based on the first protocol. The first response object is bound to the first protocol and can respond to all methods in the first protocol. After the binding module 502 completes the binding operation, it is necessary to link the first response object to other response objects based on the first business scenario. Therefore, the linking module 503 is required to link the first response object to a second response object to form the first protocol chain. Specifically, when facing a complex business scenario, there are multiple response objects. The link module 503 can also link the second response object to the fourth response object, and link the fourth response object to the fifth response object. This application does not impose specific restrictions on this.
[0100] The specific implementation of the protocol chain construction device is basically the same as the specific embodiment of the protocol chain construction method described above, and will not be repeated here.
[0101] The present application also provides an electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned protocol chain construction method when executing the computer program. The electronic device can be any smart terminal including a tablet computer, an in-vehicle computer, or the like.
[0102] See also Figure 6 , Figure 6 The hardware structure of an electronic device according to another embodiment is shown. The electronic device includes:
[0103] The processor 601 may be implemented as a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application.
[0104] The memory 602 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 602 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 602, and the processor 601 calls and executes the construction method of the protocol chain in the embodiments of this application;
[0105] Input / output interface 603, used to implement information input and output;
[0106] Communication interface 604, used to implement communication interaction between this device and other devices, which can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WiFi, Bluetooth, etc.);
[0107] Bus 605 , which transmits information between various components of the device (e.g., processor 601 , memory 602 , input / output interface 603 , and communication interface 604 );
[0108] The processor 601 , the memory 602 , the input / output interface 603 and the communication interface 604 are connected to each other in communication within the device via a bus 605 .
[0109] An embodiment of the present application further provides a storage medium, which is a computer-readable storage medium and stores a computer program. When the computer program is executed by a processor, the method for constructing the above-mentioned protocol chain is implemented.
[0110] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0111] The protocol chain construction method, apparatus, device and storage medium proposed in this application are based on a two-way binding framework, and the logic layer 403 is set as the agent of the view element layer 402, thereby reducing the burden on the view element layer 402 and the control layer. At the same time, on this basis, this application can receive the first instruction sent by the user and gradually construct the first protocol chain according to the first instruction, so that each node can achieve rapid communication through the first protocol chain, without the need to construct a layer-by-layer forwarding link with the controller as the central node, thereby simplifying the work of the controller and facilitating the maintenance of the system.
[0112] The embodiments described in the embodiments of this application are intended to more clearly illustrate the technical solutions of the embodiments of this application and do not constitute a limitation on the technical solutions provided by the embodiments of this application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0113] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0114] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, i.e., they may be located in one place or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of this embodiment.
[0115] Those skilled in the art will appreciate that all or some of the steps in the methods, systems, and functional modules / units in the devices disclosed above may be implemented as software, firmware, hardware, or appropriate combinations thereof.
[0116] The terms "first", "second", "third", "fourth", etc. (if any) in the specification 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 sequential order. 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 those illustrated or described herein. In addition, the terms "including" and "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 clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0117] It should be understood that in this application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0118] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the above-mentioned units is only a logical function division. In actual implementation, there may be other division methods, such as 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 interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0119] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0120] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0121] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes multiple instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: various media that can store programs, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0122] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but are not intended to limit the scope of the present invention. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and essence of the present invention should be within the scope of the present invention.
Claims
1. A method for constructing a protocol chain, characterized in that: Applied to a two-way binding framework, the two-way binding framework includes a data model layer, a view element layer, and a logic layer, and the logic layer is set as a proxy of the view element layer. The method includes: receiving a first instruction sent by a user terminal, and specifying a first protocol according to a first business scenario corresponding to the first instruction, wherein the first protocol is used to define an event type transmitted by the view element layer in the first business scenario; Setting a first response object at the logic layer according to the first protocol, wherein the first response object is bound to the first protocol; The first response object is linked to a second response object according to the first business scenario to obtain a first protocol chain.
2. The method for constructing a protocol chain according to claim 1, wherein: The linking of the first response object to the second response object according to the first business scenario further includes: An acquisition method of the first protocol is specified, and the acquisition method is distributed to the second response object, so that the second response object responds to the acquisition method to perform an information acquisition operation.
3. The method for constructing a protocol chain according to claim 2, wherein: The linking of the first response object to the second response object according to the first business scenario further includes: According to the first business scenario, a new response object is added to the second response object link at the end of the current protocol chain; the verification method of the first protocol is specified, and the verification method is distributed to the newly added response object, so that the newly added response object responds to the verification method to perform a verification operation; until all operations included in the first business scenario are completed.
4. The method for constructing a protocol chain according to claim 3, wherein: The linking the first response object to the second response object according to the first business scenario to obtain a first protocol chain includes: The close operation instruction is called to make the response object at the end of the current protocol chain stop linking to other response objects, thereby obtaining the first protocol chain.
5. The method for constructing a protocol chain according to claim 4, characterized in that: The method further comprises: Notifying the data model layer to perform an update operation according to the first protocol chain, and causing the data model layer to feedback completion information after completing the update operation; The view element layer is notified according to the completion information to perform an interface update operation.
6. The method for constructing a protocol chain according to claim 1, wherein: The method further comprises: When the user terminal sends the second instruction, specifying the second protocol according to the second business scenario corresponding to the second instruction; Setting a third response object within the logic layer according to the second protocol, and binding the third response object to the second protocol; According to the second business scenario, response objects are linked to the third response object one by one until all operations included in the second business scenario are executed, thereby obtaining a second protocol chain.
7. The method for constructing a protocol chain according to claim 1, wherein: The method further comprises: The asynchronous callback instruction is declared in combination with the specified protocol, so that the logic layer can realize information transmission in all business scenarios through function pointer calls.
8. A device for constructing a protocol chain, characterized in that: A two-way binding framework is introduced, which includes a data model layer, a view element layer, and a logic layer. The logic layer is set as a proxy of the view element layer. The device includes: a control module, configured to receive a first instruction sent by a user terminal, and specify a first protocol according to a first business scenario corresponding to the first instruction, wherein the first protocol is used to define an event type transmitted by the view element layer in the first business scenario; a binding module, configured to set a first response object at the logic layer according to the first protocol, wherein the first response object is bound to the first protocol; A linking module is used to link the first response object to the second response object according to the first business scenario to obtain a first protocol chain.
9. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the protocol chain construction method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for constructing a protocol chain according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
System and method for storing contract data structures on permissioned distributed ledgers
CA3061603A1
Techniques to generate a graph model for cloud infrastructure elements
CN107005454A