CN115913944A - Data updating method, device, equipment, medium and program product - Google Patents

Data updating method, device, equipment, medium and program product Download PDF

Info

Publication number
CN115913944A
CN115913944A CN202211352749.3A CN202211352749A CN115913944A CN 115913944 A CN115913944 A CN 115913944A CN 202211352749 A CN202211352749 A CN 202211352749A CN 115913944 A CN115913944 A CN 115913944A
Authority
CN
China
Prior art keywords
long connection
data
signaling message
heartbeat detection
connection request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211352749.3A
Other languages
Chinese (zh)
Inventor
郭松
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202211352749.3A priority Critical patent/CN115913944A/en
Publication of CN115913944A publication Critical patent/CN115913944A/en
Pending legal-status Critical Current

Links

Images

Abstract

The disclosure provides a data updating method which can be applied to the technical field of internet communication. The data updating method comprises the following steps: sending a long connection request, the long connection request being formed based on a time check factor; periodically executing a heartbeat detection mechanism with a backend in the event of successful establishment of a long connection with the backend; receiving a signaling message under the condition that the heartbeat detection mechanism passes, wherein the signaling message is sent by the back end in response to the operation of data updating; updating and checking the signaling message; and under the condition that the updating check is successful, updating the data of the front end based on the signaling message. The present disclosure also provides a data updating apparatus, a device, a storage medium, and a program product.

Description

Data updating method, device, equipment, medium and program product
Technical Field
The present disclosure relates to the field of internet technologies, particularly to the field of internet communications technologies, and more particularly, to a data update method, apparatus, device, medium, and program product.
Background
In a typical internet scenario, a front end adopts an HTTP request method for acquiring data of a back end, the HTTP request model is designed as a one-time request model, a connection is separately established each time an HTTP request is initiated during end-to-end communication to achieve end-to-end data transmission, and the HTTP connection is closed after the request data is returned to the front end, wherein a lifecycle is recorded from the HTTP request to the HTTP connection closing.
When the HTTP connection is adopted to realize the end-to-end data synchronization, the HTTP connection can ensure the data security to a great extent because the identity check is required to realize the data interaction in each end-to-end data acquisition. However, HTTP is a too complicated connection manner, which cannot guarantee instant delivery of data interaction, and reduces flexibility and timeliness of data interaction to some extent.
With the development of the internet era, data interaction can be achieved in many application scenarios while safety and flexibility are considered. Therefore, the way to implement front-end data updates using HTTP connections alone has grown unable to meet the growing data interaction needs.
Disclosure of Invention
In view of the foregoing, the present disclosure provides a data updating method, apparatus, device, medium, and program product that can compromise data flexibility and security.
According to a first aspect of the present disclosure, there is provided a data update method, which is applied to a front end, the method including: sending a long connection request, the long connection request being formed based on a time check factor; periodically executing a heartbeat detection mechanism with a backend in the event of a successful long connection establishment with the backend; receiving a signaling message under the condition that the heartbeat detection mechanism passes, wherein the signaling message is sent by the back end in response to the operation of data updating; updating and checking the signaling message; and under the condition that the updating check is successful, updating the data of the front end based on the signaling message.
According to the embodiment of the disclosure, the method for forming the long connection request comprises the following steps: acquiring a current timestamp; calculating a unique identifier based on the current timestamp as the time check factor; and forming the long connection request based on the unique identifier.
According to an embodiment of the present disclosure, the periodically performing the heartbeat detection mechanism with the backend includes: forming a heartbeat detection request data packet based on the unique identification; sending a heartbeat detection request data packet to the rear end based on a preset heartbeat detection period; and receiving a heartbeat detection response data packet under the condition that the back end judges that the unique identification is consistent with the pre-stored identification in the white list.
According to the embodiment of the disclosure, the pre-stored identifier is stored in a white list as the pre-stored identifier when the backend receives the unique identifier for the first time.
According to the embodiment of the present disclosure, the performing update verification on the signaling packet includes: analyzing the signaling message to obtain an updated version number and an updated data set; acquiring a local version number; and under the condition that the update version number is inconsistent with the local version number, replacing the local data corresponding to the local version number with the update data set.
In a second aspect of the present disclosure, a data updating method is provided, which is applied to a backend, and the method includes: receiving a long connection request from a front end, the long connection request being formed based on a time check factor; establishing a long connection with the front end based on the long connection request; under the condition that the long connection verification request is successful, responding to the operation of data updating, and packaging the changed data into a signaling message; and sending the signaling message to a front end under the condition of passing a heartbeat detection mechanism.
According to an embodiment of the present disclosure, the establishing a long connection with the front end based on the long connection request includes: analyzing the long connection request to obtain a unique identifier; and storing the unique identification as a pre-stored identification in a white list.
According to an embodiment of the present disclosure, wherein the heartbeat detection mechanism includes: receiving a heartbeat detection request data packet from the front end; analyzing the heartbeat detection request data packet to obtain the unique identifier; and sending a heartbeat detection response data packet under the condition that the unique identifier is consistent with the pre-stored identifier in the white list.
In a third aspect of the present disclosure, a data updating method is provided, the method including: the front end sends a long connection request, wherein the long connection request is formed based on a time check factor; the back end establishes a long connection with the front end based on the long connection request; the back end responds to the operation of data updating under the condition that the long connection verification request is successful, and encapsulates the changed data into a signaling message; under the condition of passing through a heartbeat detection mechanism, the back end sends the signaling message to the front end; the front end updates and checks the signaling message; and the front end updates the data of the front end based on the signaling message under the condition that the updating verification is successful.
In a fourth aspect of the present disclosure, there is provided a data update apparatus applied to a front end, the apparatus including: a long connection request sending module, configured to send a long connection request, where the long connection request is formed based on a time check factor; the heartbeat detection module is used for periodically executing a heartbeat detection mechanism of the back end under the condition that the long connection is successfully established with the back end; a signaling message receiving module, configured to receive a signaling message when the heartbeat detection mechanism passes, where the signaling message is sent by the back end in response to a data update operation; the updating and checking module is used for updating and checking the signaling message; and the data updating module is used for updating the data of the front end based on the signaling message under the condition that the updating check is successful.
According to an embodiment of the present disclosure, the apparatus further includes a long connection request forming module, configured to obtain a current timestamp; calculating a unique identifier based on the current timestamp as the time check factor; and forming the long connection request based on the unique identification.
According to the embodiment of the present disclosure, the heartbeat detection module is further configured to form a heartbeat detection request data packet based on the unique identifier; sending a heartbeat detection request data packet to the rear end based on a preset heartbeat detection period; and receiving a heartbeat detection response data packet under the condition that the back end judges that the unique identifier is consistent with the pre-stored identifier in the white list.
According to the embodiment of the disclosure, the pre-stored identifier is stored in a white list as the pre-stored identifier when the backend receives the unique identifier for the first time.
According to the embodiment of the present disclosure, the update checking module is further configured to parse the signaling message to obtain an update version number and an update data set; acquiring a local version number; and under the condition that the update version number is inconsistent with the local version number, replacing the local data corresponding to the local version number with the update data set.
In a fifth aspect of the present disclosure, there is provided a data updating apparatus, which is applied to a back end, the apparatus comprising: a long connection request receiving module, configured to receive a long connection request from a front end, where the long connection request is formed based on a time check factor; a long connection establishing module, configured to establish a long connection with the front end based on the long connection request; the data encapsulation module is used for responding to the operation of data updating and encapsulating the changed data into a signaling message under the condition that the long connection verification request is successful; and the signaling message sending module is used for sending the signaling message to the front end under the condition of passing through a heartbeat detection mechanism.
According to the embodiment of the present disclosure, the long connection establishing module is further configured to parse the long connection request to obtain a unique identifier; and storing the unique identification as a pre-stored identification in a white list.
According to an embodiment of the present disclosure, wherein the heartbeat detection mechanism includes: receiving a heartbeat detection request data packet from the front end; analyzing the heartbeat detection request data packet to obtain the unique identifier; and sending a heartbeat detection response data packet under the condition that the unique identifier is consistent with the pre-stored identifier in the white list.
In a sixth aspect of the present disclosure, there is provided an electronic device comprising: one or more processors; a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the data update method described above.
In a seventh aspect of the present disclosure, a computer-readable storage medium is further provided, which has executable instructions stored thereon, and when executed by a processor, causes the processor to execute the above data updating method.
In an eighth aspect of the present disclosure, there is also provided a computer program product comprising a computer program which, when executed by a processor, implements the above-mentioned data updating method.
In the embodiment of the disclosure, the long connection request is generated by the time check factor, so that the security of the request is improved to a certain extent; furthermore, the timeliness and flexibility of data transmission can be ensured through long connection; on the basis, the premise of data transmission is that data transmission can be realized only after the heartbeat detection mechanism passes, so that the safety of data transmission is improved. In conclusion, the processing efficiency of the back-end configuration and the front-end effectiveness is improved on the premise of not additionally increasing the system performance overhead, and the operation level and the marketing performance of an enterprise are improved.
Drawings
The foregoing and other objects, features and advantages of the disclosure will be apparent from the following description of embodiments of the disclosure, which proceeds with reference to the accompanying drawings, in which:
fig. 1 schematically shows an application scenario diagram of a data update method according to an embodiment of the present disclosure;
FIG. 2 schematically shows a flow chart of a data update method according to an embodiment of the present disclosure;
FIG. 3 schematically illustrates a flow chart of a method of forming a long connection request according to an embodiment of the disclosure;
FIG. 4 schematically shows a flow diagram of a heartbeat detection mechanism according to an embodiment of the present disclosure;
FIG. 5 schematically illustrates a flow chart of a data verification method according to an embodiment of the present disclosure;
FIG. 6 schematically shows a flow chart of a data update method according to an embodiment of the present disclosure;
FIG. 7 schematically illustrates a full flow diagram of a data update method according to an embodiment of the disclosure;
fig. 8 is a block diagram schematically illustrating a structure of a data updating apparatus according to an embodiment of the present disclosure;
FIG. 9 is a block diagram schematically illustrating another data update apparatus according to an embodiment of the present disclosure; and
FIG. 10 schematically illustrates a block diagram of an electronic device adapted to implement a data update method according to an embodiment of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is illustrative only and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It is noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of this specification and should not be interpreted in an idealized or overly formal sense.
In those instances where a convention analogous to "at least one of A, B, and C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B, and C" would include but not be limited to systems that have A alone, B alone, C alone, A and B together, A and C together, B and C together, and/or A, B, and C together, etc.).
In the prior art, when the market meets the requirement of real-time update, the following scheme is often adopted for realizing the requirement. The system sets a timing task thread at the front end, automatically initiates a request in a set time period, and synchronizes with the background in real time, for example, a page wants to read the latest operation advertisement in the background, and generally actively triggers refresh for a user, for example, opening the page, clicking a button, and the like, and also can set a mode of automatically refreshing once every 10 minutes in the page to update page data. The scheme can not achieve real-time effect of data updating, in addition, due to complex conditions such as user network abnormity and the like, the timing task is easily interrupted due to various emergency situations, and after interruption, a user cannot restart a client or a webpage to initialize the timing task, and the mechanism fails. It is also more important that the overhead of each front end is kept high if it initiates a timing task, and the higher the frequency of the timing task is, the higher the overhead of the system is.
To solve the technical problems in the prior art, an embodiment of the present disclosure provides a data updating method, which is applied to a front end, and the method includes: sending a long connection request, the long connection request being formed based on a time check factor; periodically executing a heartbeat detection mechanism with a backend in the event of a successful long connection establishment with the backend; receiving a signaling message under the condition that the heartbeat detection mechanism passes, wherein the signaling message is sent by the back end in response to the operation of data updating; updating and checking the signaling message; and under the condition that the updating check is successful, updating the data of the front end based on the signaling message.
In the embodiment of the disclosure, the long connection request is generated by the time check factor, so that the security of the request is improved to a certain extent; furthermore, the timeliness and flexibility of data transmission can be ensured through long connection; on the basis, the premise of data transmission is that data transmission can be realized only after the heartbeat detection mechanism passes, so that the safety of data transmission is improved. In conclusion, the processing efficiency of the back-end configuration and the front-end effectiveness is improved on the premise of not additionally increasing the system performance overhead, and the operation level and the marketing performance of an enterprise are improved.
Fig. 1 schematically illustrates an application scenario diagram of a data update method according to an embodiment of the present disclosure.
As shown in fig. 1, an application scenario 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104, and a server 105. Network 104 is the medium used to provide communication links between terminal devices 101, 102, 103 and server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have installed thereon various communication client applications, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 105 may be a server providing various services, such as a background management server (for example only) providing support for websites browsed by users using the terminal devices 101, 102, 103. The background management server may analyze and perform other processing on the received data such as the user request, and feed back a processing result (e.g., a webpage, information, or data obtained or generated according to the user request) to the terminal device.
It should be noted that the data updating method provided by the embodiment of the present disclosure may be generally executed by the terminals 101, 102, 103 or the server 105, respectively. Accordingly, the data updating apparatus provided by the embodiments of the present disclosure may be generally disposed in the terminals 101, 102, 103 or the server 105, respectively. The steps corresponding to the data updating method provided by the embodiment of the present disclosure may also be executed by a server or a server cluster that is different from the server 105 and is capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Correspondingly, the modules corresponding to the data updating apparatus provided by the embodiment of the present disclosure may also be disposed in a server or a server cluster different from the server 105 and capable of communicating with the terminal devices 101, 102, 103 and/or the server 105.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
The data update method of the disclosed embodiment will be described in detail below with fig. 2 to 7 based on the scenario described in fig. 1.
Fig. 2 schematically shows a flow chart of a data update method according to an embodiment of the present disclosure.
As shown in fig. 2, the data update method of this embodiment includes operations S210 to S250, and the data update method may be performed by the terminals 101, 102, 103.
In operation S210, a long connection request, which is formed based on a time check factor, is transmitted.
The data updating method of the embodiment of the disclosure can be widely applied to an instant social scene or an internet operation scene. When a user logs in or opens an application in a terminal, a front end initiates a long connection request to establish long connection with a server at a rear end, and the connection state is maintained after the long connection is established, and data transmission is realized through the established long connection.
In the connection establishment stage, the back end needs to verify the request of the front end according to a certain rule to verify the identity. For example, the long connection request is formed based on a client hardware identification, a network identification, a user identification, and the like. On the basis, the original long connection request can be further packaged and encrypted, or some factors are used as part of encryption to form the encrypted long connection request, and for the latter long connection request, the long connection request is formed by a time check factor which is used as the encryption factor and is used as part of the long connection request composition based on time so as to realize the check function, and meanwhile, different long connection requests can be identified.
Taking Socket as an example, in the setup phase, the front end may send a Socket long connection request to the backend through a method provided by Socket connection when the front end is first opened by introducing a Socket sdk or a websocket sdk.
Due to the characteristics of the long connection mechanism, generally, in the data transmission stage after connection establishment, the user identity is not checked any more, and once the long connection is falsely used, potential safety hazards may be generated.
Fig. 3 schematically illustrates a flow chart of a method of forming a long connection request according to an embodiment of the present disclosure.
As shown in fig. 3, the method of forming the long connection request of this embodiment includes operations S310 to S330.
In operation S310, a current time is acquired.
In operation S320, a unique identifier is calculated based on the current timestamp as the time check factor.
In operation S330, the long connection request is formed based on the unique identification.
Specifically, in the connection establishment stage, the front end obtains an initial unique identifier through encryption and confusion. For example, the unique identifier may be a token. The initial unique identifier may be used during multiple long connection setups or during connection phase checks.
In order to ensure that the unique identifiers of the same device are different each time a connection is established, it is necessary to further form the unique identifiers of different long connections by using the current timestamp as an encryption factor on the basis of the initial unique identifier. Therefore, once the back end finds that the unique identifier is changed, the connection can be interrupted, and a message for terminating the connection at the front end or a message for newly establishing the connection at the front end is returned.
In operation S220, in case of successfully establishing a long connection with a backend, a heartbeat detection mechanism with the backend is periodically performed.
The heartbeat detection mechanism can ensure normal state of long connection, for example, normal state of network, and data security in the connection process.
In operation S230, a signaling message is received when the heartbeat detection mechanism passes, where the signaling message is sent by the backend in response to the data update after the operation.
It will be appreciated that the heartbeat detection mechanism is one mechanism involving front-end and back-end interactions, involving two execution bodies, and will be disclosed in detail below with respect to the heartbeat detection mechanism on the front-end side.
Fig. 4 schematically shows a flow chart of a heartbeat detection mechanism according to an embodiment of the present disclosure.
As shown in fig. 4, the data verification method of this embodiment includes operations S410 to S430.
In operation S410, a heartbeat detection request packet is formed based on the unique identifier.
In operation S420, a heartbeat detection request packet is sent to the backend based on a preset heartbeat detection period.
In operation S430, a heartbeat detection response packet is received when the back end determines that the unique identifier is consistent with a pre-stored identifier in a white list.
In order to ensure that the long connection state is normal, the front end sends the heartbeat detection data packet to the server at the back end through the long connection channel within a preset period, where the preset period may be defined by a developer, for example, the heartbeat detection data packet may be sent once every second. And after receiving the heartbeat detection response data packet in the preset time, reserving corresponding processing resources for the rear end to ensure that the data can be received.
Wherein, the front end receives the heartbeat detection response data packet to mark the heartbeat detection mechanism between the two to pass, and the connection between the two is normal. That is, the premise for the front end to receive data is that the heartbeat detection mechanism passes.
Of course, in the case that the heartbeat detection mechanism fails, the back end does not return a front-end heartbeat detection response packet. At this time, after the front end does not receive the heartbeat detection response data packet within a certain time, the front end tries to send the heartbeat detection request data packet again, and tries to restart the long connection and send the long connection request again after receiving the heartbeat detection response data packet for a plurality of times.
Specifically, when the long connection is disconnected due to an abnormal disconnection, the front end continuously executes a reconnection mechanism, and the reconnection at a proper time point is guaranteed to be successful under the condition that no dead cycle occurs. For example, first, when a client or a web page is opened, connection state detection is performed (when a heartbeat detection reply packet is not received within a certain period, it is identified as abnormal), and reconnection is triggered if the heartbeat detection reply packet is abnormal. If the connection fails due to network interruption in the using process, reconnection is automatically triggered every 10 seconds, reconnection is abandoned if the connection cannot be recovered after reconnection is carried out for 6 times (60 seconds), the user is prompted to fail in connection, and the user is supported to manually click a button to trigger reconnection at the moment. In addition, if the dependence of part of service functions on the connection is stronger, detection is added at a function entrance to ensure that the functions are used on the premise of normal connection.
When the front end is in an abnormal state or the service adjustment is not carried out with long connection data updating, the terminal can be set to be incapable of receiving the hop detection request data packet within a certain time. At this time, the long connection is considered to be disconnected, and the transmission data at the back end is not synchronized any more. By adopting the method for not sending the heartbeat detection request data packet, long connection can be stopped unilaterally, and flexible configuration is facilitated.
According to the embodiment of the disclosure, the pre-stored identifier is stored in a white list as the pre-stored identifier when the backend receives the unique identifier for the first time.
It can be understood that, the content of the verification at the back end side is that whether the unique identifier corresponding to the front end received in the verification establishing stage is consistent with the unique identifier corresponding to the front end received in the transmission stage.
In operation S240, an update check is performed on the signaling packet.
The updating check has the function of judging whether the data sent by the back end is the data which accords with the updating rule.
Fig. 5 schematically shows a flow chart of a data verification method according to an embodiment of the present disclosure.
As shown in fig. 5, the data verification method of this embodiment includes operations S510 to S530.
In operation S510, the signaling message is parsed to obtain an update version number and an update data set.
In operation S520, a local version number is acquired.
In operation S530, if the update version number is not consistent with the local version number, the local data corresponding to the local version number is replaced with the update data set.
In operation S250, if the update check is successful, the data of the front end is updated based on the signaling message.
Specifically, the version number of the message is compared with the version number of the local data or the data set, if the version number is updated, the original data is replaced, the data synchronization action is completed, and if the version number is not changed, the message is discarded, and the stock data is still used.
For example, taking an advertising operation scenario as an example, the update data set may be as follows:
Figure BDA0003917173610000111
/>
Figure BDA0003917173610000121
for example, whether the version numbers of the corresponding advertisements are consistent or not can be judged through the advertisement names or the URLs, and if the version numbers of the corresponding advertisements are inconsistent, the corresponding advertisement contents are updated.
In the embodiment of the disclosure, the long connection request is generated by the time check factor, so that the security of the request is improved to a certain extent; furthermore, the timeliness and flexibility of data transmission can be ensured through long connection; on the basis, the premise of data transmission is that data transmission can be realized only after the heartbeat detection mechanism passes, so that the safety of data transmission is improved. In conclusion, the processing efficiency of the back-end configuration and the front-end effectiveness is improved on the premise of not additionally increasing the system performance overhead, and the operation level and the marketing performance of an enterprise are improved.
Hereinafter, a data update method of the back end side of the embodiment of the present disclosure will be described in detail with reference to fig. 6.
Fig. 6 schematically shows a flow chart of a data update method according to an embodiment of the present disclosure.
As shown in fig. 6, the data updating method of this embodiment includes operations S610 to S640. The data update method may be performed by the server 105.
In operation S610, a long connection request from a front end is received, the long connection request being formed based on a time check factor.
According to an embodiment of the present disclosure, the establishing a long connection with the front end based on the long connection request includes: analyzing the long connection request to obtain a unique identifier; and storing the unique identification as a pre-stored identification in a white list.
In operation S620, a long connection with the head end is established based on the long connection request.
In operation S630, in case that the long connection check request is successful, a signaling message is encapsulated with the changed data in response to the operation of data updating.
In operation S640, the signaling message is sent to the front end through a heartbeat detection mechanism.
According to an embodiment of the present disclosure, wherein the heartbeat detection mechanism includes: receiving a heartbeat detection request data packet from the front end; analyzing the heartbeat detection request data packet to obtain the unique identifier; and sending a heartbeat detection response data packet under the condition that the unique identifier is consistent with the pre-stored identifier in the white list.
When the back end is in an abnormal state or the service adjustment is not performed with long connection data updating, the server at the back end can be set to be incapable of receiving the heartbeat detection request data packet within a certain time, or the server at the back end discards the received heartbeat detection request data packet within a certain time. At this point, the long connection is considered to be broken and no longer transmits data for the head end. By adopting the method for replying the data packet without replying the heartbeat detection, the long connection can be stopped unilaterally, and flexible configuration is facilitated.
FIG. 7 schematically shows a full flow diagram of a data update method according to an embodiment of the present disclosure.
As shown in fig. 7, the data updating method of this embodiment includes at least a front end 710 and a back end 720, and the data updating method of this embodiment includes at least operations S701 to S708.
In operation S701, the front end initiates a long connection request.
In operation S702, the backend receives a long connection request.
In operation S703, the backend establishes a long connection.
In operation S704, the front end establishes a long connection.
It is understood that the above operations S701 to S704 are directed to the establishment phase of the long connection.
In operation S705, when the back end generates a data change, the changed data is encapsulated to obtain a signaling message.
In operation S706, the back end sends a signaling message.
In operation S707, the front end receives a signaling message.
In operation S708, the front end updates the received signaling message.
The mechanism of heartbeat detection is used in operations S705 to S708.
The front end establishes Socket long connection with the background during initial, then requests for communication each time, connection heartbeat is kept disconnected after a user closes a front end page, and the back end releases connection resources after monitoring connection failure. During the connection effective period, the data change of the background can be informed to the front end in real time, and the front end can determine whether to update the local data according to actual needs without user triggering or timing tasks.
Taking an advertisement operation scene as an example, an enterprise provides service for a guest through an App, an App home page provides a carousel advertisement area configured by background operators, when a user starts the App, a client establishes Socket long connection with a server, if the advertisement is displayed on the App home page at present, the App needs to be closed again and opened for the user in the original scheme, the client triggers an advertisement updating action, and the background returns the data to the client for updating after inquiring the data. According to the scheme, the user can stay on the App page without any operation, the server directly pushes the new advertisement to the client through Socket long connection after generating data change, the client completes updating locally, the user does not need to do any operation in the whole process, the advertisement can be immediately seen to be updated when the user stays on the current page, and the purpose of real-time operation effect is achieved.
In the embodiment of the disclosure, the long connection request is generated by the time check factor, so that the security of the request is improved to a certain extent; furthermore, the timeliness and flexibility of data transmission can be ensured through long connection; on the basis, the premise of data transmission is that data transmission can be realized only after the heartbeat detection mechanism passes, so that the safety of data transmission is improved. In conclusion, the processing efficiency of the back-end configuration and the front-end effectiveness is improved on the premise of not additionally increasing the system performance overhead, and the operation level and the marketing performance of an enterprise are improved.
Based on the data updating method, the disclosure also provides two data updating devices. The apparatus will be described in detail below with reference to fig. 8 and 9.
Fig. 8 schematically shows a block diagram of a data update apparatus according to an embodiment of the present disclosure.
As shown in fig. 8, the data updating apparatus 800 of this embodiment includes a long connection request sending module 810, a heartbeat detecting module 820, a signaling message receiving module 830, an update checking module 840, and a data updating module 850. The data update apparatus 800 of this embodiment is applied to the terminals 101, 102, 103.
The long connection request sending module 810 is configured to send a long connection request, which is formed based on the time check factor. In an embodiment, the long connection request sending module 810 may be configured to perform the operation S210 described above, and is not described herein again.
The heartbeat detection module 820 is configured to periodically perform a heartbeat detection mechanism with the backend if a long connection is successfully established with the backend. In an embodiment, the heartbeat detection module 820 may be configured to perform the operation S220 described above, which is not described herein again.
The signaling message receiving module 830 is configured to receive a signaling message when the heartbeat detection mechanism passes, where the signaling message is sent by the backend in response to the operation of data update. In an embodiment, the signaling message receiving module 830 may be configured to perform the operation S230 described above, which is not described herein again.
The update checking module 840 is configured to perform update checking on the signaling message. In an embodiment, the update checking module 840 may be configured to perform the operation S240 described above, which is not described herein again.
The data updating module 850 is configured to update the front-end data based on the signaling message if the update check is successful. In an embodiment, the data update module 850 may be configured to perform the operation S250 described above, which is not described herein again.
According to the embodiment of the present disclosure, the apparatus further includes a long connection request forming module, configured to obtain a current timestamp; calculating a unique identifier based on the current timestamp as the time check factor; and forming the long connection request based on the unique identification.
According to an embodiment of the present disclosure, the heartbeat detection module 820 is further configured to form a heartbeat detection request data packet based on the unique identifier; sending a heartbeat detection request data packet to the rear end based on a preset heartbeat detection period; and receiving a heartbeat detection response data packet under the condition that the back end judges that the unique identifier is consistent with the pre-stored identifier in the white list.
According to the embodiment of the disclosure, the pre-stored identifier is stored in a white list as the pre-stored identifier when the backend receives the unique identifier for the first time.
According to the embodiment of the present disclosure, the update checking module 840 is further configured to analyze the signaling message to obtain an update version number and an update data set; acquiring a local version number; and under the condition that the update version number is inconsistent with the local version number, replacing the local data corresponding to the local version number with the update data set.
According to the embodiment of the present disclosure, any multiple modules of the long connection request sending module 810, the heartbeat detecting module 820, the signaling message receiving module 830, the update checking module 840, and the data updating module 850 may be combined into one module to be implemented, or any one module thereof may be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of the other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the long connection request sending module 810, the heartbeat detection module 820, the signaling message receiving module 830, the update checking module 840, and the data updating module 850 may be implemented at least partially as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented by hardware or firmware in any other reasonable manner of integrating or packaging a circuit, or implemented by any one of three implementation manners of software, hardware, and firmware, or implemented by a suitable combination of any several of them. Alternatively, at least one of the long connection request sending module 810, the heartbeat detection module 820, the signaling message receiving module 830, the update checking module 840 and the data updating module 850 may be at least partially implemented as a computer program module, which, when executed, may perform a corresponding function.
Fig. 9 schematically shows a block diagram of another data update apparatus according to an embodiment of the present disclosure.
As shown in fig. 9, the data updating apparatus 900 of this embodiment includes a long connection request receiving module 910, a long connection establishing module 920, a data encapsulating module 930, and a signaling message sending module 940. The data update apparatus 900 of this embodiment is applied to the server 105.
The long connection request receiving module 910 is configured to receive a long connection request from a front end, where the long connection request is formed based on a time check factor. In an embodiment, the long connection request receiving module 910 may be configured to perform the operation S610 described above, which is not described herein again.
The long connection establishing module 920 is configured to establish a long connection with the front end based on the long connection request. In an embodiment, the long connection establishing module 920 may be configured to perform the operation S620 described above, which is not described herein again.
The data encapsulating module 930 is configured to encapsulate the changed data into a signaling message in response to the operation of data update when the long connection check request is successful. In an embodiment, the data encapsulation module 930 may be configured to perform the operation S630 described above, which is not described herein again.
The signaling message sending module 940 is configured to send the signaling message to the front end through a heartbeat detection mechanism. In an embodiment, the signaling message sending module 940 may be configured to perform the operation S640 described above, which is not described herein again.
According to an embodiment of the present disclosure, the long connection establishing module 920 is further configured to parse the long connection request to obtain a unique identifier; and storing the unique identification as a pre-stored identification in a white list.
According to an embodiment of the present disclosure, wherein the heartbeat detection mechanism includes: receiving a heartbeat detection request data packet from the front end; analyzing the heartbeat detection request data packet to obtain the unique identifier; and sending a heartbeat detection response data packet under the condition that the unique identifier is consistent with the pre-stored identifier in the white list.
According to the embodiment of the present disclosure, any multiple modules of the long connection request receiving module 910, the long connection establishing module 920, the data encapsulating module 930, and the signaling message sending module 940 may be combined into one module to be implemented, or any one of the modules may be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of other modules and implemented in one module. According to the embodiment of the present disclosure, at least one of the long connection request receiving module 910, the long connection establishing module 920, the data encapsulating module 930, and the signaling message sending module 940 may be implemented at least partially as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented by hardware or firmware in any other reasonable manner of integrating or packaging a circuit, or implemented by any one of three implementation manners of software, hardware, and firmware, or an appropriate combination of any several of them. Alternatively, at least one of the long connection request receiving module 910, the long connection establishing module 920, the data encapsulating module 930 and the signaling message sending module 940 may be implemented at least partially as a computer program module, which when executed, may perform a corresponding function.
FIG. 10 schematically shows a block diagram of an electronic device adapted to implement a data update method according to an embodiment of the present disclosure.
As shown in fig. 10, an electronic device 1000 according to an embodiment of the present disclosure includes a processor 1001 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 1002 or a program loaded from a storage section 1008 into a Random Access Memory (RAM) 1003. Processor 1001 may include, for example, a general purpose microprocessor (e.g., CPU), an instruction set processor and/or associated chipset, and/or a special purpose microprocessor (e.g., application Specific Integrated Circuit (ASIC)), among others. The processor 1001 may also include onboard memory for caching purposes. The processor 1001 may include a single processing unit or multiple processing units for performing different actions of a method flow according to embodiments of the present disclosure.
In the RAM 1003, various programs and data necessary for the operation of the electronic apparatus 1000 are stored. The processor 1001, ROM 1002, and RAM 1003 are connected to each other by a bus 1004. The processor 1001 performs various operations of the method flow according to the embodiments of the present disclosure by executing programs in the ROM 1002 and/or the RAM 1003. Note that the programs may also be stored in one or more memories other than the ROM 1002 and the RAM 1003. The processor 1001 may also perform various operations of the method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
Electronic device 1000 may also include an input/output (I/O) interface 1005, the input/output (I/O) interface 1005 also being connected to bus 1004, according to an embodiment of the present disclosure. Electronic device 1000 may also include one or more of the following components connected to I/O interface 1005: an input portion 1006 including a keyboard, a mouse, and the like; an output section 1007 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 1008 including a hard disk and the like; and a communication section 1009 including a network interface card such as a LAN card, a modem, or the like. The communication section 1009 performs communication processing via a network such as the internet. The driver 1010 is also connected to the I/O interface 1005 as necessary. A removable medium 1011 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 1010 as necessary, so that a computer program read out therefrom is mounted into the storage section 1008 as necessary.
The present disclosure also provides a computer-readable storage medium, which may be contained in the apparatus/device/system described in the above embodiments; or may exist separately and not be assembled into the device/apparatus/system. The computer-readable storage medium carries one or more programs which, when executed, implement the method according to an embodiment of the disclosure.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example but is not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. For example, according to embodiments of the present disclosure, a computer-readable storage medium may include the ROM 1002 and/or the RAM 1003 described above and/or one or more memories other than the ROM 1002 and the RAM 1003.
Embodiments of the present disclosure also include a computer program product comprising a computer program containing program code for performing the method illustrated in the flow chart. When the computer program product runs in a computer system, the program code is used for causing the computer system to realize the method provided by the embodiment of the disclosure.
The above-described functions defined in the system/apparatus of the embodiments of the present disclosure are performed when the computer program is executed by the processor 1001. The systems, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In one embodiment, the computer program may be hosted on a tangible storage medium such as an optical storage device, a magnetic storage device, or the like. In another embodiment, the computer program may also be transmitted in the form of a signal on a network medium, distributed, downloaded and installed via the communication part 1009, and/or installed from the removable medium 1011. The computer program containing program code may be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
In such an embodiment, the computer program may be downloaded and installed from the network through the communication part 1009 and/or installed from the removable medium 1011. The computer program performs the above-described functions defined in the system of the embodiment of the present disclosure when executed by the processor 1001. The systems, devices, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In accordance with embodiments of the present disclosure, program code for executing computer programs provided by embodiments of the present disclosure may be written in any combination of one or more programming languages, and in particular, these computer programs may be implemented using high level procedural and/or object oriented programming languages, and/or assembly/machine languages. The programming language includes, but is not limited to, programming languages such as Java, C + +, python, the "C" language, or the like. The program code may execute entirely on the user's computing device, partly on the user's device, partly on a remote computing device, or entirely on the remote computing device or server. In situations involving remote computing devices, the remote computing devices may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to external computing devices (e.g., through the internet using an internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Those skilled in the art will appreciate that various combinations and/or combinations of features recited in the various embodiments and/or claims of the present disclosure can be made, even if such combinations or combinations are not expressly recited in the present disclosure. In particular, various combinations and/or combinations of the features recited in the various embodiments and/or claims of the present disclosure may be made without departing from the spirit or teaching of the present disclosure. All such combinations and/or associations are within the scope of the present disclosure.
The embodiments of the present disclosure are described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described separately above, this does not mean that the measures in the embodiments cannot be used advantageously in combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be devised by those skilled in the art without departing from the scope of the present disclosure, and such alternatives and modifications are intended to be within the scope of the present disclosure.

Claims (14)

1. A data update method, the method being applied to a front end, the method comprising:
sending a long connection request, the long connection request being formed based on a time check factor;
periodically executing a heartbeat detection mechanism with a backend in the event of a successful long connection establishment with the backend;
receiving a signaling message under the condition that the heartbeat detection mechanism passes, wherein the signaling message is sent by the back end in response to the operation of data updating;
updating and checking the signaling message; and
and under the condition that the updating check is successful, updating the data of the front end based on the signaling message.
2. The method of claim 1, wherein the method of forming the long connection request comprises:
acquiring a current timestamp;
calculating a unique identifier based on the current timestamp as the time check factor; and
forming the long connection request based on the unique identification.
3. The method of claim 2, wherein the periodically performing a heartbeat detection mechanism with the backend comprises:
forming a heartbeat detection request data packet based on the unique identifier;
sending a heartbeat detection request data packet to the rear end based on a preset heartbeat detection period; and
and receiving a heartbeat detection response data packet under the condition that the back end judges that the unique identifier is consistent with the pre-stored identifier in the white list.
4. The method of claim 3, wherein the pre-stored identity is white listed as the unique identity when the backend first receives the unique identity.
5. The method according to any of claims 1-4, wherein said performing an update check on said signaling message comprises:
analyzing the signaling message to obtain an updated version number and an updated data set;
acquiring a local version number; and
and under the condition that the update version number is inconsistent with the local version number, replacing local data corresponding to the local version number with the update data set.
6. A data update method, the method being applied to a backend, the method comprising:
receiving a long connection request from a front end, the long connection request being formed based on a time check factor;
establishing a long connection with the front end based on the long connection request;
under the condition that the long connection verification request is successful, responding to the operation of data updating, and packaging the changed data into a signaling message; and
and under the condition of passing through a heartbeat detection mechanism, sending the signaling message to a front end.
7. The method of claim 6, wherein the establishing a long connection with the front end based on the long connection request comprises:
analyzing the long connection request to obtain a unique identifier; and
and storing the unique identifier as a pre-stored identifier in a white list.
8. The method of claim 7, wherein the heartbeat detection mechanism comprises:
receiving a heartbeat detection request data packet from the front end;
analyzing the heartbeat detection request data packet to obtain the unique identifier;
and sending a heartbeat detection response data packet under the condition that the unique identifier is consistent with the pre-stored identifier in the white list.
9. A method of data updating, the method comprising:
the method comprises the steps that a front end sends a long connection request, wherein the long connection request is formed based on a time check factor;
the back end establishes a long connection with the front end based on the long connection request;
the back end responds to the operation of data updating under the condition that the long connection verification request is successful, and encapsulates the changed data into a signaling message;
under the condition of passing through a heartbeat detection mechanism, the back end sends the signaling message to the front end;
the front end updates and checks the signaling message; and
and the front end updates the data of the front end based on the signaling message under the condition that the updating check is successful.
10. A data update apparatus, the apparatus being applied to a front end, the apparatus comprising:
a long connection request sending module, configured to send a long connection request, where the long connection request is formed based on a time check factor;
the heartbeat detection module is used for periodically executing a heartbeat detection mechanism of the back end under the condition that the long connection is successfully established with the back end;
a signaling message receiving module, configured to receive a signaling message when the heartbeat detection mechanism passes, where the signaling message is sent by the back end in response to a data update operation;
the updating and checking module is used for updating and checking the signaling message; and
and the data updating module is used for updating the data of the front end based on the signaling message under the condition that the updating check is successful.
11. A data updating apparatus applied to a back end, the apparatus comprising:
a long connection request receiving module, configured to receive a long connection request from a front end, where the long connection request is formed based on a time check factor;
a long connection establishing module, configured to establish a long connection with the front end based on the long connection request;
the data encapsulation module is used for responding to the operation of data updating under the condition that the long connection verification request is successful and encapsulating the changed data into a signaling message; and
and the signaling message sending module is used for sending the signaling message to the front end under the condition of a heartbeat detection mechanism.
12. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method of any of claims 1-8.
13. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to perform the method according to any one of claims 1 to 8.
14. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 8.
CN202211352749.3A 2022-10-31 2022-10-31 Data updating method, device, equipment, medium and program product Pending CN115913944A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211352749.3A CN115913944A (en) 2022-10-31 2022-10-31 Data updating method, device, equipment, medium and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211352749.3A CN115913944A (en) 2022-10-31 2022-10-31 Data updating method, device, equipment, medium and program product

Publications (1)

Publication Number Publication Date
CN115913944A true CN115913944A (en) 2023-04-04

Family

ID=86487538

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211352749.3A Pending CN115913944A (en) 2022-10-31 2022-10-31 Data updating method, device, equipment, medium and program product

Country Status (1)

Country Link
CN (1) CN115913944A (en)

Similar Documents

Publication Publication Date Title
US10965772B2 (en) Interface invocation method and apparatus for hybrid cloud
US9544288B2 (en) Messaging gateway
CN103167031A (en) Communication between Web applications
CN111159614A (en) Webpage resource acquisition method and device
EP3528474B1 (en) Webpage advertisement anti-shielding methods and content distribution network
CN113900834B (en) Data processing method, device, equipment and storage medium based on Internet of things technology
CN104967644A (en) Message push method, apparatus and system
CN106911666B (en) Wearable intelligent device and message processing method and system thereof
CN112202744B (en) Multi-system data communication method and device
CN112015383A (en) Login method and device
CN109981546B (en) Method and device for acquiring remote call relation between application modules
CN110855655B (en) Information verification method, device, equipment and storage medium
US9763082B2 (en) Optimizing setup for wireless devices
CN111666567A (en) Detection method, device, computer program and medium for malicious modification of application program
CN114257632B (en) Method and device for reconnecting broken wire, electronic equipment and readable storage medium
CN115913944A (en) Data updating method, device, equipment, medium and program product
US20220066792A1 (en) Methods for Information Processing and In-Vehicle Electronic Device
CN113709136B (en) Access request verification method and device
CN112953719B (en) Token authentication method and device
CN113824675B (en) Method and device for managing login state
CN114518909A (en) Authorization information configuration method, device, equipment and storage medium based on API gateway
CN115292440A (en) Remote guidance method, apparatus, device and medium
EP4053696A1 (en) Information processing method, device, and computer storage medium
CN111897620A (en) Interaction method and device and electronic equipment
CN114979004B (en) Information processing method, device, equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination