Exemple #1
0
        internal static TheNodeInfoHeader GetInfoHeaderJSON()
        {
            var tHead = new TheNodeInfoHeader {
                CloudRoutes    = new List <TheServiceRouteInfo>(),
                NodeID         = TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID,
                NodeName       = TheBaseAssets.MyServiceHostInfo.NodeName,
                BuildVersion   = TheBaseAssets.BuildVersion,
                CurrentVersion = TheBaseAssets.CurrentVersionInfo,
                ScopeHash      = TheBaseAssets.MyScopeManager.IsScopingEnabled ? TheBaseAssets.MyScopeManager.ScopeID.Substring(0, 4).ToUpper() : "unscoped",
                OSInfo         = TheBaseAssets.MyServiceHostInfo.OSInfo
            };
            var CNs = TheQueuedSenderRegistry.GetCloudNodes(true);

            if (CNs.Count > 0)
            {
                foreach (var tQ in CNs)
                {
                    var tInfo = new TheServiceRouteInfo
                    {
                        Url            = tQ.MyTargetNodeChannel.TargetUrl,
                        IsConnected    = tQ.IsConnected,
                        IsConnecting   = tQ.IsConnecting,
                        LastError      = tQ.GetLastError(),
                        ErrorCode      = tQ.GetLastErrorCode(),
                        LastHB         = (tQ.GetLastHeartBeat() == DateTimeOffset.MinValue ? "not yet" : $"{TheCommonUtils.GetDateTimeString(tQ.GetLastHeartBeat(), -1)}"),
                        ConnectedSince = (tQ.MyLastConnectTime == DateTimeOffset.MinValue ? "not yet" : $"{TheCommonUtils.GetDateTimeString(tQ.MyLastConnectTime, -1)}"),
                        IsAlive        = tQ.IsAlive,
                        UsesWS         = tQ.HasWebSockets()
                    };
                    tInfo.Status = $"{tInfo.Url} (Connected: {(tInfo.IsConnected ? "Yes, all is good" : (tInfo.IsConnecting ? "Not, yet - trying to connect" : "No, and not yet trying to connect again!"))}{(!string.IsNullOrEmpty(tInfo.LastError) ? $" Last Error: {tInfo.LastError}" : "")})";
                    tHead.CloudRoutes.Add(tInfo);
                }
            }
            return(tHead);
        }