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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
using Google.Protobuf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Transport.Adapters;
using Tango.PMR;
using Tango.PMR.Common;
using System.Collections.ObjectModel;
namespace Tango.Transport
{
/// <summary>
/// Represents a transportation engine which can send and receive <see cref="TangoMessage{T}"/> message using a <see cref="ITransportAdapter">Transport adapter</see>.
/// </summary>
/// <seealso cref="Tango.Transport.ITransportComponent" />
public interface ITransporter : ITransportComponent
{
/// <summary>
/// Gets or sets the <see cref="ITransportAdapter"/> used to read and write raw data.
/// </summary>
ITransportAdapter Adapter { get; set; }
/// <summary>
/// Gets or sets the transport encoder used to encode and decode tango messages.
/// </summary>
ITransportEncoder Encoder { get; set; }
/// <summary>
/// Gets the last failed state exception/reason.
/// </summary>
Exception FailedStateException { get; }
/// <summary>
/// Sends a request.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="timeout">Optional timeout. If not specified will use the <see cref="RequestTimeout"/>.</param>
/// <returns></returns>
Task<IMessage> SendRequest(IMessage request, TimeSpan? timeout = null);
/// <summary>
/// Sends the request.
/// </summary>
/// <param name="container">The container.</param>
/// <returns></returns>
Task<MessageContainer> SendRequest(MessageContainer container);
/// <summary>
/// Sends a continuous request.
/// </summary>
/// <param name="container">The container.</param>
/// <returns></returns>
IObservable<MessageContainer> SendContinuousRequest(MessageContainer container);
/// <summary>
/// Sends the response.
/// </summary>
/// <param name="container">The container.</param>
/// <returns></returns>
Task SendResponse(MessageContainer container);
/// <summary>
/// Sends the response.
/// </summary>
/// <param name="response">The response.</param>
/// <param name="token">The token.</param>
/// <param name="completed">The completed.</param>
/// <param name="errorCode">The error code.</param>
/// <param name="errorMessage">The error message.</param>
/// <returns></returns>
Task SendResponse(IMessage response, String token, bool? completed = null, ErrorCode? errorCode = null, String errorMessage = null);
/// <summary>
/// Sends a request and expecting multiple response messages.
/// </summary>
/// <param name="request">The request.</param>
/// <returns></returns>
IObservable<IMessage> SendContinuousRequest(IMessage request, TimeSpan? timeout = null);
/// <summary>
/// Sends a request.
/// </summary>
/// <typeparam name="Request">The type of the request.</typeparam>
/// <typeparam name="Response">The type of the response.</typeparam>
/// <param name="request">The request.</param>
/// <param name="timeout">Optional timeout. If not specified will use the <see cref="RequestTimeout"/>.</param>
/// <returns></returns>
Task<TangoMessage<Response>> SendRequest<Request, Response>(TangoMessage<Request> request, TimeSpan? timeout = null) where Request : IMessage<Request> where Response : IMessage<Response>;
/// <summary>
/// Sends a request and expecting multiple response messages.
/// </summary>
/// <typeparam name="Request">The type of the request.</typeparam>
/// <typeparam name="Response">The type of the response.</typeparam>
/// <param name="request">The request.</param>
/// <returns></returns>
IObservable<TangoMessage<Response>> SendContinuousRequest<Request, Response>(TangoMessage<Request> request, TimeSpan? firstTimeout = null, TimeSpan? continousTimeout = null) where Request : IMessage<Request> where Response : IMessage<Response>;
/// <summary>
/// Sends a response.
/// </summary>
/// <typeparam name="Response">The type of the response.</typeparam>
/// <param name="response">The response.</param>
/// <returns></returns>
Task SendResponse<Response>(TangoMessage<Response> response) where Response : IMessage<Response>;
/// <summary>
/// Sends a response for the specified token.
/// </summary>
/// <typeparam name="Response">The type of the response.</typeparam>
/// <param name="response">The response.</param>
/// <param name="token">The token.</param>
/// <param name="completed">The completed.</param>
/// <param name="errorCode">The error code.</param>
/// <param name="errorMessage">The error message.</param>
/// <returns></returns>
Task SendResponse<Response>(TangoMessage<Response> response, String token, bool? completed = null, ErrorCode? errorCode = null, String errorMessage = null) where Response : IMessage<Response>;
/// <summary>
/// Sends a general error response agnostic to the type of request.
/// </summary>
/// <param name="exception">The exception.</param>
/// <param name="token">The token.</param>
/// <returns></returns>
Task SendErrorResponse(Exception exception, String token);
/// <summary>
/// Clears all message queues.
/// </summary>
void ClearQueues();
/// <summary>
/// Occurs when a new request message has been received.
/// </summary>
event EventHandler<MessageContainer> RequestReceived;
/// <summary>
/// Occurs when a new response message has been received.
/// </summary>
event EventHandler<MessageContainer> PendingResponseReceived;
/// <summary>
/// Gets or sets the default request timeout.
/// </summary>
TimeSpan RequestTimeout { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to use a keep alive mechanism.
/// </summary>
bool UseKeepAlive { get; set; }
/// <summary>
/// Gets or sets the keep alive timeout.
/// </summary>
TimeSpan KeepAliveTimeout { get; set; }
/// <summary>
/// Gets or sets the keep alive retries.
/// </summary>
int KeepAliveRetries { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to auto respond to keep alive requests.
/// </summary>
bool EnableKeepAliveAutoResponse { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the transporter will get in to a failed state if the <see cref="Adapter"/> has failed.
/// </summary>
bool FailsWithAdapter { get; set; }
}
}
|