Data transmission method, device, equipment and medium

By converting the WebSocket request of the probe into Http information, the problem that the probe management end based on the Http protocol is difficult to meet the high real-time requirements, achieving efficient and real-time data transmission and reducing the difficulty of system maintenance.

CN118316914BActive Publication Date: 2025-03-04BEIJING YUANYUAN SHUAN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410322431.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-20
Publication Date
2025-03-04
Estimated Expiration
2044-03-20

AI Technical Summary

Technical Problem

The existing probe management side's back-end services based on the Http protocol are difficult to meet the needs of high real-time, resulting in the probes that need to frequently poll the management side to obtain configuration information, which is inefficient and wastes resources.

Method used

By converting the WebSocket request of the probe into Http information without losslessly, the protocol advantages of WebSocket are compatible with the Http protocol and are uniformly processed by a single program, thereby real-time data transmission and reducing the difficulty of system maintenance.

Benefits of technology

It improves the performance and real-time performance of data transmission, avoids the problem of maintaining two sets of interfaces, and reduces the difficulty of system maintenance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118316914B_ABST
    Figure CN118316914B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a data transmission method, device, system, equipment and medium. The method includes: receiving a WebSocket message request, instantiating the WebSocket message request into an object to obtain a first object; parsing the WebSocket message request based on a custom message format, obtaining the api information and request parameter information included in the WebSocket message request; assigning the api information and request parameter information objects to the fields of the first object; querying a preset hash table through the api field in the segment of the first object, obtaining the Http interface method corresponding to the WebSocket request and the class instance where the Http interface method is located; calling the instance of the class where the Http interface method corresponding to the WebSocket request is located by reflection, and processing the WebSocket message data through the Http interface. The data transmission method of the present application improves performance while being compatible with the old Http interface, and also avoids the problem of maintaining two sets of interfaces, reducing the difficulty of system maintenance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of database technology, and in particular to a data transmission method, device, equipment and medium. Background Art

[0002] Probe management requires two-way communication. On the one hand, the probe needs to report status information to the management end, and on the other hand, the management end also needs to send configuration information to the probe. Due to the wide application of Http, there are many types of web-type backend service development frameworks and rich components, so the development efficiency of web-type servers is very high. Conventional probe management ends adopt the form of web services. However, backend services based on web servers are usually connected to the Http protocol. Http is an interactive protocol based on the "request-response" form. Due to its half-duplex characteristics, it is difficult to adapt to high real-time requirements. When the probe management end needs to actively initiate configuration instructions to the probe, it must also wait for the Http request initiated by the probe to the management end before sending the configuration instruction information to the probe through the Http response. As a result, the probe needs to periodically and frequently initiate requests to the management end to ensure that the configuration information can be obtained in time. However, this method of periodically polling the management end with Http requests is very inefficient, not only wasting CPU resources, but also wasting network bandwidth.

[0003] In order to solve the timeliness problem, the backend service based on the web server is connected to the WebSocket protocol. The WebSocket protocol is a full-duplex binary protocol. The biggest feature of it, unlike Http, is that it is not limited by the "request-response" mode, so it can send data in real time. Therefore, WebSocket is increasingly replacing the Http protocol.

[0004] However, once the probe is deployed to the target environment, it is difficult to replace and upgrade the program in order not to affect the target environment. The old probe uses the Http protocol. If the newly developed probe uses the WebSocket protocol, it is necessary to develop another set of WebSocket-based back-end management programs, which cannot be integrated with the original Http-based back-end management programs, increasing the difficulty of maintenance. Summary of the invention

[0005] In order to solve the above technical problems, the present invention provides a data transmission method, device, equipment and medium, which losslessly converts the probe WebSocket request into Http information, which is uniformly processed by one program, thereby utilizing the protocol advantages of WebSocket and being compatible with the Http protocol, reducing the difficulty of system maintenance.

[0006] In a first aspect, the present disclosure provides a data transmission method, comprising:

[0007] Receive a WebSocket message request, wherein the WebSocket message is organized based on a custom message format, wherein the custom message format is equivalent to the Http message format and includes necessary information elements of the Http protocol;

[0008] Instantiate the WebSocket message request into an object to obtain a first object;

[0009] Parsing the WebSocket message request based on the custom message format to obtain API information and request parameter information included in the WebSocket message request, wherein the API information corresponds to the URI information of Http, and the request parameter information is completely consistent with the parameter name of the Http interface method;

[0010] Assign the API information and request parameter information objects to the fields of the first object;

[0011] A preset hash table is queried through the api field in the segment of the first object to obtain the Http interface method corresponding to the WebSocket request and the class instance where the Http interface method is located, wherein the hash key of the preset hash table is the uri of the Http interface method, the hash value is the Http interface method and the instance of the class where the Http interface method is located, and the uri of the Http interface method is obtained by scanning the annotation;

[0012] The instance of the class where the Http interface method corresponding to the WebSocket request is located is called by reflection, and the WebSocket message data is processed through the Http interface.

[0013] Furthermore, the custom message format at least includes: a message header Head and a message body Body;

[0014] The message header Head includes at least a fixed magic for checking the starting boundary of the message; the total length of the data; the header length; at least one option, each option including the option name length, option name, option value length, and option value; the name of the first option is api.

[0015] Furthermore, the method further comprises:

[0016] The request parameter information is set in the option of the message header Head, where the option name is the parameter name of the Http interface method;

[0017] Alternatively, the request parameter information is set in the message body, and the options of the message header include the format information of the message body.

[0018] Further, the parsing of the WebSocket message request based on the custom message format to obtain the API information and request parameter information included in the WebSocket message request includes:

[0019] Parsing the WebSocket message request based on the custom message format, and obtaining the API information from the message header;

[0020] Analyze whether the request parameter information exists in the option information of the message header;

[0021] If the option information is in the message header Head, the request parameter information is obtained from the parameter name of the Http interface method in the option name;

[0022] If it is not in the option information of the message header Head, the request parameter information is obtained from the message body Body.

[0023] Furthermore, the method further comprises:

[0024] Obtain the Http interface method, the URI of the Http interface method, and the instance of the class where the Http interface method is located based on the custom annotation and the return call method;

[0025] The preset hash table is constructed based on the Http interface method, the URI of the Http interface method and the instance of the class where the Http interface method belongs.

[0026] Furthermore, the method of obtaining the Http interface method, the URI of the Http interface method, and the instance of the class where the Http interface method is located based on the custom annotation and the return call method includes:

[0027] Dynamically scan classes containing custom annotations, where the custom annotation is @WsAdapter;

[0028] If the class containing the custom annotation is scanned, the method with the @RequestMapping annotation in the class is obtained by reflection;

[0029] Parse the method annotated with @RequestMapping to obtain the Http interface method, the URI of the Http interface method, and the instance of the class where the Http interface method is located.

[0030] Furthermore, the method also includes:

[0031] Add a custom annotation @WsAdapter to the definition of all Http controller classes.

[0032] In a second aspect, the present disclosure provides a data transmission device, including:

[0033] A receiving unit, configured to receive a WebSocket message request, wherein the WebSocket message is organized based on a custom message format, wherein the custom message format is equivalent to the Http message format and includes information elements necessary for the Http protocol;

[0034] An instantiation unit, configured to instantiate the WebSocket message request into an object to obtain a first object;

[0035] A parsing unit, configured to parse the WebSocket message request based on the custom message format, and obtain the API information and request parameter information included in the WebSocket message request, wherein the API information corresponds to the URI information of Http, and the request parameter information is completely consistent with the parameter name of the Http interface method;

[0036] An assignment unit, used for assigning the API information and request parameter information objects to the fields of the first object;

[0037] A first acquisition unit is used to query a preset hash table through the api field in the segment of the first object to obtain the Http interface method corresponding to the WebSocket request and the class instance of the Http interface method, wherein the hash key of the preset hash table is the uri of the Http interface method, the hash value is the Http interface method and the instance of the class of the Http interface method, and the uri of the Http interface method is obtained by scanning the annotation;

[0038] The data transmission unit is used to call the instance of the class where the Http interface method corresponding to the WebSocket request is located by reflection, and process the WebSocket message data through the Http interface.

[0039] In a third aspect, an embodiment of the present disclosure further provides an electronic device, including:

[0040] processor;

[0041] A memory for storing executable instructions;

[0042] The processor is used to read executable instructions from the memory and execute the executable instructions to implement the data transmission method of the first aspect.

[0043] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, wherein the storage medium stores a computer program. When the computer program is executed by a processor, the processor implements the data transmission method of the first aspect.

[0044] Compared with the prior art, the technical solution provided by the embodiment of the present disclosure has the following advantages: in the embodiment of the present application, a WebSocket message request is received, the WebSocket message is organized based on a custom message format, the custom message format is equivalent to the Http message format, and includes the necessary information elements of the Http protocol; the WebSocket message request is instantiated as an object to obtain a first object; the WebSocket message request is parsed based on the custom message format to obtain the api information and request parameter information included in the WebSocket message request, the api information corresponds to the Http uri information, and the request parameter information corresponds to the parameters of the Http interface method The name is completely consistent; the api information and request parameter information object are assigned to the field of the first object; the preset hash table is queried through the api field in the segment of the first object to obtain the Http interface method corresponding to the WebSocket request and the class instance where the Http interface method is located, the hash key of the preset hash table is the uri of the Http interface method, the hash value is the Http interface method and the instance of the class where the Http interface method is located, and the uri of the Http interface method is obtained by scanning annotations; the instance of the class where the Http interface method corresponding to the WebSocket request is located is called by reflection, and the WebSocket message data is processed through the Http interface. Compared with the prior art, based on the WebSocket message format, WebSocket messages can be converted into Http information without loss; and through custom annotations and reflection, the instance of the class where the Http interface method corresponding to the WebSocket request is located is dynamically called, and the WebSocket message data is processed through the Http interface, thereby realizing the lossless conversion of the probe WebSocket request into Http information, which is uniformly processed by one program, that is, the protocol advantages of WebSocket are utilized and it is compatible with the Http protocol. The data transmission method of the present application improves performance while being compatible with the old Http interface, and also avoids the problem of needing to maintain two sets of interfaces, thereby reducing the difficulty of system maintenance. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0046] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0047] Figure 1 A flowchart of a data transmission method provided by an embodiment of the present disclosure;

[0048] Figure 2 A flowchart of a data transmission method provided by an embodiment of the present disclosure;

[0049] Figure 3 A schematic diagram of a data transmission principle provided by an embodiment of the present disclosure;

[0050] Figure 4 A flowchart of a data transmission method provided by an embodiment of the present disclosure;

[0051] Figure 5 A block diagram of a data transmission device provided by an embodiment of the present disclosure;

[0052] Figure 6 A block diagram of another data transmission device provided by an embodiment of the present disclosure;

[0053] Figure 7 A schematic diagram of the hardware circuit structure of a data transmission device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0054] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.

[0055] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0056] In order to solve the above problems, the embodiments of the present disclosure provide a data transmission method, device, equipment, medium and vehicle.

[0057] Figure 1 The flowchart of a data transmission method provided by an embodiment of the present disclosure can be specifically performed by a data transmission device, wherein the data transmission device can be implemented by software and / or hardware, and can generally be integrated in an electronic device, and the data transmission device and / or electronic device can be configured in a vehicle. Figure 1 As shown, the data transmission method includes:

[0058] Step 101, receiving a WebSocket message request, wherein the WebSocket message is organized based on a custom message format, and the custom message format is equivalent to the Http message format and includes necessary information elements of the Http protocol.

[0059] It should be noted that the embodiment of the present application is based on the WebSocket custom load protocol message. When the newly developed probe uses the WebSocket protocol to interact with the probe management end, it is necessary to follow the format of the message to organize the data and send it to the management end through WebSocket. The message format is equivalent to the Http message information, and the necessary information elements of the Http protocol can be expressed through the custom message. All probes that use the WebSocket protocol to interact with the management end use this format to report.

[0060] Step 102: instantiate the WebSocket message request into an object to obtain a first object.

[0061] It should be noted here in this embodiment that, during the program running phase, a WebSocket message request is processed. When a WebSocket message request is received, it is firstly instantiated to obtain a first object, such as a pojo object (Plain Ordinary Java Object).

[0062] Step 103: Parse the WebSocket message request based on the custom message format to obtain application programming interface (API) information and request parameter information included in the WebSocket message request, wherein the api information corresponds to the uniform resource identifier (URI) information of Http, and the request parameter information is completely consistent with the parameter name of the Http interface method.

[0063] It should be noted here in this embodiment that the api information and the request parameter information are stored in different places. Based on the different storage methods, the WebSocket message request is parsed and the corresponding api information and request parameter information are read from the corresponding setting location.

[0064] Step 104: assign the API information and request parameter information objects to the fields of the first object.

[0065] In this embodiment, the acquired API information and request parameter information are assigned to the fields of the created object, such as the fields of the POJO object, so that the POJO object contains the API information field and the request parameter information field.

[0066] Step 105: query a preset hash table through the api field in the segment of the first object to obtain the Http interface method corresponding to the WebSocket request and the class instance of the Http interface method, wherein the hash key of the preset hash table is the uri of the Http interface method, and the hash value is the Http interface method and the instance of the class of the Http interface method, and the uri of the Http interface method is obtained by scanning the annotation.

[0067] Step 106: Invoke the instance of the class where the Http interface method corresponding to the WebSocket request is located by reflection, and process the WebSocket message data through the Http interface.

[0068] In an embodiment of the present application, a WebSocket message request is received, wherein the WebSocket message is organized based on a custom message format, wherein the custom message format is equivalent to the Http message format and includes information elements necessary for the Http protocol; the WebSocket message request is instantiated as an object to obtain a first object; the WebSocket message request is parsed based on the custom message format to obtain api information and request parameter information included in the WebSocket message request, wherein the api information corresponds to the Http uri information, and the request parameter information is completely consistent with the parameter name of the Http interface method; the api information and request parameter information objects are assigned to a field of the first object; a preset hash table is queried through the api field in the segment of the first object to obtain the Http interface method corresponding to the WebSocket request and the class instance where the Http interface method is located, wherein the hash key of the preset hash table is the uri of the Http interface method, and the hash value is the instance of the Http interface method and the class where the Http interface method is located, and the uri of the Http interface method is obtained by scanning annotations; the instance of the class where the Http interface method corresponding to the WebSocket request is located is called through reflection, and the WebSocket message data is processed through the Http interface. Compared with the prior art, based on the WebSocket message format, WebSocket messages can be converted into Http information without loss; and through custom annotations and reflection, the instance of the class where the Http interface method corresponding to the WebSocket request is located is dynamically called, and the WebSocket message data is processed through the Http interface, thereby realizing the lossless conversion of the probe WebSocket request into Http information, which is uniformly processed by one program, that is, the protocol advantages of WebSocket are utilized and it is compatible with the Http protocol. The data transmission method of the present application improves performance while being compatible with the old Http interface, and also avoids the problem of needing to maintain two sets of interfaces, thereby reducing the difficulty of system maintenance.

[0069] Furthermore, it should be noted that the above-mentioned embodiments of the present disclosure are equivalent to the Http message information, including the necessary information elements of the Http protocol. The format simulates the structure of the Http request, including at least: a message header Head and a message body Body.

[0070] The message header Head includes at least a fixed magic for checking the starting boundary of the message; the total length of the data; the header length; at least one option, each option including the option name length, option name, option value length, and option value; the name of the first option is api.

[0071] As shown in Table 1, the custom message format is shown in the following table:

[0072]

[0073] This application needs to explain that in the header of all WebSocket requests, the name of the first option must be "api". This option is used to express the "Uniform Resource Identifier (URI) of the Http request" corresponding to the Http protocol. Therefore, the option value is filled in with the fixed uri of the corresponding Http protocol. This application uses this information to determine the interface uri corresponding to the Http backend service.

[0074] Furthermore, the request parameter information shown above can be set in the options of the message header Head based on the custom message format, and the option name is the parameter name of the Http interface method; or, the request parameter information can be set in the message body Body, and the options of the message header Head contain the format information of the message body Body. No matter where it is placed, it needs to be completely consistent with the parameter name of the Http interface method. When placed in the options, the key of the options is the method parameter name. When placed in the Body, in order to correctly parse the request parameters, the options must contain the format information of the Body - "Ws-Content-Type": "Parameter format" - currently there are 4 formats supported, namely json, yml, properties, and binary (binary type does not require a parameter name).

[0075] Based on the storage location of the request parameter information, the WebSocket message request is parsed based on the custom message format to obtain the API information and request parameter information included in the WebSocket message request, which can be implemented by but not limited to the following method, including:

[0076] Parsing the WebSocket message request based on the custom message format, and obtaining the API information from the message header;

[0077] Analyze whether the request parameter information exists in the option information of the message header;

[0078] If the option information is in the message header Head, the request parameter information is obtained from the parameter name of the Http interface method in the option name;

[0079] If it is not in the option information of the message header Head, the request parameter information is obtained from the message body Body.

[0080] Furthermore, after the WebSocket message is losslessly converted into Http information, the present embodiment needs to transmit data through the Http interface. When transmitting data, it is necessary to obtain the api field in the segment of the first object to query the preset hash table, obtain the Http interface method corresponding to the WebSocket request and the class instance of the Http interface method. The construction of the preset hash table can be implemented by, but not limited to, the following method: Figure 2 As shown, including:

[0081] Obtain the Http interface method, the URI of the Http interface method, and the instance of the class where the Http interface method is located based on the custom annotation and the return call method;

[0082] Construct the preset hash table based on the Http interface method, the URI of the Http interface method and the instance of the class where the Http interface method is located

[0083] Wherein, the acquisition of the Http interface method, the URI of the Http interface method and the instance of the class where the Http interface method is located based on the custom annotation and the return call method can be implemented by but not limited to the following method, such as Figure 2 As shown, including:

[0084] Dynamically scan classes containing custom annotations, where the custom annotation is @WsAdapter;

[0085] If the class containing the custom annotation is scanned, the method with the @RequestMapping annotation in the class is obtained by reflection;

[0086] Parse the method annotated with @RequestMapping to obtain the Http interface method, the URI of the Http interface method, and the instance of the class where the Http interface method is located.

[0087] As shown above, the instance of the class where the Http interface method corresponding to the WebSocket request is located is called by reflection, and the WebSocket message data is processed through the Http interface. This can be achieved based on the reflection call of the springbootcontroller interface. Based on the original Http interface, that is, the controller method interface of springboot, it is very convenient to call the original controller interface method by reflection, and realize the processing of WebSocket through the Http interface. Figure 3 As shown, including:

[0088] The embodiment of the present disclosure takes the specific operation of calling the controller method by Java reflection as an example to illustrate, adopts the Java custom annotation method to complete the acquisition of the controller method by itself, and can select the appropriate interface method to call when receiving a WebSocket request. The steps are as follows:

[0089] a) First, the program starts the initialization phase and adds an annotation to the definition of all Http controller classes

[0090] @WsAdapter, automatically scans the annotation @WsAdapter through the program to obtain all controller classes that accept HTTP access;

[0091] b) Since @RequestMapping in the springboot project is the standard host for processing specific HTTP requests, the program can automatically mark all methods annotated with @RequestMapping. Therefore, the uri information can be obtained from the above method annotations; the methods annotated with @RequestMapping in the class can be obtained through reflection.

[0092] c) After obtaining the complete URIs of all these Http interface methods, a hash structure mapping is established, where the hash key is the complete URI and the hash value is the Http interface method and the instance of the class where the method is located.

[0093] d) Program running stage, such as Figure 4 As shown, when processing a WebSocket message request, when receiving a WebSocket message request, it is first parsed into a pojo object (Plain Ordinary Java Object). The object field contains the "api" information and request parameter information obtained in the request. "api" corresponds to uri. The hash structure mapping established at startup can be used to obtain the Http interface method object and its class instance.

[0094] e) With the method object, the instance of the class where the method is located, and the calling parameters, the method is called through reflection, so that all the input information of WebSocket is passed to the Http interface method. The original backend implementation code corresponding to Http handles subsequent requests, thus completing the entire conversion process.

[0095] In order to achieve the purpose of making the original Http protocol service support the WebSocket protocol, the embodiment of the present application is completed by adding dependencies and adding new annotations, and the Http interface method and its subsequent code are fully reused. No code similar to the original program function is added, and there will be no difference in behavior and status due to inconsistent protocols.

[0096] In addition, in the embodiment of the present application, the @WsAdapter annotation is customized to automatically identify the existing Http controller processing interface function, and can be dynamically called by reflection, without hard coding in the whole process.

[0097] Furthermore, in the embodiment of the present application, the implementation method of calling the method of the controller class of springboot is realized by reflection. The original interface function of the controller class facing Http does not need to make any modification to the internal implementation of the original function.

[0098] Since the entire design is based on AOP (aspect-oriented programming), code iteration can be very concise when the probe side is upgraded or the requirements change. All interfaces can be covered by modifying only one location. Moreover, the invention also places great emphasis on extensibility during the design phase. For example, in the design of WebSocket messages, it supports partial customization of options (corresponding to Http Header). It only requires adding new attributes when sending and adding parsing logic to the corresponding position of the server-side aspect. The entire original Http service can receive this variable, thus achieving high cohesion and low coupling.

[0099] Figure 5 A schematic diagram of the composition of a data transmission device provided in an embodiment of the present disclosure is shown, and the data transmission device is applied to a central domain controller.

[0100] In some embodiments of the present disclosure, Figure 5The data transmission device shown can be executed by an electronic device or a server. The electronic device may include but is not limited to mobile terminals such as smart phones, laptops, personal digital assistants (PDAs), tablet computers (PADs), portable multimedia players (PMPs), vehicle terminals (such as vehicle navigation terminals), wearable devices, etc., and fixed terminals such as digital TVs, desktop computers, smart home devices, etc. The server may be a server cluster or a cloud server.

[0101] like Figure 5 As shown, the data transmission device may include:

[0102] The receiving unit 201 is used to receive a WebSocket message request, wherein the WebSocket message is organized based on a custom message format, and the custom message format is equivalent to the Http message format and includes necessary information elements of the Http protocol;

[0103] The instantiation unit 202 is used to instantiate the WebSocket message request into an object to obtain a first object;

[0104] The parsing unit 203 is used to parse the WebSocket message request based on the custom message format, and obtain the API information and request parameter information included in the WebSocket message request, wherein the API information corresponds to the URI information of Http, and the request parameter information is completely consistent with the parameter name of the Http interface method;

[0105] An assignment unit 204, configured to assign the API information and request parameter information objects to the fields of the first object;

[0106] The first acquisition unit 205 is used to query a preset hash table through the api field in the segment of the first object to obtain the Http interface method corresponding to the WebSocket request and the class instance of the Http interface method, wherein the hash key of the preset hash table is the uri of the Http interface method, the hash value is the Http interface method and the instance of the class of the Http interface method, and the uri of the Http interface method is obtained by scanning the annotation;

[0107] The data transmission unit 206 is used to call the instance of the class where the Http interface method corresponding to the WebSocket request is located by reflection, and process the WebSocket message data through the Http interface.

[0108] Optionally, the custom message format at least includes: a message header Head and a message body Body;

[0109] The message header Head includes at least a fixed magic for checking the starting boundary of the message; the total length of the data; the header length; at least one option, each option including the option name length, option name, option value length, and option value; the name of the first option is api.

[0110] Optionally, the request parameter information is set in an option of the message header Head, where the option name is a parameter name of the Http interface method;

[0111] Alternatively, the request parameter information is set in the message body, and the options of the message header include the format information of the message body.

[0112] Optionally, the parsing unit 203 includes:

[0113] Parsing the WebSocket message request based on the custom message format, and obtaining the API information from the message header;

[0114] Analyze whether the request parameter information exists in the option information of the message header;

[0115] If the option information is in the message header Head, the request parameter information is obtained from the parameter name of the Http interface method in the option name;

[0116] If it is not in the option information of the message header Head, the request parameter information is obtained from the message body Body.

[0117] Furthermore, the device is as follows Figure 6 As shown, it also includes:

[0118] The second acquisition unit 207 is used to acquire the Http interface method, the URI of the Http interface method and the instance of the class where the Http interface method is located based on the custom annotation and the return call method;

[0119] The construction unit 208 is used to construct the preset hash table based on the Http interface method, the URI of the Http interface method and the instance of the class where the Http interface method belongs.

[0120] Furthermore, the second acquiring unit 207 includes:

[0121] Dynamically scan classes containing custom annotations, where the custom annotation is @WsAdapter;

[0122] If the class containing the custom annotation is scanned, the method with the @RequestMapping annotation in the class is obtained by reflection;

[0123] Parse the method annotated with @RequestMapping to obtain the Http interface method, the URI of the Http interface method, and the instance of the class where the Http interface method is located.

[0124] Furthermore, it also includes: adding a custom annotation @WsAdapter to the definition of all Http controller classes.

[0125] The data transmission device provided in the embodiments of the present disclosure can execute the data transmission method provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.

[0126] Figure 7 A schematic diagram of the hardware circuit structure of a data transmission device provided by an embodiment of the present disclosure is shown.

[0127] like Figure 7 As shown, the data transmission device 500 may include a controller 501 and a memory 502 storing computer program instructions.

[0128] Specifically, the controller 501 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.

[0129] The memory 502 may include a large capacity memory for information or instructions. By way of example and not limitation, the memory 502 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a tape, or a universal serial bus (USB) drive or a combination of two or more of these. Where appropriate, the memory 502 may include a removable or non-removable (or fixed) medium. Where appropriate, the memory 502 may be inside or outside the integrated gateway device. In a particular embodiment, the memory 502 is a non-volatile solid-state memory. In a particular embodiment, the memory 502 includes a read-only memory (ROM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (Electrically Erasable Programmable ROM, EEPROM), an electrically rewritable ROM (EAROM) or a flash memory, or a combination of two or more of these.

[0130] The controller 501 reads and executes the computer program instructions stored in the memory 502 to perform the steps of the data transmission method provided in the embodiment of the present disclosure.

[0131] In an example, the data transmission device 500 may further include a transceiver 503 and a bus 504. Figure 7 As shown, the controller 501, the memory 502 and the transceiver 503 are connected via a bus 504 and communicate with each other.

[0132] The bus 504 includes hardware, software, or both. For example, but not limitation, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industrial Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a MicroChannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses or a combination of two or more of these. Where appropriate, the bus 504 may include one or more buses. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.

[0133] The following is an embodiment of a computer-readable storage medium provided in an embodiment of the present disclosure. The computer-readable storage medium and the data transmission method of the above-mentioned embodiments belong to the same inventive concept. For details not described in detail in the embodiment of the computer-readable storage medium, reference can be made to the embodiment of the above-mentioned lane keeping method.

[0134] This embodiment provides a storage medium including computer executable instructions, which are used to perform a data transmission method when executed by a computer processor.

[0135] Of course, the computer executable instructions of a storage medium containing computer executable instructions provided by an embodiment of the present disclosure are not limited to the above method operations, and can also execute related operations in the data transmission method provided by any embodiment of the present disclosure.

[0136] Through the above description of the implementation methods, the technical personnel in the relevant field can clearly understand that the present disclosure can be implemented by means of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present disclosure can be essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions to enable a computer cloud platform (which can be a personal computer, a server, or a network cloud platform, etc.) to execute the data transmission method provided by each embodiment of the present disclosure.

[0137] The embodiment of the present disclosure also provides an electronic wiper, comprising at least one of the following: the above-mentioned data transmission device; the above-mentioned electronic device; and the above-mentioned computer-readable storage medium.

[0138] Note that the above are only preferred embodiments of the present disclosure and the technical principles used. Those skilled in the art will understand that the present disclosure is not limited to the specific embodiments 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 disclosure. Therefore, although the present disclosure is described in more detail through the above embodiments, the present disclosure is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present disclosure, and the scope of the present disclosure is determined by the scope of the appended claims.

Claims

1. A data transmission method, characterized in that: include: Receive a WebSocket message request, wherein the WebSocket message is organized based on a custom message format, and the custom message format is equivalent to the Http message format; Instantiate the WebSocket message request into an object to obtain a first object; Parsing the WebSocket message request based on the custom message format, obtaining application programming interface api information and request parameter information included in the WebSocket message request, wherein the api information corresponds to the uniform resource identifier uri information of Http, and the request parameter information is completely consistent with the parameter name of the Http interface method; Assign the API information and request parameter information objects to the fields of the first object; The preset hash table is queried through the api field in the field of the first object to obtain the Http interface method corresponding to the WebSocket message request and the class instance of the Http interface method, wherein the hash key of the preset hash table is the uri of the Http interface method, the hash value is the Http interface method and the instance of the class of the Http interface method, and the uri of the Http interface method is obtained by scanning the annotation; The instance of the class where the Http interface method corresponding to the WebSocket message request is located is called by reflection, and the WebSocket message data is processed through the Http interface.

2. The method according to claim 1, characterized in that The custom message format at least includes: a message header Head and a message body Body; The message header Head includes at least: a fixed magic for checking the starting boundary of the message; the total length of the data; the header length; at least one option, each option including the option name length, option name, option value length and option value; the name of the first option in the at least one option is the API information.

3. The method according to claim 2, characterized in that The method further comprises: The request parameter information is set in the option of the message header Head, where the option name is the parameter name of the Http interface method; Alternatively, the request parameter information is set in the message body, and the options of the message header include the format information of the message body.

4. The method according to claim 3, characterized in that The step of parsing the WebSocket message request based on the custom message format and obtaining the API information and request parameter information included in the WebSocket message request includes: Parsing the WebSocket message request based on the custom message format, and obtaining the API information from the message header; Analyze whether the request parameter information exists in the option information of the message header; If the option information is in the message header Head, the request parameter information is obtained from the parameter name of the Http interface method in the option name; If it is not in the option information of the message header Head, the request parameter information is obtained from the message body Body.

5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: Get the Http interface method, the URI of the Http interface method, and the instance of the class where the Http interface method is located based on the custom annotation and the calling method; The preset hash table is constructed based on the Http interface method, the URI of the Http interface method and the instance of the class where the Http interface method belongs.

6. The method according to claim 5, characterized in that The method of obtaining the Http interface method, the URI of the Http interface method, and the instance of the class where the Http interface method is located based on the custom annotation and the calling method includes: Dynamically scan classes containing custom annotations, where the custom annotation is @WsAdapter; If the class containing the custom annotation is scanned, the method with the @RequestMapping annotation in the class is obtained by reflection; Parse the method annotated with @RequestMapping to obtain the Http interface method, the URI of the Http interface method, and the instance of the class where the Http interface method is located.

7. The method according to claim 6, characterized in that The method further includes: Add a custom annotation @WsAdapter to the definition of all Http controller classes.

8. A data transmission device, characterized in that: include: A receiving unit, configured to receive a WebSocket message request, wherein the WebSocket message is organized based on a custom message format, and the custom message format is equivalent to an Http message format; An instantiation unit, configured to instantiate the WebSocket message request into an object to obtain a first object; A parsing unit, configured to parse the WebSocket message request based on the custom message format, and obtain the API information and request parameter information included in the WebSocket message request, wherein the API information corresponds to the URI information of Http, and the request parameter information is completely consistent with the parameter name of the Http interface method; An assignment unit, used for assigning the API information and request parameter information objects to the fields of the first object; A first acquisition unit is used to query a preset hash table through the api field in the field of the first object to obtain the Http interface method corresponding to the WebSocket message request and the class instance of the Http interface method, wherein the hash key of the preset hash table is the uri of the Http interface method, the hash value is the Http interface method and the instance of the class of the Http interface method, and the uri of the Http interface method is obtained by scanning the annotation; The data transmission unit is used to call the instance of the class where the Http interface method corresponding to the WebSocket message request is located by reflection, and process the WebSocket message data through the Http interface.

9. An electronic device, characterized in that: The electronic device comprises: Processor and memory; The processor is used to execute the steps of the method according to any one of claims 1 to 7 by calling the program or instruction stored in the memory.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program or instruction, and the program or instruction enables a computer to execute the steps of the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • System and method for obtaining of real-time state of charging pile

    CN109194770A

  • Data message processing method, system and device and readable storage medium

    CN112104634A