Rebel Fork Framework
Urho3D::ClockSynchronizer Class Reference

Classes

struct  PendingPing
struct  PendingPong

Public Member Functions

 ClockSynchronizer (unsigned pingIntervalMs, unsigned maxPingMs, unsigned clockBufferSize, unsigned pingBufferSize, ea::function< unsigned()> getTimestamp=nullptr)
void ProcessMessage (const ClockSynchronizerMessage &msg)
 Process incoming message. Should be called as soon as possible.
ea::optional< ClockSynchronizerMessage > PollMessage ()
 Receive outgoing message if there is any. Should be called as late as possible.
bool IsReady () const
 Return whether synchronizer is ready to use.
unsigned LocalToRemote (unsigned value) const
 Convert from local to remote timestamp.
unsigned RemoteToLocal (unsigned value) const
 Convert from remote to local timestamp.
unsigned GetPing () const
 Return ping, i.e. half of round-trip delay excluding remote processing time.
unsigned GetLocalTimeOfLatestRoundtrip () const
 Return local timestamp of the latest successful roundtrip.

Private Member Functions

ClockSynchronizerMessage CreateNewPing (unsigned now)
ClockSynchronizerMessage CreateNewPong (const PendingPong &pong)
void CleanupExpiredPings (unsigned now)
unsigned GetTimestamp () const
void UpdateClocks (unsigned localSent, unsigned remoteReceived, unsigned remoteSent, unsigned localReceived)

Private Attributes

ea::function< unsigned()> getTimestamp_
unsigned pingIntervalMs_ {}
unsigned maxPingMs_ {}
ea::optional< unsigned > latestProbeTimestamp_
ea::vector< PendingPing > pendingPings_
ea::vector< PendingPong > pendingPongs_
FilteredUint localToRemote_
FilteredUint roundTripDelay_
ea::optional< unsigned > latestRoundtripTimestamp_

The documentation for this class was generated from the following files:
  • Urho3D/Network/ClockSynchronizer.h
  • Urho3D/Network/ClockSynchronizer.cpp