Beispiel #1
0
        /// <summary>
        /// Parse the server status string
        /// </summary>
        async Task ParseServerStatus(string sample)
        {
            var connectionStatus = JsonConvert.DeserializeObject <BrainHatServerStatus>(sample);

            //  update connection status with local properties
            connectionStatus.HostName     = HostName;
            connectionStatus.OffsetTime   = DateTimeOffset.UtcNow - connectionStatus.TimeStamp;
            connectionStatus.ReceivingRaw = ReceivingRaw;
            connectionStatus.RawLatency   = RawLatency;

            //  update local properties with connection status
            TimeStamp    = DateTimeOffset.UtcNow;
            OffsetTime   = connectionStatus.OffsetTime;
            CytonSRB1    = connectionStatus.CytonSRB1;
            DaisySRB1    = connectionStatus.DaisySRB1;
            IsStreaming  = connectionStatus.IsStreaming;
            Eth0Address  = connectionStatus.Eth0Address;
            Wlan0Address = connectionStatus.Wlan0Address;

            if (!SyncedTime)
            {
                await SyncServerTime(connectionStatus);
            }

            HatConnectionStatusUpdate?.Invoke(this, new BrainHatStatusEventArgs(connectionStatus));

            if (ReportNetworkTimeInterval.ElapsedMilliseconds > 30000)
            {
                ReportNetworkTimeInterval.Restart();
                Log?.Invoke(this, new LogEventArgs(connectionStatus.HostName, this, "ParseServerStatus", $"Network status for {connectionStatus.HostName}: Offset time {connectionStatus.OffsetTime.TotalSeconds:F4} s.", LogLevel.TRACE));
            }
        }
Beispiel #2
0
 private void OnHatConnectionStatusUpdate(object sender, BrainHatStatusEventArgs e)
 {
     HatConnectionStatusUpdate?.Invoke(sender, e);
 }