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;
2using System.Collections.Generic;
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 byte[] MessageBinary;
17 public DateTime Timeout;
18 public DateTime TimeLimit;
19 public EventHandlerAsync<ClusterMessageAckEventArgs> Callback;
20 public object State;
21
27 public bool IsComplete(EndpointStatus[] Statuses)
28 {
29 lock (this.Acknowledged)
30 {
31 foreach (EndpointStatus Status in Statuses)
32 {
33 if (!this.Acknowledged.ContainsKey(Status.Endpoint))
34 return false;
35 }
36 }
37
38 return true;
39 }
40
45 public EndpointAcknowledgement[] GetResponses(EndpointStatus[] Statuses)
46 {
47 EndpointAcknowledgement[] Result;
48 int i, c;
49
50 lock (this.Acknowledged)
51 {
52 foreach (EndpointStatus Status in Statuses)
53 {
54 if (!this.Acknowledged.ContainsKey(Status.Endpoint))
55 this.Acknowledged[Status.Endpoint] = null;
56 }
57
58 Result = new EndpointAcknowledgement[c = this.Acknowledged.Count];
59
60 i = 0;
61 foreach (KeyValuePair<IPEndPoint, bool?> P in this.Acknowledged)
62 Result[i++] = new EndpointAcknowledgement(P.Key, P.Value);
63 }
64
65 return Result;
66 }
67 }
68}