CN110691263A - Method, medium, electronic device and system for synchronizing local time and server time - Google Patents

Method, medium, electronic device and system for synchronizing local time and server time Download PDF

Info

Publication number
CN110691263A
CN110691263A CN201810731429.6A CN201810731429A CN110691263A CN 110691263 A CN110691263 A CN 110691263A CN 201810731429 A CN201810731429 A CN 201810731429A CN 110691263 A CN110691263 A CN 110691263A
Authority
CN
China
Prior art keywords
time
server
class
local
calling
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
CN201810731429.6A
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.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu 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 Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201810731429.6A priority Critical patent/CN110691263A/en
Publication of CN110691263A publication Critical patent/CN110691263A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/242Synchronization processes, e.g. processing of PCR [Program Clock References]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0682Clock or time synchronisation in a network by delay compensation, e.g. by compensation of propagation delay or variations thereof, by ranging
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/21Server components or server architectures
    • H04N21/218Source of audio or video content, e.g. local disk arrays
    • H04N21/2187Live feed

Abstract

The invention discloses a method, a medium, electronic equipment and a system for synchronizing local time and server time, which relate to the field of Internet application development and comprise the following steps: acquiring local time and server time, and calculating a time difference value between the local time and the server time; defining a time acquisition function with public authority, and creating a NetTimeUtils class for calling the time acquisition function; when a live broadcast network request is initiated, the NetTimeUtils class is used for calling the time acquisition function to acquire the current local time, and the current server time is calculated according to the acquired current local time and the time difference value to be used for server authentication. The method for synchronizing the local time and the server time provided by the invention can ensure that the request authentication of the live broadcast network is successful even if the user modifies the local time of the system, and has better reliability.

Description

Method, medium, electronic device and system for synchronizing local time and server time
Technical Field
The invention relates to the field of Internet application development, in particular to a method, a medium, electronic equipment and a system for synchronizing local time and server time.
Background
In the field of live broadcast, a live broadcast server receives a large number of live broadcast network requests, and after receiving the live broadcast network requests, the server needs time information in the live broadcast network requests to perform authentication operation.
The time obtaining mode of the traditional scheme is to directly obtain the local time of the Android system of the client, and the mode is effective under the normal condition, but the authentication fails after the user modifies the local time of the system, so that the problem of failure of the live broadcast network request is caused.
Disclosure of Invention
Aiming at the defects in the prior art, the invention aims to provide a method for synchronizing local time and server time, which can ensure that the request authentication of a live broadcast network is successful and the reliability is better even if a user modifies the local time of a system.
In order to achieve the above purposes, the technical scheme adopted by the invention is as follows:
a method of synchronizing local and server time, comprising the steps of:
acquiring local time and server time, and calculating a time difference value between the local time and the server time;
defining a time acquisition function with public authority, and creating a NetTimeUtils class for calling the time acquisition function;
when a live broadcast network request is initiated, the NetTimeUtils class is used for calling the time acquisition function to acquire the current local time, and the current server time is calculated according to the acquired current local time and the time difference value to be used for server authentication.
On the basis of the technical scheme, after the time difference value between the local time and the server time is calculated, the method further comprises the following steps: updating the time difference in real time, wherein the specific process is as follows:
constructing a filter object through the IntentFilter class, and calling a filter.addAction function to filter and monitor the change information of the time zone and the change information of the system time;
defining a broadcast receiving class MyReceiver, wherein the MyReceiver class inherits the broadcastReceive class and overwrites an onReceive function of the broadcastReceive class;
instantiating an mMyRereceptor object through a constructor of MyRereceptor;
calling a getApplicationContext function to acquire a context object mContext of a system, and calling a broadcast registration function mContext.
Analyzing the change information of the time zone and the change information of the system time in an onReceive function of the MyReceiver class to obtain time change information;
and re-assigning and updating the time difference value to ensure that the updated time difference value is the sum of the time difference value before updating and the time change information.
On the basis of the technical scheme, the specific steps of acquiring the local time and the service time comprise:
calling a Post method of an OKhttpUtils tool class to obtain server time;
system currenttimemillis () function is called to obtain local time.
On the basis of the technical scheme, the specific steps of acquiring the current local time, calculating the current server time according to the acquired current local time and the time difference value and providing the current server time for server authentication comprise:
calling a system currenttimeMillis () function to obtain the current local time;
and calculating the sum of the current local time and the time difference value to be used as the current server time obtained by calculation.
On the basis of the technical scheme, when the sum of the current local time and the time difference is calculated, the method comprises the following steps: and the current local time is consistent with the unit conversion of the time difference value, and then the current local time and the unit conversion of the time difference value are added and summed.
On the basis of the above technical solution, after calculating the sum of the current local time and the time difference as the current server time obtained by calculation, the method further includes the steps of: the current server time estimated is rounded.
The invention also provides a storage medium having stored thereon a computer program which, when executed by a processor, implements the above-described method of synchronizing local and server time.
The invention also provides an electronic device, which comprises a memory and a processor, wherein the memory is stored with a computer program running on the processor, and the processor executes the computer program to realize the method for synchronizing the local time and the server time.
The invention also provides a system for synchronizing local time and server time, which comprises:
the time acquisition module is used for acquiring local time and service time;
the computing module is used for computing a time difference value between the local time and the server time;
the creating module is used for defining a time obtaining function with public authority and creating a NetTimeUtils class;
and the synchronous processing module is used for calling the time acquisition function by using a NetTimeUtils class when a live network request is initiated, acquiring the current local time, and calculating the current server time according to the acquired current local time and the time difference value for the server to authenticate.
On the basis of the above technical solution, the system further includes an updating module, configured to update the time difference in real time, where the updating module includes:
the filter monitoring unit is used for constructing a filter object through the IntentFilter class and calling a filter.
The broadcast receiving system comprises a definition unit, a broadcast receiving unit and a broadcast receiving unit, wherein the definition unit is used for defining a broadcast receiving class MyReceiver, the MyReceiver class inherits the BroadcastReceive class, overwrites an onReceive function of the BroadcastReceive class, and instantiates an mMyReceiver object through a constructor of the MyReceiver;
the system comprises an association unit, a filter unit and a service unit, wherein the association unit is used for calling a getApplicationContext function to acquire a context object mContext of the system and calling a broadcast registration function mContext.
The analysis unit is used for analyzing the change information of the time zone and the change information of the system time in an onReceive function of the MyReceiver class to obtain time change information;
and the updating unit is used for reassigning and updating the time difference value, so that the updated time difference value is the sum of the time difference value before updating and the time change information.
On the basis of the above technical solution, the time acquisition module includes:
the first time acquisition unit is used for calling a Post method of the OKhttpUtils tool class and acquiring server time;
and a second time acquisition unit for calling the system currenttimeMillis () function to acquire the local time.
On the basis of the above technical solution, the synchronization processing module includes:
a third time obtaining unit, configured to, when there is a live broadcast network request, call a system.
And the first calculation unit is used for calculating the sum of the current local time and the time difference value as the current server time.
Compared with the prior art, the invention has the advantages that:
(1) according to the method for synchronizing the local time and the server time, the time difference between the local time and the server time is obtained through pre-calculation, when a live broadcast network request exists, the current local time is obtained, and then the current server time is calculated according to the obtained current local time and the time difference to be used for server authentication, so that before the time difference is obtained, even if a user modifies the local time of a system, the time information carried by a live broadcast network requester when sending the live broadcast network request to a server is the calculated server time, the calculated server time can be consistent with the actual server time, and authentication is successful.
(2) The method for synchronizing the local time and the server time further comprises the step of updating the time difference in real time, the updating logic of the time difference can be actively triggered as long as the system time is changed, the time information synchronized with the server time can be further acquired by calling the time acquisition function, and the authentication operation is carried out by using the time information synchronized with the server time.
Drawings
FIG. 1 is a flow chart of a method for synchronizing local and server time according to an embodiment of the present invention;
fig. 2 is a schematic diagram of three electronic devices according to the embodiment of the invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples.
Example one
Referring to fig. 1, an embodiment of the present invention provides a method for synchronizing local and server times, including the steps of:
s1: acquiring local time and server time, and calculating a time difference value between the local time and the server time;
s2: defining a time acquisition function with public authority, and creating a NetTimeUtils class for calling the time acquisition function;
s3: when a live broadcast network request is initiated, the NetTimeUtils class is used for calling the time acquisition function to acquire the current local time, and the current server time is calculated according to the acquired current local time and the time difference value to be used for server authentication. This step S3 is a specific implementation process of the time obtaining function.
In the embodiment of the invention, when the goblet client is connected with the server, the operation of the step S1 is carried out to obtain the time difference between the local time and the server time, when the goblet live broadcast is needed, namely, the live broadcast network request is initiated, the operation of the step S3 is carried out, the NetTimeUtils class is used for calling the time obtaining function to obtain the current local time, the current server time is obtained by calculation according to the obtained current local time and the time difference, then the calculated current server time is returned to the caller, the caller here can understand as the goblet client initiating the live broadcast network request, at the moment, the time information carried in the live broadcast network request of the goblet client is the calculated current server time, and the calculated server time is consistent with the actual server time, thereby completing the synchronization of local and server time.
The server compares time information carried in a live network request of the goblet client with the server time to authenticate the live network request, if the time information carried in the live network request is consistent with the server time, the authentication is successful, the server allows the live network request of the goblet client, and if the time information carried in the live network request is inconsistent with the server time, the authentication is failed, and the server forbids the live network request of the goblet client.
Generally, if the local time and the server time are completely consistent, the time difference between the local time and the server time should be zero, however, when the user modifies the local time of the system before the client connects to the server, so that the time difference is not zero, by adopting the above technical solution, after the synchronization between the local time and the server time is completed, even if the time difference is not zero, the server can successfully authenticate the request of the live broadcast network.
In this embodiment of the present invention, the specific step of acquiring the local time and the service time in step S1 includes:
s101: calling a Post method of an OKhttpUtils tool class to obtain server time;
the specific process is as follows: calling a Post function of an OKhttpUtils tool class, sending a Post request to a server, acquiring server time, and recording the acquired server time as server time;
the Post function is illustrated as follows:
OKhttpUtils.url(“http://douyu.xxx.com”).post().exec();
s102: calling a System of Android TimeMillis () function of an Android system to obtain local time;
the unit of local time acquired by the system currenttimeMillis () function is millisecond, so the acquired local time needs to be converted into unit, the unit is converted into second, then output is performed, namely the system currenttimeMillis ()/1000 is output, and the local time after unit conversion is marked as localTime.
Correspondingly, in the time difference between the local time and the server time, the time difference is marked as diffTime, and the diffTime is equal to server time-localTime, and the unit of the diffTime is second at this time.
In this embodiment of the present invention, in step S2, the defined time obtaining function is getTimeStamp (), which is illustrated as:
public static long getTimeStamp(){}
the name of the time obtaining function is getTimeStamp, the time obtaining function is set to be a static type, the return value of the time obtaining function is a long type, and the unit of the return value of the time obtaining function is second.
In the embodiment of the invention, the time acquisition function getTimeStamp has public authority, so that other classes have the authority of calling the time acquisition function, namely the created NetTimeUtils class has the authority of calling the time acquisition function getTimeStamp; in addition, the time obtaining function getTimeStamp is a static type, so that the time obtaining function getTimeStamp can be directly called by classes when needing to be called, and the calling process is simplified.
Further, in the embodiment of the present invention, after calculating the time difference between the local time and the server time, the method further includes step S4: and updating the time difference value in real time.
The specific process of updating the time difference in real time in step S4 is as follows:
s401: constructing a filter object through the IntentFilter class, and calling a filter.addAction function to filter and monitor the change information of the time zone and the change information of the system time;
the IntentFilter class is a filter provided by the Android system and is used for filtering the class of the broadcast messages at the system level. Constructing a filter object through the IntentFilter class, wherein the specific method comprises the following steps: the construct method in IntentFilter is called to instantiate the filter object IntentFilter filter ═ new IntentFilter (). Specifically, filtering and monitoring the CHANGE information of the time zone by calling the filter.
S402: defining a broadcast receiving class MyReceiver, wherein the MyReceiver class inherits the broadcastReceive class and over-writes an onReceive function of the broadcastReceive class, so that the MyReceiver class has the capability of receiving system broadcast messages;
s403: instantiating an mMyReceiver object by a constructor of the MyReceiver, specifically instantiating an mMyReceiver object by calling a MyReceiver mMyReceiver-new MyReceiver () method;
s404: calling a getApplicationContext function to acquire a context object mContext of the system, and calling a broadcast registration function mContext.
S405: analyzing the change information of the time zone and the change information of the system time in an onReceive function of the MyReceiver class, wherein the specific process of the analysis is as follows: calling a getBendler (). getTime () method in the intent object to obtain time change information, and marking the time change information as receiveDIffTime;
s406: and re-assigning and updating the time difference value to ensure that the updated time difference value is the sum of the time difference value before updating and the time change information, namely assigning and updating the time difference value diffTime to diffTime + receiveDIffTime.
Through the operation of the step S4, as long as the system time changes, the update logic of the time difference value can be actively triggered, and further the time information synchronized with the server time can be obtained by calling the time obtaining function getTimeStamp, and the time information synchronized with the server time is returned to the caller for authentication operation.
In this embodiment of the present invention, in step S3, the specific process of calling the time obtaining function using the NetTimeUtils class is as follows: gettimestamp () mode calls the time acquisition function, where nettimeultis is the class name of the time acquisition function.
In step S3, the specific steps of acquiring the current local time and calculating the current server time according to the acquired current local time and the time difference include:
s301: when a live network request is initiated, calling a System, currentTimeMillis () function provided by an Android system to obtain the current local time, and recording the current local time as currentTime;
s302: calculating the sum of the current local time and the time difference value to serve as the current server time, and recording the current server time as resultTime;
specifically, since currentTime is in milliseconds, and the time difference diffTime is in seconds, when calculating the sum of the current local time and the time difference, the method includes the steps of: firstly, converting the unit of the current local time and the time difference value to be consistent, and then adding and summing, namely, calculating the current server time resultTime which is currentTime + diffTime 1000, wherein the unit of the current server time is millisecond.
Further, after obtaining the current server time resultTime, in order to match the unit of the commonly used server time, it is necessary to convert the unit of the resultTime into seconds, and record the result of the resultTime conversion as secondTmp, that is, the secondTmp is equal to resultTime/1000, and at this time, the secondTmp may be a decimal number, and therefore, after calculating the sum of the current local time and the time difference as the estimated current server time, the method further includes the steps of: rounding the current server time obtained by estimation, namely rounding secondTmp.
In practical application, the specific process of rounding secondTmp is as follows: calling a Math function provided by an Android system to round the secondTimp, wherein the code is shown as: ceil (secondTmp), and records the result after rounding processing as targetResult, and then returns targetResult to the caller through return targetResult for authentication of the server.
Preferably, the time difference used in step S302 is the time difference updated in step S4 in real time, so that the time information synchronized with the server time information can be obtained as long as the system time changes, and the live network request authentication is successful. In practical application, even if a user modifies the local time of the system after the client and the server are connected, the time difference value is updated in real time, so that the time synchronization of the local time and the server can be ensured, the request authentication of the live broadcast network is successful, and the method is safer and more reliable.
Based on the same inventive concept, the present application provides an embodiment of a storage medium corresponding to the embodiment, which is detailed in embodiment two
Example two
Corresponding to the above method for synchronizing local time and server time, an embodiment of the present invention further provides an embodiment of a storage medium, where a computer program is stored on the storage medium, and when the computer program is executed by a processor, the method for synchronizing local time and server time in the above embodiment is implemented, specifically, the following steps are implemented:
acquiring local time and server time, and calculating a time difference value between the local time and the server time;
defining a time acquisition function with public authority, and creating a NetTimeUtils class for calling the time acquisition function;
when a live broadcast network request is initiated, the NetTimeUtils class is used for calling the time acquisition function to acquire the current local time, and the current server time is calculated according to the acquired current local time and the time difference value to be used for server authentication.
It should be noted that, the method for synchronizing the local time and the server time in the first embodiment of the present invention and the method in the second embodiment of the present invention are based on the same concept, so that based on the method described in the first embodiment of the present invention, a person skilled in the art can understand the specific implementation manner of the storage medium in the present embodiment and various variations thereof, and therefore, how to implement the method in the first embodiment of the present invention and various preferred embodiments of the storage medium are not described in detail herein.
Based on the same inventive concept, the present application provides an embodiment of an electronic device corresponding to the first embodiment, which is detailed in the third embodiment
EXAMPLE III
Referring to fig. 2, in response to the method for synchronizing local time and server time, an embodiment of the present invention further provides an electronic device, where the electronic device stores a computer program, and the computer program, when executed by a processor, implements the steps of the method for synchronizing local time and server time according to the foregoing embodiments.
The electronic equipment comprises a memory and a processor, wherein the memory stores a computer program running on the processor, and the processor executes the computer program to realize the following steps:
acquiring local time and server time, and calculating a time difference value between the local time and the server time;
defining a time acquisition function with public authority, and creating a NetTimeUtils class for calling the time acquisition function;
when a live broadcast network request is initiated, the NetTimeUtils class is used for calling the time acquisition function to acquire the current local time, and the current server time is calculated according to the acquired current local time and the time difference value to be used for server authentication.
It should be noted that, a method for synchronizing local time and server time in the first embodiment of the present invention and the method used in the first embodiment of the present invention are based on the same concept, so that based on the method described in the first embodiment of the present invention, a person skilled in the art can understand a specific implementation manner of the electronic device of the present embodiment and various variations thereof, and therefore, how to implement the method in the first embodiment of the present invention and various preferred embodiments thereof by the electronic device are not described in detail herein.
Based on the same inventive concept, the application provides a system for synchronizing local time and server time corresponding to the fourth embodiment.
Example four
The embodiment of the invention also provides a system for synchronizing the time of the local server and the time of the server, which comprises the following steps:
the time acquisition module is used for acquiring local time and service time;
the computing module is used for computing a time difference value between the local time and the server time;
the system comprises a creating module, a setting module and a sending module, wherein the creating module is used for defining a time acquisition function with public authority and creating a NetTimeUtils class for calling the time acquisition function;
and the synchronous processing module is used for calling the time acquisition function by using a NetTimeUtils class when a live network request is initiated, acquiring the current local time, and calculating the current server time according to the acquired current local time and the time difference value for the server to authenticate.
Further, the system for synchronizing local time and server time in the embodiment of the present invention further includes an updating module, configured to update the time difference in real time, where the updating module includes:
the filter monitoring unit is used for constructing a filter object through the IntentFilter class and calling a filter.
The broadcast receiving system comprises a definition unit, a broadcast receiving unit and a broadcast receiving unit, wherein the definition unit is used for defining a broadcast receiving class MyReceiver, the MyReceiver class inherits the BroadcastReceive class, overwrites an onReceive function of the BroadcastReceive class, and instantiates an mMyReceiver object through a constructor of the MyReceiver;
the system comprises an association unit, a filter unit and a service unit, wherein the association unit is used for calling a getApplicationContext function to acquire a context object mContext of the system and calling a broadcast registration function mContext.
The analysis unit is used for analyzing the change information of the time zone and the change information of the system time in an onReceive function of the MyReceiver class to obtain time change information;
and the updating unit is used for reassigning and updating the time difference value, so that the updated time difference value is the sum of the time difference value before updating and the time change information.
Specifically, the time acquisition module includes:
the first time acquisition unit is used for calling a Post method of the OKhttpUtils tool class and acquiring server time;
and a second time acquisition unit for calling the system currenttimeMillis () function to acquire the local time.
Specifically, the synchronization processing module includes:
a third time obtaining unit, configured to, when a live broadcast network request is initiated, call a system currenttimeMillis () function to obtain a current local time;
and the first calculation unit is used for calculating the sum of the current local time and the time difference value as the current server time obtained by calculation.
The present invention is not limited to the above-described embodiments, and it will be apparent to those skilled in the art that various modifications and improvements can be made without departing from the principle of the present invention, and such modifications and improvements are also considered to be within the scope of the present invention. Those not described in detail in this specification are within the skill of the art.

Claims (10)

1. A method of synchronizing local and server time, comprising the steps of:
acquiring local time and server time, and calculating a time difference value between the local time and the server time;
defining a time acquisition function with public authority, and creating a NetTimeUtils class for calling the time acquisition function;
when a live broadcast network request is initiated, the NetTimeUtils class is used for calling the time acquisition function to acquire the current local time, and the current server time is calculated according to the acquired current local time and the time difference value to be used for server authentication.
2. The method of claim 1, further comprising the step of updating the time difference in real time after calculating the time difference between the local time and the server time, by the following steps:
constructing a filter object through the IntentFilter class, and calling a filter.addAction function to filter and monitor the change information of the time zone and the change information of the system time;
defining a broadcast receiving class MyReceiver, wherein the MyReceiver class inherits the broadcastReceive class and overwrites an onReceive function of the broadcastReceive class;
instantiating an mMyRereceptor object through a constructor of MyRereceptor;
calling a getApplicationContext function to acquire a context object mContext of a system, and calling a broadcast registration function mContext.
Analyzing the change information of the time zone and the change information of the system time in an onReceive function of the MyReceiver class to obtain time change information;
and re-assigning and updating the time difference value to ensure that the updated time difference value is the sum of the time difference value before updating and the time change information.
3. The method of claim 1, wherein the step of obtaining the local time and the service time comprises:
calling a Post method of an OKhttpUtils tool class to obtain server time;
system currenttimemillis () function is called to obtain local time.
4. The method according to claim 1, wherein the specific steps of obtaining the current local time, and calculating the current server time according to the obtained current local time and the time difference for the server to authenticate comprise:
calling a system currenttimeMillis () function to obtain the current local time;
and calculating the sum of the current local time and the time difference value to be used as the current server time obtained by calculation.
5. The method for synchronizing local and server time according to claim 4, comprising, in calculating the sum of the current local time and said time difference, the steps of: and the current local time is consistent with the unit conversion of the time difference value, and then the current local time and the unit conversion of the time difference value are added and summed.
6. The method of synchronizing local and server times as recited in claim 4, further comprising, after calculating a sum of the current local time and the time difference as the derived current server time, the steps of: the current server time estimated is rounded.
7. A storage medium having a computer program stored thereon, characterized in that: the computer program, when executed by a processor, implements the method of any of claims 1 to 6.
8. An electronic device comprising a memory and a processor, the memory having stored thereon a computer program that runs on the processor, characterized in that: the processor, when executing the computer program, implements the method of any of claims 1 to 6.
9. A system for synchronizing local and server time, comprising:
the time acquisition module is used for acquiring local time and service time;
the computing module is used for computing a time difference value between the local time and the server time;
the system comprises a creating module, a setting module and a sending module, wherein the creating module is used for defining a time acquisition function with public authority and creating a NetTimeUtils class for calling the time acquisition function;
and the synchronous processing module is used for calling the time acquisition function by using a NetTimeUtils class when a live network request is initiated, acquiring the current local time, and calculating the current server time according to the acquired current local time and the time difference value for the server to authenticate.
10. The system for synchronizing local and server time according to claim 9, further comprising an update module for updating the time difference value in real time, the update module comprising:
the filter monitoring unit is used for constructing a filter object through the IntentFilter class and calling a filter.
The broadcast receiving system comprises a definition unit, a broadcast receiving unit and a broadcast receiving unit, wherein the definition unit is used for defining a broadcast receiving class MyReceiver, the MyReceiver class inherits the BroadcastReceive class, overwrites an onReceive function of the BroadcastReceive class, and instantiates an mMyReceiver object through a constructor of the MyReceiver;
the system comprises an association unit, a filter unit and a service unit, wherein the association unit is used for calling a getApplicationContext function to acquire a context object mContext of the system and calling a broadcast registration function mContext.
The analysis unit is used for analyzing the change information of the time zone and the change information of the system time in an onReceive function of the MyReceiver class to obtain time change information;
and the updating unit is used for reassigning and updating the time difference value, so that the updated time difference value is the sum of the time difference value before updating and the time change information.
CN201810731429.6A 2018-07-05 2018-07-05 Method, medium, electronic device and system for synchronizing local time and server time Pending CN110691263A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810731429.6A CN110691263A (en) 2018-07-05 2018-07-05 Method, medium, electronic device and system for synchronizing local time and server time

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810731429.6A CN110691263A (en) 2018-07-05 2018-07-05 Method, medium, electronic device and system for synchronizing local time and server time

Publications (1)

Publication Number Publication Date
CN110691263A true CN110691263A (en) 2020-01-14

Family

ID=69106685

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810731429.6A Pending CN110691263A (en) 2018-07-05 2018-07-05 Method, medium, electronic device and system for synchronizing local time and server time

Country Status (1)

Country Link
CN (1) CN110691263A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114546932A (en) * 2022-02-23 2022-05-27 地平线征程(杭州)人工智能科技有限公司 Multi-processing unit time synchronization method and device, storage medium and electronic equipment
CN114827699A (en) * 2022-04-25 2022-07-29 康键信息技术(深圳)有限公司 Time synchronization method, device, equipment and storage medium for live broadcast activity

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102523128A (en) * 2011-12-31 2012-06-27 浙江万朋网络技术有限公司 Data synchronism method in remote data transmission
JP2013250759A (en) * 2012-05-31 2013-12-12 Ntt Data Corp File synchronization system by differential encryption, method thereof and program
CN104572047A (en) * 2013-10-18 2015-04-29 镇江鼎拓科技信息有限公司 Apache Tomcat based WEB database component development method
CN106688008A (en) * 2014-07-25 2017-05-17 汤森路透环球资源公司 Ideal latency floor
CN107341377A (en) * 2017-06-16 2017-11-10 武汉斗鱼网络科技有限公司 Time synchronization control method in one kind authentication

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102523128A (en) * 2011-12-31 2012-06-27 浙江万朋网络技术有限公司 Data synchronism method in remote data transmission
JP2013250759A (en) * 2012-05-31 2013-12-12 Ntt Data Corp File synchronization system by differential encryption, method thereof and program
CN104572047A (en) * 2013-10-18 2015-04-29 镇江鼎拓科技信息有限公司 Apache Tomcat based WEB database component development method
CN106688008A (en) * 2014-07-25 2017-05-17 汤森路透环球资源公司 Ideal latency floor
CN107341377A (en) * 2017-06-16 2017-11-10 武汉斗鱼网络科技有限公司 Time synchronization control method in one kind authentication

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
扶松柏等: "《Android开发从入门到精通》", 31 January 2012, 北京希望电子出版社 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114546932A (en) * 2022-02-23 2022-05-27 地平线征程(杭州)人工智能科技有限公司 Multi-processing unit time synchronization method and device, storage medium and electronic equipment
CN114827699A (en) * 2022-04-25 2022-07-29 康键信息技术(深圳)有限公司 Time synchronization method, device, equipment and storage medium for live broadcast activity

Similar Documents

Publication Publication Date Title
CN110083455B (en) Graph calculation processing method, graph calculation processing device, graph calculation processing medium and electronic equipment
US9454439B2 (en) Disaster recovery validation
CN109542529B (en) Function name-based point burying method and device, computer equipment and storage medium
US10116642B2 (en) Identity management over multiple identity providers
US20150067031A1 (en) Business transaction correlation with client request monitoring data
WO2016037479A1 (en) Method, device and system for optimizing virtualized network function (vnf)
US20200327045A1 (en) Test System and Test Method
CN110659109A (en) Openstack cluster virtual machine monitoring system and method
CN111611054A (en) Application deployment method and device
CN110691263A (en) Method, medium, electronic device and system for synchronizing local time and server time
CN112434278A (en) Bare computer authentication method, apparatus, device and medium
CN113419818B (en) Basic component deployment method, device, server and storage medium
CN110347413B (en) Software configuration information updating method and device
CN111327447B (en) Distributed system, arbitration method, node device and storage medium
CN111327680A (en) Authentication data synchronization method, device, system, computer equipment and storage medium
CN115390939A (en) Service processing method and system
CN112448909A (en) Electronic lock management method, device, system and storage medium
CN112073462B (en) Positioning method and device
CN115291973A (en) Method and device for connecting database by application on cloud, electronic equipment and storage medium
US11579896B2 (en) Autonomously re-initializing applications based on detecting periodic changes in device state
CN110750424B (en) Resource inspection method and device
CN112766486A (en) Searching method of neural network structure, terminal, server and readable storage medium
WO2019205345A1 (en) User information synchronization method, device, computer device, and storage medium
WO2015192497A1 (en) Communication link sending method and apparatus, and terminal
CN111488223A (en) Container-based data processing 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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20200114