aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Transport
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2020-03-03 18:56:58 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2020-03-03 18:56:58 +0200
commitc38f1c80f1fbdfdb758c5a0b93d045a9a5b526ad (patch)
tree20cc57b06f4260b6f86fdaca04129e1a8ace53cd /Software/Visual_Studio/Tango.Transport
parent1b0bdf6f8148e9cc4e7e07e41e9e2d75039c1349 (diff)
downloadTango-c38f1c80f1fbdfdb758c5a0b93d045a9a5b526ad.tar.gz
Tango-c38f1c80f1fbdfdb758c5a0b93d045a9a5b526ad.zip
Machine Studio v4.1.2
PPC v1.1.5 Added BYPASS_ROCKERS to SQLExaminer config. Started integrating FSE Remote/Console To PPC. Added support for generic continuous request.
Diffstat (limited to 'Software/Visual_Studio/Tango.Transport')
-rw-r--r--Software/Visual_Studio/Tango.Transport/ITransporter.cs9
-rw-r--r--Software/Visual_Studio/Tango.Transport/TransporterBase.cs55
2 files changed, 64 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Transport/ITransporter.cs b/Software/Visual_Studio/Tango.Transport/ITransporter.cs
index bffcb0444..78047c080 100644
--- a/Software/Visual_Studio/Tango.Transport/ITransporter.cs
+++ b/Software/Visual_Studio/Tango.Transport/ITransporter.cs
@@ -104,6 +104,15 @@ namespace Tango.Transport
Task SendGenericResponse<Response>(Response response, String token, TransportResponseConfig config = null) where Response : class;
/// <summary>
+ /// Sends a generic request and expecting multiple generic 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>
diff --git a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs
index c9388678d..f61e29795 100644
--- a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs
+++ b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs
@@ -885,6 +885,61 @@ namespace Tango.Transport
await SendResponse<GenericResponse>(genericResponse, token, config);
}
+ /// <summary>
+ /// Sends a generic request and expecting multiple generic 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>
+ public IObservable<Response> SendGenericContinuousRequest<Request, Response>(Request request, TransportContinuousRequestConfig config = null) where Request : class where Response : class
+ {
+ GenericRequest genericRequest = new GenericRequest();
+ genericRequest.Type = request.GetType().Name;
+ genericRequest.Data = ByteString.CopyFromUtf8(JsonConvert.SerializeObject(request, _genericMessageSettings));
+
+ Subject<Response> subject = new Subject<Response>();
+
+ SendContinuousRequest<GenericRequest, GenericResponse>(genericRequest, config).Subscribe((response) =>
+ {
+
+ try
+ {
+ var responseObject = JsonConvert.DeserializeObject<Response>(response.Message.Data.ToStringUtf8());
+ subject.OnNext(responseObject);
+ }
+ catch
+ {
+ //Ignore exception at the client side.
+ }
+
+ }, (ex) =>
+ {
+
+ try
+ {
+ subject.OnError(ex);
+ }
+ catch
+ {
+ //Ignore exception at the client side.
+ }
+
+ }, () =>
+ {
+ try
+ {
+ subject.OnCompleted();
+ }
+ catch
+ {
+ //Ignore exception at the client side.
+ }
+ });
+
+ return subject.AsObservable();
+ }
+
#endregion
#region Public Response Methods