CN111628913B - Online time length determining method and device, readable medium and electronic equipment - Google Patents

Online time length determining method and device, readable medium and electronic equipment Download PDF

Info

Publication number
CN111628913B
CN111628913B CN202010477940.5A CN202010477940A CN111628913B CN 111628913 B CN111628913 B CN 111628913B CN 202010477940 A CN202010477940 A CN 202010477940A CN 111628913 B CN111628913 B CN 111628913B
Authority
CN
China
Prior art keywords
request
time
sequence number
message
determining
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.)
Active
Application number
CN202010477940.5A
Other languages
Chinese (zh)
Other versions
CN111628913A (en
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.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
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 Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202010477940.5A priority Critical patent/CN111628913B/en
Publication of CN111628913A publication Critical patent/CN111628913A/en
Application granted granted Critical
Publication of CN111628913B publication Critical patent/CN111628913B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0805Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/535Tracking the activity of the user
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/54Presence management, e.g. monitoring or registration for receipt of user log-on information, or the connection status of the users

Abstract

The disclosure relates to a method, a device, a readable medium and an electronic device for determining online time length, wherein the method comprises the following steps: receiving a message request sent by a terminal device according to a request period, wherein the message request comprises a request serial number, the request serial number is used for indicating the sending times of the message request sent by the terminal device, determining the latest request time according to whether the request serial number is matched with a preset sampling interval, taking the difference between the latest request time and the initial request time as the online time of the terminal device, and the initial request time is the time for the terminal device to send the message request for the first time. The method and the device determine the online time according to the request sequence number and the sampling interval in the message request sent by the terminal equipment, can reduce the calculated amount of the server for calculating the online time, and simultaneously ensure the stability and the accuracy of the online time.

Description

Online time length determining method and device, readable medium and electronic equipment
Technical Field
The present disclosure relates to the field of electronic information technologies, and in particular, to a method and an apparatus for determining an online duration, a readable medium, and an electronic device.
Background
With the continuous development of electronic information technology, various Application programs (english: Application, abbreviation: APP) appear in the Application market to meet the diversified demands of users. When evaluating an application or analyzing the behavior of a user of the application, statistics on the online time of the user using the application are generally required.
For real-time message software capable of providing interaction for users, a user terminal can regularly send a request to a message server according to a fixed time interval so as to acquire the latest message. The message server records the time when the user terminal sends a request to the message server each time in a request log to calculate the online time of each user terminal. When a large number of user terminals access the message server, the online time of each user terminal is counted to bring too high calculation amount, so the server usually randomly samples in a request log, and randomly calculates the online time of part of the user terminals, so that the problems that some user terminals are not sampled all the time, and the corresponding online time is unstable and inaccurate may exist.
Disclosure of Invention
This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
In a first aspect, the present disclosure provides a method for determining an online duration, where the method includes:
receiving a message request sent by a terminal device according to a request period, wherein the message request comprises a request sequence number which is used for indicating the sending times of the message request sent by the terminal device;
determining the latest request time according to whether the request sequence number is matched with a preset sampling interval;
and taking the difference between the latest request time and the initial request time as the online time of the terminal equipment, wherein the initial request time is the time when the terminal equipment sends the message request for the first time.
In a second aspect, the present disclosure provides an apparatus for determining an online time period, the apparatus comprising:
a receiving module, configured to receive a message request sent by a terminal device according to a request period, where the message request includes a request sequence number, and the request sequence number is used to indicate the number of times the terminal device has sent the message request;
the first determining module is used for determining the latest request time according to whether the request sequence number is matched with a preset sampling interval;
and the second determining module is used for taking the difference between the latest request time and the initial request time as the online time of the terminal equipment, wherein the initial request time is the time when the terminal equipment sends the message request for the first time.
In a third aspect, the present disclosure provides a computer readable medium having stored thereon a computer program which, when executed by a processing apparatus, performs the steps of the method of the first aspect of the present disclosure.
In a fourth aspect, the present disclosure provides an electronic device comprising:
a storage device having a computer program stored thereon;
processing means for executing the computer program in the storage means to implement the steps of the method of the first aspect of the present disclosure.
Through the technical scheme, the server firstly receives the message request sent by the terminal equipment according to the request period, wherein the message request comprises the request sequence number used for indicating the sending times of the message request sent by the terminal equipment. And finally, taking the difference between the latest request time and the initial request time of the first message sending request of the terminal equipment as the online time of the terminal equipment. According to the method and the device, after the server receives the message request sent by the terminal equipment, the online time is determined according to the sampling interval and the request serial number included in the message request, the calculated amount of the server for calculating the online time can be reduced, and meanwhile the stability and the accuracy of the online time of the terminal equipment are guaranteed.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale. In the drawings:
FIG. 1 is a schematic diagram of a terminal device and server deployment;
FIG. 2 is a flow diagram illustrating a method for determining an online time duration in accordance with an exemplary embodiment;
FIG. 3 is a flow diagram illustrating another online time duration determination method in accordance with an exemplary embodiment;
FIG. 4 is a flow diagram illustrating another online time duration determination method in accordance with an exemplary embodiment;
FIG. 5 is a flow diagram illustrating another online time duration determination method in accordance with an exemplary embodiment;
FIG. 6 is a flow diagram illustrating another online time duration determination method in accordance with an exemplary embodiment;
FIG. 7 is a flow diagram illustrating another online time duration determination method in accordance with an exemplary embodiment;
FIG. 8 is a flow diagram illustrating another online time duration determination method in accordance with an exemplary embodiment;
FIG. 9 is a block diagram illustrating an online time duration determination apparatus in accordance with an exemplary embodiment;
FIG. 10 is a block diagram illustrating another online time duration determination apparatus in accordance with an exemplary embodiment;
FIG. 11 is a block diagram illustrating another online time duration determination apparatus in accordance with an exemplary embodiment;
FIG. 12 is a block diagram illustrating another online time duration determination apparatus in accordance with an exemplary embodiment;
FIG. 13 is a block diagram illustrating another online time duration determination apparatus in accordance with an exemplary embodiment;
FIG. 14 is a block diagram of an electronic device shown in accordance with an example embodiment.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
Before introducing the online duration determining method, the online duration determining device, the readable medium, and the electronic device provided by the present disclosure, an application scenario related to various embodiments of the present disclosure is first introduced. The application scenario may include a terminal device and a server, and data transmission may be performed between the terminal device and the server. The terminal device may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle-mounted terminal (e.g., a car navigation terminal), etc., and a fixed terminal such as a digital TV, a desktop computer, etc., among others. The server may be a message server, for example, which may include but is not limited to: an entity server, a server cluster or a cloud server, etc. In a specific implementation scenario, one or more terminal devices may be included, as shown in fig. 1, data transmission may be performed between multiple terminal devices through a server, so as to achieve that synchronized content is displayed on each terminal device. In the embodiments provided in the present disclosure, the execution subject may be the server described above.
Fig. 2 is a flowchart illustrating a method for determining an online duration according to an exemplary embodiment, where as shown in fig. 2, the method may be applied to a server, and specifically includes the following steps:
step 101, receiving a message request sent by a terminal device according to a request cycle, where the message request includes a request sequence number, and the request sequence number is used to indicate the number of times the terminal device has sent the message request.
For example, when the terminal device runs real-time message software (such as chat software, game software, live broadcast software, etc.), the terminal device periodically sends a message request to the server according to a fixed request period so as to request the server for the latest message directed to the terminal device. It can be understood that a message pull mode is adopted between the terminal device and the server to realize data transmission. The message request includes a request sequence number, which can indicate the number of times the terminal device has sent the message request. It is understood that the request sequence number is counted by the server and fed back to the terminal device to indicate that the terminal device has sent several message requests to the server before the current time. For example, the request sequence number may be sent to the terminal device by the server after receiving a message request sent by the terminal device in the last request period. The initial value of the request sequence number may be 0, that is, when the terminal device sends the message request to the server for the first time, the request sequence number fed back by the server has not been received yet, and then the request sequence number is 0, which indicates that the terminal device has not sent the message request to the server before that. After receiving the message request, the server may obtain a request sequence number from the message request.
It should be noted that the terminal device may be one or more terminal devices, and in order to enable the server to distinguish which terminal device the message request is sent by, the message request may further include a device identification code of the terminal device that sent the message request. The device identification code can uniquely identify the terminal device, for example: may be the IMEI (english: International Mobile Equipment Identity, chinese: International Mobile Equipment Identity).
And step 102, determining the latest request time according to whether the request sequence number is matched with a preset sampling interval.
For example, after receiving the request sequence number in the message request, the server may first determine whether the request sequence number matches a preset sampling interval, and then select a different policy for determining the latest request time according to a matching result. The preset sampling interval (for example, may be 5) may be understood as an update period of the latest request time, that is, the latest request time is updated once every time the terminal device sends a message request at the sampling interval. Correspondingly, the request sequence number matches the sampling interval, indicating that the request sequence number is an integer multiple of the sampling interval, and the request sequence number does not match the sampling interval, indicating that the request sequence number is not an integer multiple of the sampling interval. In this way, the current time (i.e., the time at which the server receives the message request) can be taken as the latest request time in the case where the request sequence number matches the sampling interval. And under the condition that the request sequence number is not matched with the sampling interval, keeping the latest request time unchanged, namely not updating the latest request time, and determining the latest request time by the server when the latest request time is still the last request period. In another implementation manner, the latest request time may be kept unchanged when the request sequence number matches the sampling interval, and the current time may be used as the latest request time when the request sequence number does not match the sampling interval.
And 103, taking the difference between the latest request time and the initial request time as the online time of the terminal equipment, wherein the initial request time is the time when the terminal equipment sends the message request for the first time.
For example, if the latest request time is not updated in step 102, the online time of the terminal device remains unchanged, and no processing may be performed at this time, which correspondingly reduces the calculation amount of the server. If the latest request time is updated in step 102, the difference between the updated latest request time and the initial request time (i.e. the time when the terminal device first sends the message request) is used as the online time of the terminal device, so that the terminal device updates the online time according to the sampling interval, and the accuracy of the online time can be kept within a preset range, where the preset range can be determined according to the request period and the sampling interval, for example, the request period is 1s, and the sampling interval is 3, and then the preset range can be ± 3 s.
It should be noted that, in the embodiment of the present disclosure, the online time of the terminal device is counted in a process of starting the real-time message software on the terminal device. If the real-time message software on the terminal equipment is closed or the time for the real-time message software to enter the background to run exceeds the preset time (for example, 2min), the server does not receive the message request sent by the terminal equipment any more, the server considers that the terminal equipment is off-line at the moment, and clears the initial request time and the latest request time corresponding to the terminal equipment, and can also store the last determined on-line time as historical on-line time and clear the on-line time.
In this way, compared with a manner in which the server counts the online time of the terminal device each time the server receives the message request in the prior art, by setting the sampling interval in this embodiment, the number of times that the server calculates the online time of each terminal device is reduced, thereby reducing the total calculation amount of the server. Further, compared with the prior art in which the server randomly samples in the request log and randomly calculates the online time of part of the user terminals, in this embodiment, by setting the request sequence number, it can be ensured that each terminal device can update the latest request time according to the sampling interval, thereby ensuring the stability and accuracy of the online time of each terminal device.
In summary, in the present disclosure, a server first receives a message request sent by a terminal device according to a request cycle, where the message request includes a request sequence number used for indicating the number of times that the terminal device has sent the message request. And finally, taking the difference between the latest request time and the initial request time of the first message sending request of the terminal equipment as the online time of the terminal equipment. According to the method and the device, after the server receives the message request sent by the terminal equipment, the online time is determined according to the sampling interval and the request serial number included in the message request, the calculated amount of the server for calculating the online time can be reduced, and meanwhile the stability and the accuracy of the online time of the terminal equipment are guaranteed.
Fig. 3 is a flowchart illustrating another online time duration determination method according to an exemplary embodiment, where as shown in fig. 3, before step 101, the method may further include:
and step 104, after receiving the message request sent by the terminal device in the previous request period, sending the request sequence number to the terminal device.
For example, the request sequence number is counted by the server and fed back to the terminal device, which can indicate that the terminal device has sent several message requests to the server before the current time. For example, the terminal device sends a message request to the server in the last request period, and the server sends a statistical request sequence number to the terminal device in response to the message request, where the request sequence number may be understood as the number of times the server has received the message request sent by the terminal device until the last request period.
FIG. 4 is a flow chart illustrating another method for determining an online time period, according to an example embodiment, as shown in FIG. 4, after step 102, the method may further include:
and 105, updating the request sequence number and sending the updated request sequence number to the terminal equipment.
For example, after receiving the request sequence number in the message request, the server may update the request sequence number, for example, may perform an operation of adding 1 on the basis of the request sequence number, so as to indicate that the number of times the terminal device has sent the message request is increased by 1. And then, the updated request sequence number is sent to the terminal equipment, so that when the terminal equipment sends the message request in the next request period, the request sequence number contained in the message request is the updated request sequence number.
It should be noted that step 105 may be executed after step 102, before step 102, or after step 103, and the execution sequence shown in fig. 4 is only for illustration, and the present disclosure is not limited in this regard. If step 105 is performed before step 102, the request sequence number obtained in step 101 may be stored as a first request sequence number in advance, and then the request sequence number is updated, and when step 102 is performed, the latest request time may be determined according to whether the first request sequence number matches a preset sampling interval.
Fig. 5 is a flowchart illustrating another online time duration determination method according to an exemplary embodiment, and as shown in fig. 5, the implementation manner of step 102 may include:
at step 1021, if the request sequence number can be divided by the sampling interval, the current time is determined as the latest request time.
At step 1022, if the request sequence number cannot be divided by the sampling interval, the latest request time is maintained.
For example, whether the request sequence number matches the sampling interval may be determined according to whether the request sequence number is divisible by the sampling interval. If the request sequence number is evenly divisible by the sampling interval, indicating that the request sequence number matches the sampling interval, then the current time (i.e., the time at which the server received the message request) is taken as the latest request time. If the request sequence number is not evenly divisible by the sampling interval, indicating that the request sequence number does not match the sampling interval, then the latest request time is kept unchanged, i.e., the latest request time is not updated. In another implementation, the latest request time may be kept unchanged if the request sequence number is divisible by the sampling interval, and the current time may be the latest request time if the request sequence number is not divisible by the sampling interval.
FIG. 6 is a flow chart illustrating another method for determining an online time period, according to an example embodiment, as shown in FIG. 6, before step 102, the method may further include:
step 106, determining the access amount of the server.
And step 107, determining a sampling interval according to the access amount, wherein the sampling interval is in direct proportion to the access amount.
For example, the access amount of the server may affect the computing capacity of the server, so that when the computing resources of the server have redundancy, the computing resources of the server are fully utilized, the accuracy of the online time duration is improved, when the computing capacity of the server is insufficient, the requirements on the server resources are reduced, the service capacity of the server is ensured, the access amount of the server may be monitored in real time, and the corresponding sampling interval may be determined according to the access amount. When the computing power of the server is redundant, that is, the access amount is low, the sampling interval can be reduced, so that the frequency of updating the latest request time for each terminal device becomes high, and the accuracy of the corresponding online time is also improved. When the computing power of the server is insufficient, that is, the access amount is high, the sampling interval can be expanded, so that the frequency of updating the latest request time for each terminal device becomes low, and each terminal device can still be ensured to update the online time according to the sampling interval.
Taking real-time message software as live broadcast software for example, the request period for sending a message request by the terminal device is 1 s. When a hot live broadcast room occurs, the access amount of the server is very large, the computing capacity of the server is insufficient, the sampling interval can be set to 10, and then, for each terminal device, the latest request time is updated once when 10 message requests are sent, so that the accuracy of the online time of each terminal device can be guaranteed within +/-10 s, and meanwhile, the computing amount of the server is greatly reduced. When the number of online people in the live broadcast room is small (such as in the morning hours), the access amount of the server is small, the computing power of the server is sufficient, the sampling interval can be set to be 1, and the latest request time is updated once every 1 message request is sent for each terminal device, so that the accuracy of the online time of each terminal device can be guaranteed within +/-1 s.
Fig. 7 is a flowchart illustrating another online duration determining method according to an exemplary embodiment, where as shown in fig. 7, before the updated request sequence number is sent to the terminal device, the method may further include:
and step 108, determining whether a target message corresponding to the terminal equipment exists.
Accordingly, step 105 may include the steps of:
step 1051, if the target message exists, the target message and the updated request sequence number are sent to the terminal device.
Step 1052, if there is no target message, sending the updated request sequence number to the terminal device.
For example, in the message pull mode, the terminal device sends a message request to the server at a request cycle to request the server for the latest message directed to the terminal device. Therefore, after receiving the message request sent by the terminal device, the server can search whether the target message corresponding to the terminal device exists. For example, whether the target message corresponding to the device identification code exists can be searched according to the device identification code included in the request message. The target message may be understood as a message that is not sent to the terminal device, for example, each message stored on the server may be provided with a tag to identify whether the message has been sent, and when the tag is 0, the message is not sent, and when the tag is 1, the message is sent. Then, the server may take the message corresponding to the terminal device with tag 0 as the target message.
If the target message exists, the target message and the updated request sequence number may be sent to the terminal device together, or the target message and the updated request sequence number may be sent to the terminal device separately, which is not specifically limited by the present disclosure. If the target message does not exist, the server indicates that no message to be sent to the terminal equipment currently exists, and the updated request sequence number can be sent to the terminal equipment.
Fig. 8 is a flowchart illustrating another online time duration determination method according to an exemplary embodiment, and as shown in fig. 8, the implementation manner of step 102 may be:
and if the request sequence number indicates that the sending times are more than or equal to 1, and the server receives the message request sent by the terminal equipment before the current time, determining the latest request time according to whether the request sequence number is matched with the sampling interval.
Correspondingly, the method may further include:
step 109, if the request sequence number indicates that the sending times is equal to 0 and the server does not receive the message request sent by the terminal device before the current time, determining the current time as the initial request time.
And step 110, if the request serial number indicates that the sending times are greater than or equal to 1 and the server does not receive the message request sent by the terminal device before the current time, determining the online time of the terminal device according to the request serial number and the request period.
In one implementation, whether data transmission between the terminal device and the server is normal may be determined according to a request sequence number included in the message request and whether the server receives the message request sent by the terminal device before the current time. The server may record each message request sent by the terminal device, e.g., may record the time each message request was received.
If the request sequence number included in the message request indicates that the number of transmissions is greater than or equal to 1, this indicates that the terminal device has previously transmitted the message request to the server. If the server determines that the message request sent by the terminal device is received before the current time, which indicates that the data transmission between the terminal device and the server is normal, the latest request time can be determined according to whether the request sequence number is matched with the sampling interval.
If the request sequence number included in the message request indicates that the number of transmissions is greater than or equal to 1, this indicates that the terminal device has previously transmitted the message request to the server. If the server determines that the message request sent by the terminal device is not received before the current time, it indicates that data transmission between the terminal device and the server may be abnormal, and a record on the server may be in error, at this time, if the latest request time is determined according to the request sequence number and the sampling interval, and calculating the online time according to the latest request time may cause an error to be too large. Then, the online time of the terminal device may be determined according to the request sequence number and the request period, for example, if the request sequence number is 120, and the request period for the terminal device to send the message request is 1s, then the online time of the terminal device may be determined to be 120 × 1 — 120 s.
If the request sequence number included in the message request indicates that the number of transmissions is equal to 0, this indicates that the terminal device has not previously transmitted the message request to the server. If the server determines that the message request sent by the terminal device is not received before the current time, it indicates that data transmission between the terminal device and the server is normal, and this is the first time the terminal device sends the message request to the server, and at this time, the current time (i.e. the time when the server receives the message request) is determined as the initial request time. Further, if the request sequence number included in the message request indicates that the number of transmissions is equal to 0, but the server determines that the message request transmitted by the terminal device is received before the current time, it indicates that an abnormality may occur in data transmission between the terminal device and the server, and an error may occur in the request sequence number, and at this time, if the latest request time is determined according to the request sequence number and the sampling interval, calculating the online time according to the latest request time may result in an error. Then, the time recorded by the server when the message request was last received can be used as the online time of the terminal device.
In summary, in the present disclosure, a server first receives a message request sent by a terminal device according to a request cycle, where the message request includes a request sequence number used for indicating the number of times that the terminal device has sent the message request. And finally, taking the difference between the latest request time and the initial request time of the first message sending request of the terminal equipment as the online time of the terminal equipment. According to the method and the device, after the server receives the message request sent by the terminal equipment, the online time is determined according to the sampling interval and the request serial number included in the message request, the calculated amount of the server for calculating the online time can be reduced, and meanwhile the stability and the accuracy of the online time of the terminal equipment are guaranteed.
Fig. 9 is a block diagram illustrating an online duration determining apparatus according to an exemplary embodiment, and as shown in fig. 9, the apparatus 200 is applied to a server, and may specifically include:
the receiving module 201 is configured to receive a message request sent by a terminal device according to a request period, where the message request includes a request sequence number, and the request sequence number is used to indicate the number of times that the terminal device has sent the message request.
The first determining module 202 is configured to determine a latest request time according to whether the request sequence number matches a preset sampling interval.
The second determining module 203 is configured to use a difference between the latest request time and the initial request time as the online time of the terminal device, where the initial request time is a time when the terminal device first sends a message request.
Fig. 10 is a block diagram illustrating another online time duration determination apparatus according to an exemplary embodiment, and as shown in fig. 10, the apparatus 200 further includes:
the sending module 204 is configured to send a request sequence number to the terminal device after receiving a message request sent by the terminal device in a previous request period.
Fig. 11 is a block diagram illustrating another online time duration determination apparatus according to an exemplary embodiment, and as shown in fig. 11, the apparatus 200 further includes:
and the updating module 205 is configured to update the request sequence number and send the updated request sequence number to the terminal device.
In one implementation, the first determining module 202 may be configured to:
if the request sequence number can be divided by the sampling interval, the current time is determined as the latest request time.
If the request sequence number is not evenly divisible by the sampling interval, the latest request time is maintained.
Fig. 12 is a block diagram illustrating another online time duration determination apparatus according to an exemplary embodiment, and as shown in fig. 12, the apparatus 200 further includes:
a third determining module 206, configured to determine the access amount of the server before determining the latest request time according to whether the request sequence number matches a preset sampling interval.
The third determining module 206 is further configured to determine a sampling interval according to the access amount, where the sampling interval is proportional to the access amount.
Fig. 13 is a block diagram illustrating another online time duration determination apparatus according to an exemplary embodiment, and as shown in fig. 13, the apparatus 200 further includes:
a fourth determining module 207, configured to determine whether a target message corresponding to the terminal device exists before sending the updated request sequence number to the terminal device.
Accordingly, the update module 205 is configured to:
and if the target message exists, sending the target message and the updated request sequence number to the terminal equipment.
And if the target message does not exist, sending the updated request sequence number to the terminal equipment.
In one implementation, the first determining module 202 may be configured to perform the following steps:
step 1) if the request sequence number indicates that the sending times are more than or equal to 1, and the server receives a message request sent by the terminal equipment before the current time, determining the latest request time according to whether the request sequence number is matched with the sampling interval.
And step 2) if the request sequence number indicates that the sending times are equal to 0 and the server does not receive the message request sent by the terminal equipment before the current time, determining the current time as the initial request time.
And step 3) if the request sequence number indicates that the sending times are more than or equal to 1 and the server does not receive the message request sent by the terminal equipment before the current time, determining the online time of the terminal equipment according to the request sequence number and the request period.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
In summary, in the present disclosure, a server first receives a message request sent by a terminal device according to a request cycle, where the message request includes a request sequence number used for indicating the number of times that the terminal device has sent the message request. And finally, taking the difference between the latest request time and the initial request time of the first message sending request of the terminal equipment as the online time of the terminal equipment. According to the method and the device, after the server receives the message request sent by the terminal equipment, the online time is determined according to the sampling interval and the request serial number included in the message request, the calculated amount of the server for calculating the online time can be reduced, and meanwhile the stability and the accuracy of the online time of the terminal equipment are guaranteed.
Referring now to fig. 14, a schematic diagram of an electronic device (e.g., the terminal device or the server of fig. 1) 300 suitable for implementing embodiments of the present disclosure is shown. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 14 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 14, the electronic device 300 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 301 that may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)302 or a program loaded from a storage means 308 into a Random Access Memory (RAM) 303. In the RAM 303, various programs and data necessary for the operation of the electronic apparatus 300 are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input/output (I/O) interface 305 is also connected to bus 304.
Generally, the following devices may be connected to the I/O interface 305: input devices 306 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 307 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage devices 308 including, for example, magnetic tape, hard disk, etc.; and a communication device 309. The communication means 309 may allow the electronic device 300 to communicate wirelessly or by wire with other devices to exchange data. While fig. 14 illustrates an electronic device 300 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication means 309, or installed from the storage means 308, or installed from the ROM 302. The computer program, when executed by the processing device 301, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, 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), an optical fiber, 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. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the terminal devices, servers may communicate using any currently known or future developed network Protocol, such as HTTP (HyperText Transfer Protocol), and may interconnect with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: receiving a message request sent by a terminal device according to a request period, wherein the message request comprises a request sequence number which is used for indicating the sending times of the message request sent by the terminal device; determining the latest request time according to whether the request sequence number is matched with a preset sampling interval; and taking the difference between the latest request time and the initial request time as the online time of the terminal equipment, wherein the initial request time is the time when the terminal equipment sends the message request for the first time.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, 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 and/or flowchart illustration, and combinations of blocks in the block diagrams and/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.
The modules described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of a module does not in some cases constitute a limitation of the module itself, for example, a receiving module may also be described as a "module receiving a message request".
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, 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), an optical fiber, 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 accordance with one or more embodiments of the present disclosure, example 1 provides a method of determining an online time period, comprising: receiving a message request sent by a terminal device according to a request period, wherein the message request comprises a request sequence number which is used for indicating the sending times of the message request sent by the terminal device; determining the latest request time according to whether the request sequence number is matched with a preset sampling interval; and taking the difference between the latest request time and the initial request time as the online time of the terminal equipment, wherein the initial request time is the time when the terminal equipment sends the message request for the first time.
Example 2 provides the method of example 1, in accordance with one or more embodiments of the present disclosure, before the receiving of the message request transmitted by the terminal device according to the request period, the method further including: and after receiving the message request sent by the terminal equipment in the last request period, sending the request sequence number to the terminal equipment.
Example 3 provides the method of example 1, and after determining a latest request time according to whether the request sequence number matches a preset sampling interval, the method further includes: and updating the request sequence number, and sending the updated request sequence number to the terminal equipment.
Example 4 provides the method of example 1, wherein determining a latest request time according to whether the request sequence number matches a preset sampling interval, according to one or more embodiments of the present disclosure includes: if the request sequence number can be divided by the sampling interval, determining the current time as the latest request time; if the request sequence number is not evenly divisible by the sampling interval, maintaining the latest request time.
Example 5 provides the method of any one of examples 1 to 4, further including, before the determining a latest request time according to whether the request sequence number matches a preset sampling interval: determining the access amount of the server; and determining the sampling interval according to the visit quantity, wherein the sampling interval is in direct proportion to the visit quantity.
Example 6 provides the method of example 3, before the sending the updated request sequence number to the terminal device, according to one or more embodiments of the present disclosure, the method further including: determining whether a target message corresponding to the terminal equipment exists or not; the sending the updated request sequence number to the terminal device includes: if the target message exists, sending the target message and the updated request sequence number to the terminal equipment; and if the target message does not exist, sending the updated request sequence number to the terminal equipment.
Example 7 provides the method of example 1, wherein determining a latest request time according to whether the request sequence number matches a preset sampling interval, according to one or more embodiments of the present disclosure includes: if the request sequence number indicates that the sending times are more than or equal to 1, and the server receives the message request sent by the terminal equipment before the current time, determining the latest request time according to whether the request sequence number is matched with the sampling interval; the method further comprises the following steps: if the request sequence number indicates that the sending times are equal to 0 and the server does not receive the message request sent by the terminal equipment before the current time, determining the current time as the initial request time; and if the request sequence number indicates that the sending times are greater than or equal to 1 and the server does not receive the message request sent by the terminal equipment before the current time, determining the online time of the terminal equipment according to the request sequence number and the request period.
Example 8 provides, in accordance with one or more embodiments of the present disclosure, an apparatus for determining an online time period, comprising: a receiving module, configured to receive a message request sent by a terminal device according to a request period, where the message request includes a request sequence number, and the request sequence number is used to indicate the number of times the terminal device has sent the message request; the first determining module is used for determining the latest request time according to whether the request sequence number is matched with a preset sampling interval; and the second determining module is used for taking the difference between the latest request time and the initial request time as the online time of the terminal equipment, wherein the initial request time is the time when the terminal equipment sends the message request for the first time.
Example 9 provides a computer-readable medium having stored thereon a computer program that, when executed by a processing apparatus, implements the steps of the methods of examples 1-7, in accordance with one or more embodiments of the present disclosure.
Example 10 provides, in accordance with one or more embodiments of the present disclosure, an electronic device comprising: a storage device having a computer program stored thereon; processing means for executing the computer program in the storage means to implement the steps of the methods of examples 1-7.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims. With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.

Claims (9)

1. A method for determining an online time period, the method comprising:
receiving a message request sent by a terminal device according to a request period, wherein the message request comprises a request sequence number which is used for indicating the sending times of the message request sent by the terminal device;
determining the latest request time according to whether the request sequence number is matched with a preset sampling interval;
taking the difference between the latest request time and the initial request time as the online duration of the terminal equipment, wherein the initial request time is the time when the terminal equipment sends the message request for the first time;
the determining the latest request time according to whether the request sequence number is matched with a preset sampling interval includes:
if the request sequence number can be divided by the sampling interval, determining the current time as the latest request time;
if the request sequence number is not evenly divisible by the sampling interval, maintaining the latest request time.
2. The method of claim 1, wherein prior to receiving the message request sent by the terminal device according to the request period, the method further comprises:
and after receiving the message request sent by the terminal equipment in the last request period, sending the request sequence number to the terminal equipment.
3. The method of claim 1, wherein after determining the latest request time according to whether the request sequence number matches a preset sampling interval, the method further comprises:
and updating the request sequence number, and sending the updated request sequence number to the terminal equipment.
4. The method according to any of claims 1-3, wherein before said determining a latest request time based on whether said request sequence number matches a preset sampling interval, the method further comprises:
determining the access amount of the server;
and determining the sampling interval according to the visit quantity, wherein the sampling interval is in direct proportion to the visit quantity.
5. The method according to claim 3, wherein before the sending the updated request sequence number to the terminal device, the method further comprises:
determining whether a target message corresponding to the terminal equipment exists or not;
the sending the updated request sequence number to the terminal device includes:
if the target message exists, sending the target message and the updated request sequence number to the terminal equipment;
and if the target message does not exist, sending the updated request sequence number to the terminal equipment.
6. The method of claim 1, wherein determining the latest request time according to whether the request sequence number matches a preset sampling interval comprises:
if the request sequence number indicates that the sending times are more than or equal to 1, and the server receives the message request sent by the terminal equipment before the current time, determining the latest request time according to whether the request sequence number is matched with the sampling interval;
the method further comprises the following steps:
if the request sequence number indicates that the sending times are equal to 0 and the server does not receive the message request sent by the terminal equipment before the current time, determining the current time as the initial request time;
and if the request sequence number indicates that the sending times are greater than or equal to 1 and the server does not receive the message request sent by the terminal equipment before the current time, determining the online time of the terminal equipment according to the request sequence number and the request period.
7. An apparatus for determining an online time period, the apparatus comprising:
a receiving module, configured to receive a message request sent by a terminal device according to a request period, where the message request includes a request sequence number, and the request sequence number is used to indicate the number of times the terminal device has sent the message request;
the first determining module is used for determining the latest request time according to whether the request sequence number is matched with a preset sampling interval;
a second determining module, configured to use a difference between the latest request time and an initial request time as an online duration of the terminal device, where the initial request time is a time when the terminal device first sends the message request;
the first determining module is to:
if the request sequence number can be divided by the sampling interval, determining the current time as the latest request time;
if the request sequence number is not evenly divisible by the sampling interval, the latest request time is maintained.
8. A computer-readable medium, on which a computer program is stored, characterized in that the program, when being executed by processing means, carries out the steps of the method of any one of claims 1 to 6.
9. An electronic device, comprising:
a storage device having a computer program stored thereon;
processing means for executing the computer program in the storage means to carry out the steps of the method according to any one of claims 1 to 6.
CN202010477940.5A 2020-05-29 2020-05-29 Online time length determining method and device, readable medium and electronic equipment Active CN111628913B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010477940.5A CN111628913B (en) 2020-05-29 2020-05-29 Online time length determining method and device, readable medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010477940.5A CN111628913B (en) 2020-05-29 2020-05-29 Online time length determining method and device, readable medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN111628913A CN111628913A (en) 2020-09-04
CN111628913B true CN111628913B (en) 2021-12-17

Family

ID=72272167

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010477940.5A Active CN111628913B (en) 2020-05-29 2020-05-29 Online time length determining method and device, readable medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN111628913B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113315981B (en) * 2021-04-27 2023-09-05 北京达佳互联信息技术有限公司 Task data updating method, device and system, electronic equipment and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6826513B1 (en) * 2002-11-29 2004-11-30 Council Of Scientific & Industrial Research Method and apparatus for online identification of safe operation and advance detection of unsafe operation of a system or process
US10244278B2 (en) * 2015-12-28 2019-03-26 The Nielsen Company (Us), Llc Methods and apparatus to perform identity matching across audience measurement systems
CN105847858A (en) * 2016-02-18 2016-08-10 四川长虹电器股份有限公司 Audience rating and audience share statistic method and system based on station caption identification
CN105721227B (en) * 2016-04-14 2019-03-05 武汉斗鱼网络科技有限公司 A kind of method of counting user online hours and state server and system
CN110493075B (en) * 2019-08-01 2021-06-25 京信通信系统(中国)有限公司 Method, device and system for monitoring online duration of equipment

Also Published As

Publication number Publication date
CN111628913A (en) 2020-09-04

Similar Documents

Publication Publication Date Title
CN110781373B (en) List updating method and device, readable medium and electronic equipment
CN114422267B (en) Flow detection method, device, equipment and medium
CN112311656B (en) Message aggregation and display method and device, electronic equipment and computer readable medium
CN111246228B (en) Method, device, medium and electronic equipment for updating gift resources of live broadcast room
CN111163336B (en) Video resource pushing method and device, electronic equipment and computer readable medium
CN111209306A (en) Business logic judgment method and device, electronic equipment and storage medium
CN112256733A (en) Data caching method and device, electronic equipment and computer readable storage medium
CN111596991A (en) Interactive operation execution method and device and electronic equipment
CN111163324A (en) Information processing method and device and electronic equipment
CN113034059A (en) Abnormal power information positioning method and device, electronic equipment and computer medium
CN112015816A (en) Data synchronization method, device, medium and electronic equipment
CN111209432A (en) Information acquisition method and device, electronic equipment and computer readable medium
CN111628913B (en) Online time length determining method and device, readable medium and electronic equipment
CN111225255B (en) Target video push playing method and device, electronic equipment and storage medium
CN113144620A (en) Detection method, device, platform, readable medium and equipment for frame synchronization game
CN111262907B (en) Service instance access method and device and electronic equipment
CN112148744A (en) Page display method and device, electronic equipment and computer readable medium
CN111596992A (en) Navigation bar display method and device and electronic equipment
CN113139082A (en) Multimedia content processing method, apparatus, device and medium
CN112905090A (en) Spreadsheet processing method, device, terminal and storage medium
CN112256700A (en) Data storage method and device, electronic equipment and computer readable storage medium
CN112667119A (en) Measuring point batch correlation method and device, electronic equipment and computer readable medium
CN112311840A (en) Multi-terminal data synchronization method, device, equipment and medium
CN111259174B (en) Multimedia transmission method, device, electronic equipment and medium
CN113612676B (en) Social group message synchronization method, device, equipment and storage 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
GR01 Patent grant
GR01 Patent grant