e register - flex net encryption
This commit is contained in:
+22
-1
@@ -162,34 +162,55 @@
|
||||
{
|
||||
var awaiter = new ManualResetEventSlim();
|
||||
|
||||
/// Loop while cancellation requested ...
|
||||
while (!broadcaster.cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
foreach (var tasks in broadcaster.tasks.Values.ToArray())
|
||||
/// For each address whit its tasks ...
|
||||
foreach (var ep in broadcaster.tasks)
|
||||
{
|
||||
var address = ep.Key;
|
||||
var tasks = ep.Value;
|
||||
|
||||
/// Iterates only over the tasks asigned to the current address.
|
||||
/// Always check if there are tasks into the queue because the queues throwing exceptions when they are empty.
|
||||
while (tasks.Count > 0)
|
||||
{
|
||||
/// Take a look at the first item.
|
||||
var current = tasks.Peek();
|
||||
|
||||
/// Remove when done or cancelled ...
|
||||
if (current.IsDone || current.IsCancelled)
|
||||
{
|
||||
tasks.Dequeue();
|
||||
|
||||
/// ... than go to the next one.
|
||||
continue;
|
||||
}
|
||||
|
||||
/// When current task is not running and is not cancelled or done ...
|
||||
if (!current.IsRunning)
|
||||
{
|
||||
var notWritePamTask = current.Type != SIRTConstants.WritePam;
|
||||
var notInPamPool = !broadcaster.pamPool.Values.ToArray().Any(x => x == current.Address);
|
||||
|
||||
/// ... and also is write to pam task and is not into the pam pool ...
|
||||
if (notWritePamTask || notInPamPool)
|
||||
{
|
||||
/// ... mark as running ...
|
||||
current.IsRunning = true;
|
||||
|
||||
/// ... than write to the pam pool.
|
||||
broadcaster.Write(current);
|
||||
}
|
||||
}
|
||||
|
||||
/// Break and go to the next address with tasks.
|
||||
break;
|
||||
}
|
||||
|
||||
/// Break in case the pam pool is full.
|
||||
if (pamPool.Count > 0 && !pamPool.Values.Any(x => x == 0))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,15 +23,15 @@
|
||||
|
||||
public Byte Type { get; }
|
||||
|
||||
public UInt32 Address { get; protected set; }
|
||||
public virtual UInt32 Address { get; set; }
|
||||
|
||||
public Boolean IsCancelled { get; protected set; }
|
||||
public Boolean IsRunning { get; internal set; }
|
||||
|
||||
public Boolean IsDone { get; protected set; }
|
||||
|
||||
public DateTime? Timestamp { get; protected set; }
|
||||
public Boolean IsCancelled { get; protected set; }
|
||||
|
||||
public Boolean IsRunning { get; internal set; }
|
||||
public DateTime? Timestamp { get; protected set; }
|
||||
|
||||
internal void BeginAddResponse(AcknOrAnswerResponse response)
|
||||
{
|
||||
@@ -53,18 +53,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
internal void NotifyRemoved()
|
||||
{
|
||||
if (this.IsDone)
|
||||
{
|
||||
this.NotifyDone();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.NotifyCancelled();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual Boolean AcknOrAnswerReceived(AcknOrAnswerResponse response)
|
||||
{
|
||||
return false;
|
||||
@@ -96,6 +84,8 @@
|
||||
this.AddressChanged?.Invoke(oldAddress, newAddress);
|
||||
}
|
||||
|
||||
protected virtual Byte[] GetRequestBytes() => this.request;
|
||||
|
||||
private Boolean CanReceiveResponses()
|
||||
{
|
||||
var canReceiveResponses = !this.IsDone && !this.IsCancelled;
|
||||
|
||||
Reference in New Issue
Block a user