Ejemplo n.º 1
0
 Task sendProcess() => Task.Run(async() =>
 {
     Log.RecordEvent(this, $"Send process started for instance at {Address}.", LogEntrySeverity.Info);
     while (process)
     {
         try
         {
             if (SendTSM.RunSafe(() =>
             {
                 if (SendQueue.Count > 0)
                 {
                     var p = SendQueue.Dequeue();
                     if (p.Destination == ErebusAddress.Broadcast)
                     {
                         foreach (var l in ltsm.RunSafe(() => links.ToArray()))
                         {
                             l.qtsm.RunSafe(() => l.q.Enqueue(p));
                         }
                     }
                     else
                     {
                         ErebusLink link = ltsm.RunSafe(() => (from l in links select l.RemoteAddress).Contains(p.Destination) ? (from l in links where l.RemoteAddress == p.Destination select l).First() : links[new Random().Next(links.Count)]);
                         link.qtsm.RunSafe(() => link.q.Enqueue(p));
                     }
                     Log.RecordEvent(this, $"Transmitted packet {p.Identifier} from {p.Source} to {p.Destination} on port {p.Port} ({p.Data.Length} bytes)", LogEntrySeverity.Info);
                     return(false);
                 }
                 return(true);
             }))
             {
                 await Task.Delay(5);
             }
         }
         catch (Exception e)
         {
             Log.RecordEvent(this, $"Exception in main instance transmit thread: {e.Message}", LogEntrySeverity.Warning);
         }
     }
 });
Ejemplo n.º 2
0
 internal void RemoveLink(ErebusLink l) => ltsm.RunSafe(() => links.Remove(l));
Ejemplo n.º 3
0
 internal void AddLink(ErebusLink l) => ltsm.RunSafe(() => links.Add(l));