Example #1
0
        public void GetNowTest()
        {
            DateTime now     = DateTime.Now;
            DateTime sntpNow = SNTPClient.GetNow();

            Console.WriteLine("Local Now: {0}, SNTP Now: {1}",
                              now.ToString("yyyy-MM-dd HH:mm.ss.fff"),
                              sntpNow.ToString("yyyy-MM-dd HH:mm.ss.fff"));
        }
 void Start()
 {
     try
     {
         m_cSNTPClient = new SNTPClient("time.nuri.net");   // 참조할 NTP 서버 주소.
         m_cSNTPClient.Connect(false);
         Debug.Log(m_cSNTPClient.ToString());
     }
     catch (Exception e)
     {
         Debug.LogError("ERROR: " + e.Message);
     }
 }
        private void UpdateOffsetLabel()
        {
            TimeSpan offset = SNTPClient.GetCurrentLocalTimeZoneOffset();

            if (offset == TimeSpan.Zero)
            {
                labelCurrentOffset.ForeColor = Color.Green;
            }
            else
            {
                labelCurrentOffset.ForeColor = Color.Red;
            }
            labelCurrentOffset.Text = string.Format("Current UTC Offset: {0}", offset);
        }
        private void lnkNow_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            DateTime nowDateTime =
                SNTPClient.GetNow(sntpClient.RemoteSNTPServer, sntpClient.Timeout);
            string caption = "Current Date & Time";
            string text    = string.Empty;

            if (nowDateTime != DateTime.MinValue)
            {
                text = string.Format("The real local date and time is:{0}{0}{1}",
                                     Environment.NewLine, nowDateTime);
            }
            else
            {
                text = "There was a problem retrieving the date and time.";
            }
            MessageBox.Show(this, text, caption,
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Example #5
0
        public Receiver(string host, string ntpHost, TimeSpan delay)
        {
            this.Delay = delay;

            bufferAllocator = new BufferAllocator <byte>();

            clockSyncThread = new Thread(ClockSyncWorker);
            clockSyncThread.IsBackground = true;

            this.Host = host;
            NtpClient = new SNTPClient(ntpHost);

            clockSyncThread.Start();
            WavePlayer = new WavPlayer(bufferAllocator);
            WavePlayer.Init();

            zeroPositionTime = DateTime.UtcNow;
            Thread.Sleep(500);
            AutoJitter();
        }