Collaboration diagram for Time Synchronization:
Files | |
file | timesync.c |
Implementation of Time Synchronization. | |
file | timesync.h |
Interface to the Time Synchronization module. | |
Data Structures | |
struct | TimeSample_t |
Data from a single time sync sample. More... | |
Typedefs | |
typedef TimeSample_t | TimeSample |
Enumerations | |
enum | TSYNC_STATE { TIMESYNC_IDLE, TIMESYNC_INPROG, TIMESYNC_FINISHED, TIMESYNC_POOR, TIMESYNC_ERROR } |
Functions | |
void | StartClientTimeSync () |
Starts the time synchronization process on the I/O Thread. | |
Bool | StartServerTimeSync () |
Starts the time synchronization server on a separate thread. | |
void | StopServerTimeSync () |
Stops the time synchronization server and returns the time sync state to TSYNC_STATE::TIMESYNC_IDLE. | |
Variables | |
Sint32 | timeDelta |
The time delta used to produce common game time. | |
TimeSample | timeSyncResults |
The final results of the last time sync operation that ended with a state of either TSYNC_STATE::TIMESYNC_FINISHED or TSYNC_STATE::TIMESYNC_POOR. | |
int | timeSyncState |
The state of the time synchronization system; a value from TSYNC_STATE. |
The system consists of two parts: client and server. The client first connects to a server, then calls StartClientSync(). The time sync process occurs on the I/O Thread. timeSyncState will change to reflect the status of the time sync operation (see TSYNC_STATE for the valid codes).
The server is started by a call to StartServerTimeSync() which will start another thread to handle incomming client time sync requests. To stop the time sync server, call StopServerTimeSync().
Copyright (C) 2007 Jeff Jackowski
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Or visit their website at: http://www.gnu.org/
typedef struct TimeSample_t TimeSample |
Definition at line 111 of file timesync.h.
enum TSYNC_STATE |
Definition at line 65 of file timesync.h.
void StartClientTimeSync | ( | ) |
Starts the time synchronization process on the I/O Thread.
Definition at line 372 of file timesync.c.
References ClientSync(), QueueOperation(), TIMESYNC_INPROG, and timeSyncState.
Referenced by DiscoverConnectServer().
Here is the call graph for this function:
Bool StartServerTimeSync | ( | ) |
Starts the time synchronization server on a separate thread.
Definition at line 435 of file timesync.c.
References FALSE, SocketAddr_t::ipv4, PORT_STSYNC, ServerTimeSyncThread(), thread, TRUE, tsyncSock, and UnicastSocket().
Referenced by NetCliToSrv().
Here is the call graph for this function:
void StopServerTimeSync | ( | ) |
Stops the time synchronization server and returns the time sync state to TSYNC_STATE::TIMESYNC_IDLE.
Definition at line 452 of file timesync.c.
References CloseSocket, TIMESYNC_IDLE, timeSyncState, and tsyncSock.
Referenced by NetCliToSrv(), NetDisconnect(), NetSrvToCli(), and NetUninit().
Sint32 timeDelta |
The time delta used to produce common game time.
This is the integer version of timeSyncResults.delta.
Definition at line 44 of file timesync.c.
Referenced by ClientSync().
The final results of the last time sync operation that ended with a state of either TSYNC_STATE::TIMESYNC_FINISHED or TSYNC_STATE::TIMESYNC_POOR.
Definition at line 46 of file timesync.c.
Referenced by ClientSync(), ComputeAverages(), ComputeStdDeviation(), RemoveBadSamples(), and RenderLatency().
int timeSyncState |
The state of the time synchronization system; a value from TSYNC_STATE.
Definition at line 45 of file timesync.c.