aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeSignalRClient.cs
diff options
context:
space:
mode:
authorMirta <mirta@twine-s.com>2020-12-30 16:39:52 +0200
committerMirta <mirta@twine-s.com>2020-12-30 16:39:52 +0200
commit00a491d93733d4625ad329b2ba8237f445364b3f (patch)
tree4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeSignalRClient.cs
parent124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff)
downloadTango-00a491d9.tar.gz
Tango-00a491d9.zip
merge
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeSignalRClient.cs')
-rw-r--r--Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeSignalRClient.cs124
1 files changed, 0 insertions, 124 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeSignalRClient.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeSignalRClient.cs
deleted file mode 100644
index a8f01437c..000000000
--- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeSignalRClient.cs
+++ /dev/null
@@ -1,124 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Security.Authentication;
-using System.Text;
-using System.Threading.Tasks;
-using Tango.BL;
-using Tango.BL.Entities;
-using Tango.Integration.ExternalBridge.Web;
-using Tango.Integration.Operation;
-using Tango.PMR.Integration;
-using Tango.Settings;
-using Tango.Transport;
-using Tango.Transport.Adapters;
-
-namespace Tango.Integration.ExternalBridge
-{
- public class ExternalBridgeSignalRClient : ExternalBridgeTcpClient
- {
- public ExternalBridgeSignalRClient(String url, String hub, MachineInfo machineInfo)
- {
- ComponentName = $"External Bridge SignalR Client {_component_counter++}";
-
- SerialNumber = machineInfo.SerialNumber;
- IPAddress = machineInfo.IPAddress;
- Machine = ObservablesStaticCollections.Instance.Machines.SingleOrDefault(x => x.SerialNumber == SerialNumber);
- Adapter = new SignalRTransportAdapter(url, hub, SignalRTransportAdapterMode.CreateSession, SerialNumber, null, IPAddress);
-
- KeepAliveTimeout = TimeSpan.FromSeconds(5);
- KeepAliveRetries = 2;
- UseKeepAlive = false;
- }
-
- public ExternalBridgeSignalRClient(String url, String hub, Machine machine, MachineInfo machineInfo)
- {
- ComponentName = $"External Bridge SignalR Client {_component_counter++}";
-
- SerialNumber = machine.SerialNumber;
- IPAddress = machineInfo.IPAddress;
- Machine = machine;
- Adapter = new SignalRTransportAdapter(url, hub, SignalRTransportAdapterMode.CreateSession, SerialNumber, null, IPAddress);
-
- KeepAliveTimeout = TimeSpan.FromSeconds(5);
- KeepAliveRetries = 2;
- UseKeepAlive = false;
- }
-
- /// <summary>
- /// Connects to a remote external bridge service using the specified login.
- /// </summary>
- /// <param name="login">The login request.</param>
- /// <param name="protocol">Optional protocol configuration.</param>
- /// <returns></returns>
- /// <exception cref="AuthenticationException"></exception>
- public override async Task Connect(ExternalBridgeLoginRequest login, ConfigureProtocolRequest protocol = null)
- {
- if (State != TransportComponentState.Connected)
- {
- try
- {
- Adapter.EnableCompression = false;
- GenericProtocol = GenericMessageProtocol.Json;
-
- await Adapter.Connect();
-
- State = TransportComponentState.Connected;
- StartThreads();
-
- LogManager.Log($"{ComponentName}: External Bridge SignalR Client Connected...");
-
- TimeSpan? timeout = null;
-
- if (login.RequireSafetyLevelOperations)
- {
- timeout = TimeSpan.FromSeconds(35);
- }
-
- var response = await SendRequest<ExternalBridgeLoginRequest, ExternalBridgeLoginResponse>(login, new TransportRequestConfig() { ShouldLog = true, Timeout = timeout });
-
- if (protocol != null)
- {
- try
- {
- var configureResponse = await SendRequest<ConfigureProtocolRequest, ConfigureProtocolResponse>(protocol, new TransportRequestConfig() { ShouldLog = true });
- if (configureResponse.Message.Confirmed)
- {
- await Task.Delay(500);
- Adapter.EnableCompression = protocol.EnableCompression;
- GenericProtocol = protocol.GenericProtocol;
- }
- }
- catch (Exception ex)
- {
- LogManager.Log(ex, $"{ComponentName}: Could not configure remote machine protocol. Could be an old PPC version.");
- }
- }
-
- ApplicationInformation = response.Message.ApplicationInformation;
-
- SessionLogger.CreateSession();
-
- DeviceInformation = response.Message.DeviceInformation;
- if (!response.Message.Authenticated)
- {
- await Adapter.Disconnect();
- throw new AuthenticationException(response.Container.ErrorMessage);
- }
- }
- catch (Exception ex)
- {
- try
- {
- await Adapter.Disconnect();
- }
- catch { }
-
- throw ex;
- }
-
- ApplyContinuousChannelsConfiguration();
- }
- }
- }
-}