forked from PeterWaher/IoTGateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClusterResponseEventArgs.cs
More file actions
70 lines (62 loc) · 1.93 KB
/
ClusterResponseEventArgs.cs
File metadata and controls
70 lines (62 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.Text;
namespace Waher.Networking.Cluster
{
/// <summary>
/// Event arguments for cluster command response events.
/// </summary>
/// <typeparam name="ResponseType">Type of expected response.</typeparam>
/// <param name="Sender">Sender of event.</param>
/// <param name="e">Event handler.</param>
public delegate void ClusterResponseEventHandler<ResponseType>(object Sender, ClusterResponseEventArgs<ResponseType> e);
/// <summary>
/// Event arguments for cluster message acknowledgement events.
/// </summary>
public class ClusterResponseEventArgs<ResponseType> : EventArgs
{
private readonly IClusterCommand command;
private readonly EndpointResponse<ResponseType>[] responses;
private readonly object state;
/// <summary>
/// Event arguments for cluster message acknowledgement events.
/// </summary>
/// <param name="Command">Command object.</param>
/// <param name="Responses">Message acknowledgement responses</param>
/// <param name="State">State object passed on to the original request.</param>
public ClusterResponseEventArgs(IClusterCommand Command, EndpointResponse<ResponseType>[] Responses, object State)
: base()
{
this.command = Command;
this.responses = Responses;
this.state = State;
}
/// <summary>
/// Cluster command object.
/// </summary>
public IClusterCommand Command => this.command;
/// <summary>
/// Command execution responses.
/// </summary>
public EndpointResponse<ResponseType>[] Responses => this.responses;
/// <summary>
/// State object passed on to the original request.
/// </summary>
public object State => this.state;
/// <summary>
/// If the command was executed without error on all endpoints.
/// </summary>
public bool Ok
{
get
{
foreach (EndpointResponse<ResponseType> P in this.responses)
{
if (!P.Ok)
return false;
}
return true;
}
}
}
}