Information processing method, electronic device and computer program product

Through the standard library, the complexity of information format definition and connection management in WebSocket development is solved, and the convenience and flexibility of information transmission and response are achieved. It adapts to a variety of message formats and technical needs, ensuring the stability and reliability of connections.

CN120343015APending Publication Date: 2025-07-18KE COM (BEIJING) TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510361587.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-25
Publication Date
2025-07-18

AI Technical Summary

Technical Problem

In modern web and mobile application development, when using WebSocket for real-time communication, developers need to deal with complex problems such as message format definition and connection management, which increases development costs and maintenance difficulties, and existing sub-protocols have limitations and operation and maintenance burdens in different scenarios.

Method used

Synchronize target information to another standard library through the standard library, and use the formatting and processing programs in the standard library to automatically parse and generate response plans, simplify the information transmission and response process, and maintain connection stability through the heartbeat keep-alive mechanism, supporting a variety of message formats and technical requirements.

Benefits of technology

It realizes the convenience and flexibility of information transmission and response, reduces development complexity, improves the scalability and compatibility of the system, adapts to the technical needs of different application scenarios, and ensures the stability and reliability of the connection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120343015A_ABST
    Figure CN120343015A_ABST
Patent Text Reader

Abstract

The invention provides an information processing method, electronic equipment and a computer program product. The information processing method comprises the steps that a first standard library is controlled to synchronize target information to a second standard library, the first standard library records multiple processing programs defined by a first interaction party, and the second standard library records multiple processing programs defined by a second interaction party; according to the request type of the target information, determining a target processing program corresponding to the request type by a second standard library; and controlling the target processing program to process the target information, and generating a response scheme for the target information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of data processing, etc. In particular, the present disclosure relates to an information processing method, an electronic device, and a computer program product. Background Art

[0002] In modern web and mobile application development, the real-time communication protocol WebSocket is widely used in scenarios that require real-time interaction because it supports full-duplex communication. However, directly developing using WebSocket usually requires developers to handle complex issues such as message format definition, heartbeat detection, and connection management by themselves, which undoubtedly increases the development cost and maintenance difficulty.

[0003] To simplify the development process, it is particularly important to select a suitable WebSocket sub-protocol. These sub-protocols each provide different message models and mechanisms to simplify the development work of specific types of applications. Nevertheless, each sub-protocol has its limitations. Some protocols may limit the customization ability due to high encapsulation, making them less applicable in scenarios that require flexible configuration; while other protocols, although suitable for complex publish / subscribe mode applications, may seem too complex in simple scenarios and sometimes require additional middleware deployment, increasing the operation and maintenance burden. Therefore, developers need to weigh the characteristics of each protocol against the project requirements to make a choice, and sometimes even need to bear a high development cost to implement a custom solution. Summary of the Invention

[0004] The present disclosure provides an information processing method, an electronic device, and a computer program product.

[0005] According to one aspect of the present disclosure, an information processing method is provided, including: controlling a first standard library to synchronize target information to a second standard library, where the first standard library records multiple processing programs defined by a first interaction party, and the second standard library records multiple processing programs defined by a second interaction party; determining, according to the request type of the target information, a target processing program corresponding to the request type by the second standard library; and controlling the target processing program to process the target information to generate a response plan for the target information.

[0006] In some embodiments, controlling the first standard library to synchronize target information to the second standard library includes: when the first standard library obtains the information to be synchronized through an information sending function, calling a formatting function in the first standard library to convert the information to be synchronized into target information with a first format, where the first format is a request format that can be recognized by the second standard library; and calling the information sending function in the first standard library to synchronize the target information to the second standard library according to a first connection protocol.

[0007] In some embodiments, before the second standard library determines the target processing function corresponding to the request type, it further includes: when the information receiving function of the second standard library obtains the target information, calling the type parsing function in the second standard library to parse the target information to determine the request type of the target information.

[0008] In some embodiments, after generating the response plan for the target information, it includes: when there is feedback information in the response plan, calling the formatting function in the second standard library to convert the feedback information into feedback information with a second format, where the second format is a response format recognizable by the first standard library; and calling the information sending function in the second standard library to synchronize the feedback information with the second format to the first standard library according to the first connection protocol.

[0009] In some embodiments, before controlling the first standard library to synchronize the target information to the second standard library, it includes: controlling the first standard library to obtain and store the processing programs of the first interaction party for each request type, where the first standard library has a registration function that allows adding the processing programs, and the first interaction party is a client or a server, and the second interaction party is a server or a client; and controlling the second standard library to obtain and store the processing programs of the second interaction party for each request type, where the second standard library has a registration function that allows adding the processing programs.

[0010] In some embodiments, before controlling the first standard library to synchronize the target information to the second standard library, it includes: establishing a connection relationship for the first interaction party and the second interaction party according to the first connection protocol, where the first connection protocol enables real-time two-way communication between the first interaction party and the second interaction party.

[0011] In some embodiments, after establishing the connection relationship for the first interaction party and the second interaction party, it includes: controlling the standard library of the client to send an active detection message to the server, where the client is the first interaction party or the second interaction party, and the server is the second interaction party or the first interaction party; when the standard library of the client receives the passive response message from the server in the first period, determining that the first interaction party and the second interaction party are in a connected state; or when the standard library of the client does not receive the passive response message in the first period, determining that the first interaction party and the second interaction party are in an interrupted state.

[0012] In some embodiments, after establishing a connection relationship between a first interaction party and the second interaction party, the following steps are included: controlling the standard library of the server to listen for the active detection message of the client, where the client is the first interaction party or the second interaction party, and the server is the second interaction party or the first interaction party; when the standard library of the server detects the active detection message in the second cycle, determining that the first interaction party and the second interaction party are in a connected state; or, when the standard library of the server does not detect the active detection message in the second cycle, determining that the first interaction party and the second interaction party are in an interrupted state.

[0013] In some embodiments, after determining that the first interaction party and the second interaction party are in an interrupted state, the following step is included: controlling the first standard library to send a reconnection request to the second interaction party.

[0014] In some embodiments, after establishing a connection relationship between a first interaction party and the second interaction party, the following steps are further included: after a connection closing instruction is issued by the client or the server, controlling the disconnection function in the standard library of the client to interrupt the connection with the server, and controlling the disconnection function in the standard library of the server to interrupt the connection with the client, where the client is the first interaction party or the second interaction party, and the server is the second interaction party or the first interaction party.

[0015] According to one aspect of the present disclosure, an electronic device is provided, including: a memory that stores execution instructions; and a processor that executes the execution instructions stored in the memory, so that the processor executes the information processing method of any embodiment of the present disclosure.

[0016] According to one aspect of the present disclosure, a readable storage medium is provided, in which execution instructions are stored, and when the execution instructions are executed by a processor, they are used to implement the information processing method of any embodiment of the present disclosure.

[0017] According to one aspect of the present disclosure, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, it implements the information processing method of any embodiment of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings illustrate exemplary embodiments of the present disclosure and, together with the description thereof, are used to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are included in this specification and form a part of this specification.

[0019] Figure 1 It is an application scenario diagram of the information processing method according to an embodiment of the present disclosure.

[0020] Figure 2 is a flowchart of an information processing method according to an embodiment of the present disclosure.

[0021] Figure 3 is a flowchart of the interaction process between a client and a server according to an embodiment of the present disclosure.

[0022] Figure 4 is a schematic diagram of a heartbeat keep-alive process according to an embodiment of the present disclosure.

[0023] Figure 5 is a schematic block diagram of the structure of an information processing apparatus according to an embodiment of the present disclosure.

[0024] Figure 6 is a schematic block diagram of the structure of an electronic device according to an embodiment of the present disclosure. Detailed Embodiments

[0025] The present disclosure will be further described in detail below with reference to the accompanying drawings and examples. It can be understood that the specific examples described herein are only for explaining the relevant content and do not limit the present disclosure. Additionally, it should be noted that for the sake of description, only parts related to the present disclosure are shown in the accompanying drawings.

[0026] It should be noted that, without conflict, the embodiments in the present disclosure and the features in the embodiments can be combined with each other. The technical solutions of the present disclosure will be described in detail below with reference to the accompanying drawings and embodiments.

[0027] In modern web page and mobile application development, the real-time communication protocol WebSocket, as a protocol supporting full-duplex communication, is widely used in scenarios requiring real-time interaction. However, directly developing based on WebSocket often requires developers to handle complex issues such as message format definition, heartbeat detection, and connection management by themselves, increasing the development cost and maintenance difficulty.

[0028] Therefore, choosing a suitable WebSocket sub - protocol has become the key to optimizing the development process. For example, STOMP (Simple Text Oriented Messaging Protocol), MQTT (Message Queuing Telemetry Transport), or the real - time library Socket.IO. These sub - protocols each provide different message models and mechanisms to simplify the development work of specific types of applications, such as instant messaging (IM). However, each sub - protocol has its limitations. For example, although Socket.IO is easy to use and has wide compatibility, its high - level encapsulation restricts the customization ability; STOMP and MQTT are more suitable for applications based on the publish / subscribe mode, but may seem too heavy in simple scenarios, and MQTT also requires additional middleware deployment, increasing the operation and maintenance burden. Therefore, developers need to weigh the characteristics of each protocol against the requirements of their own projects, and sometimes even have to face a relatively high development cost to implement a custom solution.

[0029] To this end, the present disclosure proposes an information processing method.

[0030] Figure 1 It is a schematic diagram of the application scenario of the information processing method according to an embodiment of the present disclosure. As Figure 1 shown, in this application scenario, it may include a server 100 and a terminal device 200. The server 100 and the terminal device 200 can be connected through a network or Bluetooth for data interaction. The server 100 can be a cloud server or a physical server, and the terminal device 200 can be an intelligent device such as a computer, a mobile phone, or a tablet. The server 100 is used to provide the basic data required to run the information processing method, and the terminal device 200 executes the information processing method of the present disclosure based on the basic data provided by the server 100.

[0031] For the convenience of description and to make the technical solutions of the specific embodiments of the present disclosure easier to understand, before describing the information processing method implemented in the present disclosure, the technical terms involved in the specific embodiments of the present disclosure are explained as follows: Standard library: It can provide a registration interface for the processing programs of the business functions of the corresponding interaction parties. The standard library can encapsulate registration functions, information sending functions, information receiving functions, etc., and has the basic ability to be ready - to - use.

[0032] Target information: It is the information sent by the first interaction party to the second interaction party. The first interaction party can be a client or a server.

[0033] Processing program: It is a program that implements the business functions of the interaction party and can be stored in the standard library through the registration function of the standard library.

[0034] Response scheme: It is the result of the second interaction party invoking a handler to process the target information. It may include: actions responding to the request content in the target information, feedback information replied to the first interaction party, etc.

[0035] Figure 2 It is a flowchart of an information processing method according to an embodiment of the present disclosure. As Figure 2 shown, the present disclosure proposes an information processing method M200. Through steps S210 to S230, it enables the two interaction parties to not need to define an information format, and can process the information according to the handlers that meet their own business functions, making the transmission and response of information more convenient and flexible.

[0036] Step S210: Control the first standard library to synchronize the target information to the second standard library.

[0037] The first standard library records multiple handlers defined by the first interaction party, and the handlers in the first standard library are mainly used to implement the business functions of the first interaction party. Similarly, the second standard library records multiple handlers defined by the second interaction party, and the handlers in the second standard library are mainly used to implement the business functions of the second interaction party.

[0038] Moreover, both the first standard library and the second standard library have an information receiving interface and an information sending interface. The information receiving interface is used to receive the target information or feedback information sent by the standard library of the other party, and trigger the corresponding information processing function to parse and classify it. The information sending interface is responsible for sending the information or feedback information to be synchronized by the local party to the other party in a predetermined format.

[0039] For example, when the first interaction party sends information to the second interaction party, the first interaction party triggers an information sending function through the information sending interface. The information sending function processes the information to be synchronized into target information. Then, the information sending function sends the target information to the information receiving interface of the second standard library according to the first connection protocol to trigger the information receiving function to process the target information.

[0040] Specifically, when the first standard library obtains the information to be synchronized through the information sending function, it calls the formatting function in the first standard library to convert the information to be synchronized into target information with a first format, and the first format is a request format that can be recognized by the second standard library; and calls the information sending function in the first standard library to synchronize the target information to the second standard library according to the first connection protocol.

[0041] Among them, the formatting function can be an auxiliary function of the information sending function. The first format is the message format of the request information agreed upon by the first standard library and the second standard library, that is, the request format. The request format can be: ['query', 1,'method', {}], where 'query' indicates that the information type is "request"; 1 indicates the information encoding, which is an identifier for the information and is incremented by the first standard library according to the number of times the information is sent. If it overflows, it is reset to 0;'method' indicates the request type of the information, such as data query, command execution, etc.; the actual content of the information request should be filled in the symbol "{}". The first format can be in json format.

[0042] The first connection protocol refers to a set of rules jointly observed by the first interaction party and the second interaction party during the communication process. For example, the real-time communication protocol WebSocket is used as the basic communication protocol to ensure that both parties can achieve efficient and low-latency data exchange through a long connection. According to the first connection protocol, after the connection is established between the two interaction parties, both parties can actively send information of the type "request" without the permission of the other party. The first connection protocol is applicable to the chat process of software such as WeChat and the pages of instant games.

[0043] In addition, in the present disclosure, the party whose information type of the sent information is a request is used as the first interaction party, and the party whose information type of the sent information is a response is used as the second interaction party. When the first connection protocol is between the two parties, the first interaction party is the client or the server. When the first interaction party is the client, the second interaction party is the server; when the first interaction party is the server, the second interaction party is the client. In other words, both the client and the server can actively send information to the other party without the permission of the other party.

[0044] Step S220, according to the request type of the target information, the second standard library determines the target handler corresponding to the request type.

[0045] Since the target information has a first format that can be recognized by the second standard library, after the information receiving interface of the second standard library obtains the target information, it will trigger the information receiving function to call the type parsing function to parse the target information to read the request type of the target information. Among them, the type parsing function is an auxiliary function of the information receiving function.

[0046] Furthermore, according to the request type of the target information, the processing program of the second interaction party when dealing with this type of information is determined. Since the second standard library stores the processing programs of the second interaction party for various request types, the target handler for processing this type can be uniquely located according to the request type.

[0047] Step S230, control the target handler to process the target information and generate a response plan for the target information.

[0048] The target handler processes according to the content actually requested in the symbol "{}" of the target information. For example, when the "request type" is "data query", the actual request content is: query location data; then, the handler should call the positioning function of the second interaction party to identify its location data and generate a response plan with the location data as the feedback information.

[0049] Further, when there is feedback information in the response plan, call the formatting function in the second standard library to convert the feedback information into feedback information with a second format, and the second format is a response format that can be recognized by the first standard library; and call the information sending function in the second standard library to synchronize the feedback information with the second format to the first standard library according to the first connection protocol.

[0050] The second format is the message format about the request information agreed upon by the first standard library and the second standard library, that is, the response format. The response format can be: ['result', 1,'method', {}], where result indicates that the information type is "response"; 1 indicates the information encoding, which is the identifier of the target information and is consistent with the information encoding of the information of the request type; method indicates the request type of the information, such as data query, command execution, etc., and is consistent with the information encoding of the information of the request type; the feedback information should be filled in the symbol "{}". The second format can be the json format.

[0051] Of course, if the "request type" of the target information is "command execution" and the actual request content is: turn off switch A; then the handler should turn off switch A of the second interaction party. At this time, the response plan is: turn off switch A, and there is no need to return feedback information to the first interaction party. In other words, the feedback information is not necessary, as long as the request of the target information can be responded to.

[0052] For possible error situations, such as network interruption, data loss, etc., the present disclosure also provides a complete error handling mechanism. When the first standard library or the second standard library detects a situation where the target information cannot be processed normally, an error message containing an error code and a description will be generated and sent to the other party according to a predefined format. This enables both parties to promptly identify the problem and take corresponding measures for repair or notify the user. In addition, for some common error types, the system can also automatically attempt to recover, such as automatically reconnecting after the network is restored, further enhancing the robustness and reliability of the system.

[0053] The format of the error message can be: ['error', 1, 1000, 'error description', {}]. Among them, "error" indicates that the message type is "error"; 1 represents the message code, which is an identifier for the target message and is consistent with the message code of the message type of the request; 1000 is the error code, and of course it can also be defined as any value; the error description information should be filled in the symbol "{}", such as the request processor not found, etc. The format of the error message can be in JSON format.

[0054] This disclosure processes the information to be synchronized through the standard library and calls the processing program, enabling both parties in the interaction to not need to define the information format, and can process the information according to the processing program that meets their own business functions, making the transmission and response of information more convenient and flexible. The information processing method proposed in this disclosure has strong scalability and compatibility. Whether using WebSocket as the underlying protocol or supporting multiple message formats (such as JSON, XML, etc.), it can flexibly adapt to different application scenarios and technical requirements. In addition, by opening the registration interface of the standard library, developers are allowed to customize and add processing programs according to specific business scenarios, greatly enhancing the flexibility and scalability of the system. This design idea not only simplifies the development process but also provides convenient conditions for subsequent function expansion.

[0055] Figure 3 It is a flowchart of the interaction process between the client and the server according to the embodiments of this disclosure. Refer to Figure 3 , which intuitively shows the interaction process between the client and the server. The method used when the client and the server interact can be Figure 1 run by the terminal device 200 in [], and the required data can be recorded in the server 100.

[0056] The standard library is a registration interface that can provide processing programs for the business functions of the corresponding interaction parties. The standard library can encapsulate registration functions, information sending functions, information receiving functions, etc., and has the basic ability to be ready for use out of the box. The target information is the information sent from the first interaction party to the second interaction party. The first interaction party can be a client or a server. The processing program is a program that implements the business functions of the interaction party and can be stored in the standard library through the registration function of the standard library. The response scheme is the result of the second interaction party calling the processing program to process the target information. It can include: actions to respond to the request content in the target information, feedback information to respond to the first interaction party, etc.

[0057] In step 301a, the client adds a processing program to the first standard library; in step 301b, the server adds a processing program to the second standard library. These two steps can be carried out simultaneously.

[0058] The handlers added by the client and the server are determined according to the business functions they can support. Different business functions correspond to different handlers. The standard library proposed in this disclosure opens a registration interface to users, which can trigger the registration function to write handlers that meet their own business needs, realizing the personalization and flexibility of the interaction.

[0059] The registration function is a function provided by the standard library that can receive and store these handlers to ensure that they can be called later.

[0060] In step 303, a connection is established between the client and the server according to WebSocket.

[0061] A persistent connection relationship is established between the client and the server through the WebSocket protocol, allowing both parties to initiate communication (including target information and feedback information) at any time.

[0062] Considering the increasing requirements of modern applications for security and privacy protection, this disclosure emphasizes the security in the information transmission process. In addition to basic encrypted communication, role-based access control is also introduced. When the client requests to establish a connection with the server, it needs to pass the permission verification of the server to ensure that only authorized clients can access specific data or perform certain operations. At the same time, all transmitted data is strictly checked and verified to prevent malicious tampering or forgery, thus providing a more secure and reliable communication environment for users.

[0063] In step 304, the client generates the information to be synchronized. The request types of the information to be synchronized can be data query, command execution, etc. When the request type is data query, it should include the specific data content to be queried; when the request type is command execution, it should include the specific request action to be executed.

[0064] In step 305, the information to be synchronized is processed into target information with the first format.

[0065] When the information sending interface of the first standard library obtains the information to be synchronized, it will trigger the information sending function to process the information to be synchronized. The information sending function calls its auxiliary function (i.e., the formatting function) to convert the information to be synchronized into target information that conforms to the first format. This format is agreed upon in advance by both parties to ensure that the information can be recognized and parsed by the other party.

[0066] Of course, when the first standard library processes the information to be synchronized, it can also include the security calibration of the information content, as well as element supplementation, etc. Element supplementation can be, for example, supplementing the timestamp at the moment of receiving the information.

[0067] In step 306, the first standard library sends the target information to the second standard library.

[0068] The information sending function of the first standard library synchronizes the formatted target information to the second standard library according to the first connection protocol.

[0069] In step 307, the second standard library determines the request type of the target information.

[0070] After obtaining the target information, the information receiving interface of the second standard library triggers the information receiving function to process the target information. This includes calling the information parsing function to determine the request type of the target information.

[0071] In step 308, the second standard library locates the target handler that can process this type of information according to the request type and generates a response plan.

[0072] In step 309, the second standard library performs corresponding operations on the server according to the response plan, such as executing actions or returning the data requested by the target information (i.e., feedback information).

[0073] In step 310, after the server returns the feedback information, the second standard library adjusts the feedback information to the second format. The second format is a response format that can be recognized by the first standard library and is processed by the formatting function of the second standard library.

[0074] In step 311, the second standard library synchronizes the feedback information to the first standard library.

[0075] The information sending function of the second standard library synchronizes the formatted feedback information to the first standard library according to the WebSocket protocol.

[0076] In steps 312 and 313, the first standard library parses the received feedback information, obtains the result and returns it to the client.

[0077] It should be noted that taking the client as the first interaction party is an interaction example. The server can also take the initiative to send target information to the client as the first interaction party. When the server is the first interaction party and the client is the second interaction party, it can also be executed according to steps 301 to 313, which will not be elaborated here.

[0078] The present disclosure processes the information to be synchronized through a standard library and calls the processing program, enabling the two parties in the interaction to not need to define the information format and process the information according to the processing program that meets their own business functions, making the transmission and response of information more convenient and flexible. The information processing method proposed by the present disclosure has strong scalability and compatibility. Whether using WebSocket as the underlying protocol or supporting multiple message formats (such as JSON, XML, etc.), it can flexibly adapt to different application scenarios and technical requirements. In addition, by opening the registration interface of the standard library, developers are allowed to customize and add processing programs according to specific business scenarios, greatly improving the flexibility and scalability of the system. This design concept not only simplifies the development process but also provides convenient conditions for subsequent function expansion.

[0079] Figure 4 is a schematic diagram of the heartbeat keep-alive process according to an embodiment of the present disclosure. As Figure 4 shown, it shows the process of heartbeat keep-alive. That is, after establishing a connection between the first interaction party and the second interaction party, the connection status of both parties is detected.

[0080] The first interaction party and the second interaction party interact according to the first connection protocol. The first connection protocol adopts an instant full-duplex communication protocol, such as the WebSocket protocol, which allows either the client or the server to initiate information transmission at any time on the connection without waiting for the other party to ask. The connection channel established through the first connection protocol provides low-latency and real-time data exchange capabilities, enabling information to be synchronized instantly. This feature is suitable for scenarios that require quick response, such as online games, instant messaging, etc. For the connection channel established according to the first connection protocol, ensuring the stability of the connection is an important link for realizing the interaction. Therefore, both the first standard library and the second standard library of the present disclosure are provided with a heartbeat keep-alive mechanism to monitor the connection status between the two interaction parties in real time.

[0081] In step 401, the standard library of the client sends an active detection message to the server through the first connection protocol.

[0082] The first standard library and the second standard library have agreed on a set of message formats that both parties can recognize, including the first format, the second format, and the format of the detection message. The first format and the second format have been described above and will not be elaborated here. Regarding the active detection message in the detection message, the format is set to ["ping"]; regarding the passive response message in the detection message, the format is set to ["pong"].

[0083] The active detection message is a heartbeat packet actively sent by the client to the server for detecting the connection status. After the client sends the active detection message, the standard library of the client formats the active detection message and converts it to ["ping"].

[0084] In step 402, after the standard library of the server receives the active detection message, it returns a passive response message.

[0085] The passive response message should be a response immediately sent by the server to the client after receiving the heartbeat packet, and is used to determine the connection status of both parties.

[0086] In step 403, after the standard library of the server receives the passive response message, it determines the connection status of both parties; or, if the passive response message is not received in the first cycle, it determines the interruption status of both parties.

[0087] When the client sends an active detection message, it is sent to the server via the connection channel of both parties according to the first connection protocol through the information sending function of the standard library of the client. The passive response message returned by the server is sent to the client via the connection channel of both parties according to the first connection protocol through the information sending function of the standard library of the server. That is to say, if the client receives the passive response message in the first cycle, it proves that the two parties are in a connected state. On the contrary, there may be a problem of connection interruption and it is in an interrupted state.

[0088] The first cycle is the duration set by the client for waiting for the server's response. It can be 10 seconds or any value. Since the first connection protocol of both parties supports real-time interaction, in order to ensure that the speed of information transmission can meet the real-time standard, the set duration of the first cycle can be relatively short. If the server returns the passive response message after the first cycle, it proves that the connection status between the two parties is unstable or the effect is not good, and conditions for optimization and improvement are also available.

[0089] Furthermore, in step 404, after the standard library of the server receives the active detection message, it determines the connection status of both parties; or, if the active detection message is not received in the second cycle, it determines the interruption status of both parties.

[0090] This process is a process for the server to actively detect the connection status. In order to reduce the overhead of the heartbeat keep-alive process and save the process of the server actively sending an active detection message to the client, but to ensure the efficiency and accuracy of the heartbeat keep-alive process, through the standard library of the server, the server still has the ability to actively detect the connection status.

[0091] Specifically, a second period is also preset in the standard library of the server. The duration of the second period is determined according to the sending frequency of the active detection message. If it is stipulated that the active detection message is sent once per second, then the duration of the second period should be between 1 and 2 seconds; of course, it can also be other sending frequencies and second periods, which are not restricted here. There is a timer in the standard library of the server. If the active detection message from the client is not received during the second period, it proves that the connection channel between the two parties may be in an interrupted state. On the contrary, if the active detection message can be obtained in time during the second period, it indicates that the connection channel between the two parties is in a connected state.

[0092] It should be noted that after the client obtains the passive response message from the server each time, the client controls the timer in its standard library to re-time the first period. After the client sends the active detection message each time, the server controls the timer in its standard library to re-time the second period.

[0093] In step 405, it is determined whether the connection channel between the two parties is in an interrupted state.

[0094] If the client detects an interrupted state, it executes step 406, and the client sends a reconnection request to the server.

[0095] If the server detects an interrupted state, it actively disconnects the connection with the client.

[0096] The present disclosure realizes the judgment of the connection channel state between the client and the server through the standard library, and can detect and take measures in time, ensuring the stability and reliability of the connection and effectively improving the efficiency of information interaction. Since the heartbeat keep-alive mechanism is set in the standard library, the effect of being ready to use out of the box is achieved.

[0097] In practical applications, in addition to the heartbeat keep-alive mechanism, connection management and optimization are also important aspects to ensure the quality of real-time communication. The present disclosure also proposes an intelligent heartbeat detection strategy, which not only relies on fixed periodic detection, but also dynamically adjusts the heartbeat interval according to the network conditions. For example, in the case of stable network, the heartbeat interval can be appropriately extended to reduce resource consumption; while in the case of unstable network, the heartbeat interval is shortened to quickly detect and repair connection problems. This adaptive strategy helps to improve the overall performance of the system and the user experience.

[0098] In modern network communication, ports and state machines are key elements to ensure efficient and reliable interaction between the client and the server. They not only affect the efficiency of data transmission, but also are directly related to the stability and maintainability of the system.

[0099] Ports, as the basic units in network communication, are used to distinguish different services or applications. In this solution, WebSocket connections are usually bound to specific TCP ports to enable secure encrypted communication. However, during actual deployment, developers can choose other unoccupied ports according to their needs to avoid conflicts and optimize resource allocation. It is important to configure firewall rules reasonably to ensure that the selected ports can correctly receive requests from the outside. In addition, considering the requirements of load balancing and high availability, multiple ports can also be used for traffic distribution to improve the overall performance and fault tolerance of the system.

[0100] A state machine is an important model that describes how a system responds to various events and migrates from one state to another. For WebSocket-based applications, the design of the state machines for the client and the server is particularly important because it directly affects the processes of connection establishment, maintenance, and disconnection. A typical WebSocket state machine includes the following main states: CONNECTING (connection establishment), OPEN (connected), CLOSING (closing), and CLOSED (closed). In each state, the system performs corresponding operations and triggers state transitions based on the received events. For example, in the OPEN state, if a network interruption is detected, the system will immediately enter the CLOSING state and attempt to re-establish the connection; if the reconnection fails, it will finally enter the CLOSED state. This state machine-based design not only simplifies logical control but also improves the robustness and predictability of the system.

[0101] To further enhance the functionality of the state machine, a heartbeat detection mechanism can also be introduced as a condition for state migration. Specifically, when the client does not receive a heartbeat response from the server for a long time, the connection can be considered invalid, and the state can be actively migrated to CLOSING or CLOSED. Similarly, the server can also adjust its own state according to the behavior of the client. In this way, even in an unstable network environment, both parties can be ensured to timely sense the changes in the connection and take appropriate measures to resume communication.

[0102] Reasonable port management and a well-designed state machine are indispensable parts of building an efficient and stable real-time communication system. They not only enhance the user experience but also provide a solid foundation for subsequent maintenance and expansion.

[0103] The present disclosure processes the information to be synchronized through a standard library and calls the processing program, enabling the two parties of the interaction to not need to define the information format and process the information according to the processing program that meets their own business functions, making the transmission and response of information more convenient and flexible. The information processing method proposed by the present disclosure has strong scalability and compatibility. Whether using WebSocket as the underlying protocol or supporting multiple message formats (such as JSON, XML, etc.), it can flexibly adapt to different application scenarios and technical requirements. In addition, by opening the registration interface of the standard library, developers are allowed to customize and add processing programs according to specific business scenarios, greatly enhancing the flexibility and scalability of the system. This design concept not only simplifies the development process but also provides convenient conditions for subsequent function expansion.

[0104] Figure 5 is a structural schematic diagram of an information processing device according to an embodiment of the present disclosure. As Figure 5 shown, an information processing device 500 is shown, including: An information sending module 510, configured to control the first standard library to synchronize target information to the second standard library. The first standard library records multiple processing programs defined by the first interaction party, and the second standard library records multiple processing programs defined by the second interaction party; a processing program determination module 520, configured to determine a target processing program corresponding to the request type from the second standard library according to the request type of the target information; and a response module 530, configured to control the target processing program to process the target information and generate a response plan for the target information.

[0105] The information processing device 500 of the present disclosure may be in the form of computer software, and each module of the information processing device 500 may be in the form of a computer software module.

[0106] Each module of the information processing device 500 of the present disclosure is set to implement each step of the information processing method. Its execution principle and steps can refer to the foregoing, and will not be elaborated here.

[0107] Figure 6 is a structural schematic diagram of an electronic device according to an embodiment of the present disclosure. As Figure 6 shown, the present disclosure also provides an electronic device 1000, including: a processor 1200 and a memory 1300. The memory 1300 stores execution instructions; the processor 1200 executes the execution instructions stored in the memory 1300, so that the processor 1200 executes the information processing method.

[0108] The hardware structure of the electronic device 1000 can be implemented using a bus architecture. The bus architecture can include any number of interconnecting buses and bridges, depending on the specific application of the hardware and the overall design constraints. The bus 1100 connects various circuits including one or more processors 1200, a memory 1300, and / or hardware modules together. The bus 1100 can also connect various other circuits 1400 such as peripheral devices, voltage regulators, power management circuits, external antennas, etc.

[0109] The bus 1100 can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Component (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one connecting line is shown in this figure, but it does not mean that there is only one bus or one type of bus.

[0110] The present disclosure also provides a readable storage medium. A computer program is stored in the readable storage medium and is used to implement the above method when executed by a processor. The "readable storage medium" can be any device that can contain, store, communicate, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. More specific examples of the readable storage medium include the following: an electrical connection part with one or more wirings (electronic device), a portable computer disk cartridge (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM), etc.

[0111] The present disclosure also provides a computer program product. The method of the present disclosure can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed, the processes or functions of the present disclosure are executed in whole or in part.

[0112] Computer programs or instructions can be stored in a readable storage medium or transmitted from one readable storage medium to another. For example, the computer programs or instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center in a wired or wireless manner. The readable storage medium can be any available medium that can be accessed or a data storage device such as a server or data center integrating one or more available media. The available medium can be a magnetic medium, such as a floppy disk, hard disk, or magnetic tape; it can also be an optical medium, such as a digital video disc; or it can be a semiconductor medium, such as a solid-state drive. The computer-readable storage medium can be a volatile or non-volatile storage medium, or can include both volatile and non-volatile types of storage media.

[0113] Those skilled in the art should understand that the embodiments of the present disclosure can be provided as a method, an electronic device, a readable storage medium, or a computer program product. Therefore, the present disclosure can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present disclosure can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) containing computer-usable program code.

[0114] The present disclosure is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present disclosure. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the functions specified in Figure 1 one or more of the flows Figure 1 or multiple flows and / or blocks

[0115] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device that implements the functions specified in Figure 1 one or more of the flows Figure 1 or multiple flows and / or blocks

[0116] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus, so that a series of operation steps are performed on the computer or other programmable apparatus to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable apparatus provide steps for implementing the functions specified in one process Figure 1 one process or more processes and / or blocks Figure 1 steps of the functions specified in one block or more blocks.

[0117] In the description of this specification, the descriptions with reference to the terms "one embodiment / way", "some embodiments / ways", "example", "specific example", or "some examples", etc. mean that the specific features, structures, or characteristics described in connection with the embodiment / way or example are included in at least one embodiment / way or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment / way or example. Moreover, the specific features, structures, or characteristics described can be combined in any one or more embodiments / ways or examples in a suitable manner. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments / ways or examples described in this specification and the features of different embodiments / ways or examples.

[0118] In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, "a plurality of" means at least two, such as two, three, etc., unless otherwise specifically defined.

[0119] Those skilled in the art should understand that the above embodiments are only for clearly illustrating the present disclosure and not for limiting the scope of the present disclosure. For those skilled in the art, other changes or variations can be made on the basis of the above disclosure, and these changes or variations are still within the scope of the present disclosure.

Claims

1. An information processing method, characterized in that, Including: Controlling the first standard library to synchronize target information to the second standard library, where the first standard library records various processing programs defined by a first interaction party, and the second standard library records various processing programs defined by a second interaction party; Determining, by the second standard library, a target processing program corresponding to the request type according to the request type of the target information; And Controlling the target processing program to process the target information to generate a response plan for the target information.

2. The information processing method according to claim 1, wherein Controlling the first standard library to synchronize target information to the second standard library includes: When the first standard library obtains information to be synchronized through an information sending function, calling a formatting function in the first standard library to convert the information to be synchronized into target information with a first format, where the first format is a request format recognizable by the second standard library; and Calling the information sending function in the first standard library to synchronize the target information to the second standard library according to a first connection protocol.

3. The information processing method according to claim 2, wherein Before determining, by the second standard library, a target processing function corresponding to the request type, it further includes: When the information receiving function of the second standard library obtains the target information, calling a type parsing function in the second standard library to parse the target information to determine the request type of the target information.

4. The information processing method according to claim 1, wherein After generating a response plan for the target information, it includes: When there is feedback information in the response plan, calling a formatting function in the second standard library to convert the feedback information into feedback information with a second format, where the second format is a response format recognizable by the first standard library; and Calling the information sending function in the second standard library to synchronize the feedback information with the second format to the first standard library according to the first connection protocol.

5. The information processing method according to claim 1, wherein Before controlling the first standard library to synchronize target information to the second standard library, it includes: Controlling the first standard library to obtain and store the processing programs of the first interaction party for each request type. The first standard library has a registration function that allows adding the processing programs, where the first interaction party is a client or a server, and the second interaction party is a server or a client; and Controlling the second standard library to obtain and store the processing programs of the second interaction party for each request type. The second standard library has a registration function that allows adding the processing programs.

6. The information processing method according to claim 1, wherein Before controlling the first standard library to synchronize target information to the second standard library, it includes: Establishing a connection relationship between the first interaction party and the second interaction party according to a first connection protocol, where the first connection protocol enables real-time two-way communication between the first interaction party and the second interaction party.

7. The information processing method according to claim 6, wherein After establishing a connection relationship between the first interaction party and the second interaction party, it includes: Controlling the standard library of the client to send an active detection message to the server, where the client is the first interaction party or the second interaction party, and the server is the second interaction party or the first interaction party; When the standard library of the client receives the passive response message from the server in the first cycle, it determines that the first interaction party and the second interaction party are in a connected state; or when the standard library of the client does not receive the passive response message in the first cycle, it determines that the first interaction party and the second interaction party are in an interrupted state.

8. The information processing method according to claim 7, characterized in that After determining that the first interaction party and the second interaction party are in an interrupted state, it includes: Controlling the first standard library to send a reconnection request to the second interaction party.

9. The information processing method according to claim 6, characterized in that, After establishing a connection relationship between the first interaction party and the second interaction party, it further includes: After a connection closing instruction is issued by the client or the server, controlling the disconnection function in the standard library of the client to interrupt the connection with the server, and controlling the disconnection function in the standard library of the server to interrupt the connection with the client, where the client is the first interaction party or the second interaction party, and the server is the second interaction party or the first interaction party.

10. An electronic device, characterized in that, It includes: A memory that stores execution instructions; And A processor that executes the execution instructions stored in the memory, enabling the processor to execute the information processing method according to any one of claims 1 to 9.

11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the information processing method according to any one of claims 1 to 9.