Example #1
0
        internal static int CalculateOffset(double now, ushort val, double roundtrip)
        {
            int oneWayMillis = (int)(roundtrip * 500.0);
            int remoteNow    = NormalizeEncoded(val + oneWayMillis);
            int localNow     = NetTime.Encoded(now);

            return(remoteNow - localNow);
        }
Example #2
0
        internal static int SendConnectResponse(NetBase netBase, NetConnection clientConnection, IPEndPoint remoteEndpoint)
        {
            double     now      = NetTime.Now;
            ushort     nowEnc   = NetTime.Encoded(now);
            NetMessage response = new NetMessage(NetMessageType.Handshake, 3);

            response.Write((byte)NetHandshakeType.ConnectResponse);
            response.Write(nowEnc);
            clientConnection.m_firstSentHandshake = now;
            clientConnection.m_lastSentHandshake  = now;
            return(netBase.SendSingleMessageAtOnce(response, clientConnection, remoteEndpoint));
        }
 /// <summary>
 /// Write a timestamp IN THE PAST
 /// </summary>
 public void WriteSendStamp(double pastTimestamp)
 {
     m_buffer.Write(NetTime.Encoded(pastTimestamp));
 }