Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MessageStatus.cs
1using System;
3using System.Net;
4using Waher.Events;
5
7{
11 internal class MessageStatus
12 {
13 public Guid Id;
14 public Dictionary<IPEndPoint, bool?> Acknowledged = new Dictionary<IPEndPoint, bool?>();
15 public IClusterMessage Message;
16 public IPEndPoint Destination;
17 public byte[] MessageBinary;
18 public DateTime Timeout;
19 public DateTime TimeLimit;
20 public EventHandlerAsync<ClusterMessageAckEventArgs> Callback;
21 public object State;
22
28 public bool IsComplete(EndpointStatus[] Statuses)
29 {
30 lock (this.Acknowledged)
31 {
32 foreach (EndpointStatus Status in Statuses)
33 {
34 if (!this.Acknowledged.ContainsKey(Status.Endpoint))
35 return false;
36 }
37 }
38
39 return true;
40 }
41
46 public EndpointAcknowledgement[] GetResponses(EndpointStatus[] Statuses)
47 {
48 EndpointAcknowledgement[] Result;
49 int i, c;
50
51 lock (this.Acknowledged)
52 {
53 foreach (EndpointStatus Status in Statuses)
54 {
55 if (!this.Acknowledged.ContainsKey(Status.Endpoint))
56 this.Acknowledged[Status.Endpoint] = null;
57 }
58
59 Result = new EndpointAcknowledgement[c = this.Acknowledged.Count];
60
61 i = 0;
62 foreach (KeyValuePair<IPEndPoint, bool?> P in this.Acknowledged)
63 Result[i++] = new EndpointAcknowledgement(P.Key, P.Value);
64 }
65
66 return Result;
67 }
68 }
69}