Exemple #1
0
 private void RefreshSelfNode()
 {
     Task.Run(() => {
         var x = new NodeInfoInNet {
             NodeGuid  = ThisNodeID,
             PCVersion = "2",
             TimeStamp = _Network.StatusTimeStamp,
             Url       = $"http://localhost:{WebServerPort}/"
         };
         NodeInfoForOneNode(x);
     });
 }
Exemple #2
0
        private void NodeInfoForOneNode(NodeInfoInNet x)
        {
            LocalNodeInfo nod = null;

            lock (LocalNodes)
            {
                nod = LocalNodes.FirstOrDefault(y => y.NodeId == x.NodeGuid);
                if (nod == null)
                {
                    nod = new LocalNodeInfo {
                        NodeId          = x.NodeGuid,
                        Fetched         = false,
                        PCVersion       = x.PCVersion,
                        StatusTimeStamp = x.TimeStamp,
                    };
                    LocalNodes.Add(nod);
                }
                else
                {
                    if (nod.StatusTimeStamp > x.TimeStamp)
                    {
                        return;
                    }
                    if (nod.StatusTimeStamp == x.TimeStamp)
                    {
                        if (nod.Fetched)
                        {
                            return;
                        }
                    }
                    else
                    {
                        nod.Fetched         = false;
                        nod.StatusTimeStamp = x.TimeStamp;
                    }
                    //do not set LocalNodeInfo.Url in this block
                }
            }
            if (nod.NodeId == ThisNodeID)//self
            {
                nod.Url = x.Url = $"http://localhost:{WebServerPort}/";
            }

            var t = new FetchQueueItem {
                Node       = x,
                LocalNode  = nod,
                FinishTask = new TaskCompletionSource <int>()
            };

            fetchCloudInfo.Post(t);
            t.FinishTask.Task.Wait(10 * 1000);
        }
Exemple #3
0
 bool IsNodeFetched(NodeInfoInNet x)
 {
     lock (LocalNodes)
     {
         var nod = LocalNodes.FirstOrDefault(y => y.NodeId == x.NodeGuid);
         if (nod != null)
         {
             Interlocked.Exchange(ref nod.MissCount, 0);
             if (nod.StatusTimeStamp > x.TimeStamp)
             {
                 return(true);
             }
             if (nod.StatusTimeStamp == x.TimeStamp)
             {
                 if (nod.Fetched)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }