aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Transport/ITransporter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.Transport/ITransporter.cs')
-rw-r--r--Software/Visual_Studio/Tango.Transport/ITransporter.cs132
1 files changed, 32 insertions, 100 deletions
diff --git a/Software/Visual_Studio/Tango.Transport/ITransporter.cs b/Software/Visual_Studio/Tango.Transport/ITransporter.cs
index 777b97e19..1f7039df7 100644
--- a/Software/Visual_Studio/Tango.Transport/ITransporter.cs
+++ b/Software/Visual_Studio/Tango.Transport/ITransporter.cs
@@ -10,12 +10,9 @@ using Tango.Transport.Adapters;
using Tango.PMR;
using Tango.PMR.Common;
using System.Collections.ObjectModel;
-using Tango.PMR.Integration;
namespace Tango.Transport
{
- public delegate void RequestHandlerCallbackDelegate<Request>(ITransporter transporter, Request request, String token);
-
/// <summary>
/// Represents a transportation engine which can send and receive <see cref="TangoMessage{T}"/> message using a <see cref="ITransportAdapter">Transport adapter</see>.
/// </summary>
@@ -38,122 +35,70 @@ namespace Tango.Transport
Exception FailedStateException { get; }
/// <summary>
- /// Gets or sets the generic protocol used to serialize/deserialize generic messages.
- /// </summary>
- GenericMessageProtocol GenericProtocol { get; set; }
-
- /// <summary>
- /// Registers a custom request handler.
- /// </summary>
- /// <typeparam name="Request">The type of the request.</typeparam>
- /// <param name="callback">The callback.</param>
- void RegisterRequestHandler<Request>(RequestHandlerCallbackDelegate<Request> callback) where Request : class;
-
- /// <summary>
- /// Unregisters a custom request handler.
- /// </summary>
- /// <typeparam name="Request">The type of the request.</typeparam>
- /// <param name="callback">The callback.</param>
- void UnregisterRequestHandler<Request>(RequestHandlerCallbackDelegate<Request> callback) where Request : class;
-
- /// <summary>
- /// Copies this instance request handlers to the specified instance.
- /// </summary>
- /// <param name="transporter">The transporter to copy the handlers to.</param>
- void CopyRequestHandlers(ITransporter transporter);
-
- /// <summary>
/// Sends a request.
/// </summary>
/// <param name="request">The request.</param>
- /// <param name="config">Request configuration.</param>
+ /// <param name="timeout">Optional timeout. If not specified will use the <see cref="RequestTimeout"/>.</param>
/// <returns></returns>
- Task<IMessage> SendRequest(IMessage request, TransportRequestConfig config = null);
+ Task<IMessage> SendRequest(IMessage request, TimeSpan? timeout = null);
/// <summary>
/// Sends the request.
/// </summary>
- /// <param name="config">Request configuration.</param>
+ /// <param name="container">The container.</param>
/// <returns></returns>
- Task<MessageContainer> SendRequest(MessageContainer container, TransportRequestConfig config = null);
+ Task<MessageContainer> SendRequest(MessageContainer container);
/// <summary>
- /// Sends a request.
+ /// Sends a continuous 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="config">Request configuration.</param>
+ /// <param name="container">The container.</param>
/// <returns></returns>
- Task<TangoMessage<Response>> SendRequest<Request, Response>(TangoMessage<Request> request, TransportRequestConfig config = null) where Request : IMessage<Request> where Response : IMessage<Response>;
+ IObservable<MessageContainer> SendContinuousRequest(MessageContainer container);
/// <summary>
- /// Sends a continuous request.
+ /// Sends the response.
/// </summary>
/// <param name="container">The container.</param>
- /// <param name="config">Request configuration.</param>
/// <returns></returns>
- IObservable<MessageContainer> SendContinuousRequest(MessageContainer container, TransportContinuousRequestConfig config = null);
+ Task SendResponse(MessageContainer container);
/// <summary>
- /// Sends a request and expecting multiple response messages.
+ /// Sends the response.
/// </summary>
- /// <param name="config">Request configuration.</param>
+ /// <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>
- IObservable<IMessage> SendContinuousRequest(IMessage request, TransportContinuousRequestConfig config = null);
+ 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>
- /// <typeparam name="Request">The type of the request.</typeparam>
- /// <typeparam name="Response">The type of the response.</typeparam>
- /// <param name="config">Request configuration.</param>
+ /// <param name="request">The request.</param>
/// <returns></returns>
- IObservable<TangoMessage<Response>> SendContinuousRequest<Request, Response>(TangoMessage<Request> request, TransportContinuousRequestConfig config = null) where Request : IMessage<Request> where Response : IMessage<Response>;
+ IObservable<IMessage> SendContinuousRequest(IMessage request, TimeSpan? timeout = null);
/// <summary>
- /// Sends a generic request of any type.
+ /// 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="config">The configuration.</param>
- /// <returns></returns>
- Task<Response> SendGenericRequest<Request, Response>(Request request, TransportRequestConfig config = null) where Request : class where Response : class;
-
- /// <summary>
- /// Sends a generic response.
- /// </summary>
- /// <typeparam name="Response">The type of the response.</typeparam>
- /// <param name="response">The response.</param>
- /// <param name="token">The request token.</param>
- /// <param name="config">The response configuration.</param>
+ /// <param name="timeout">Optional timeout. If not specified will use the <see cref="RequestTimeout"/>.</param>
/// <returns></returns>
- Task SendGenericResponse<Response>(Response response, String token, TransportResponseConfig config = null) where Response : class;
+ Task<TangoMessage<Response>> SendRequest<Request, Response>(TangoMessage<Request> request, TimeSpan? timeout = null) where Request : IMessage<Request> where Response : IMessage<Response>;
/// <summary>
- /// Sends a generic request and expecting multiple generic response messages.
+ /// 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="config">Request configuration.</param>
- /// <returns></returns>
- IObservable<Response> SendGenericContinuousRequest<Request, Response>(Request request, TransportContinuousRequestConfig config = null) where Request : class where Response : class;
-
- /// <summary>
- /// Sends the response.
- /// </summary>
- /// <param name="container">The container.</param>
- /// <returns></returns>
- Task SendResponse(MessageContainer container, TransportResponseConfig config = null);
-
- /// <summary>
- /// Sends the response.
- /// </summary>
- /// <param name="response">Request token.</param>
- /// <param name="config">Response configuration.</param>
+ /// <param name="request">The request.</param>
/// <returns></returns>
- Task SendResponse(IMessage response, String token, TransportResponseConfig config = null);
+ 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.
@@ -164,20 +109,22 @@ namespace Tango.Transport
Task SendResponse<Response>(TangoMessage<Response> response) where Response : IMessage<Response>;
/// <summary>
- /// Sends a response.
+ /// 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">Request token.</param>
- /// <param name="config">Response configuration.</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, TransportResponseConfig config = null) where Response : IMessage<Response>;
+ 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">Request token.</param>
+ /// <param name="token">The token.</param>
/// <returns></returns>
Task SendErrorResponse(Exception exception, String token);
@@ -189,7 +136,7 @@ namespace Tango.Transport
/// <summary>
/// Occurs when a new request message has been received.
/// </summary>
- event EventHandler<RequestReceivedEventArgs> RequestReceived;
+ event EventHandler<MessageContainer> RequestReceived;
/// <summary>
/// Occurs when a new response message has been received.
@@ -197,21 +144,6 @@ namespace Tango.Transport
event EventHandler<MessageContainer> PendingResponseReceived;
/// <summary>
- /// Occurs when a request has been sent.
- /// </summary>
- event EventHandler<IMessage> RequestSent;
-
- /// <summary>
- /// Occurs when a request response has been received.
- /// </summary>
- event EventHandler<IMessage> ResponseReceived;
-
- /// <summary>
- /// Occurs when a request has failed.
- /// </summary>
- event EventHandler<RequestFailedEventArgs> RequestFailed;
-
- /// <summary>
/// Gets or sets the default request timeout.
/// </summary>
TimeSpan RequestTimeout { get; set; }